]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: rate: fix the crash for the partial period copy
authorJaroslav Kysela <perex@perex.cz>
Mon, 17 Oct 2022 11:52:51 +0000 (13:52 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 17 Oct 2022 11:58:41 +0000 (13:58 +0200)
The size argument in snd_pcm_rate_commit_area can be smaller
than cont in drain. Return the original code. It should
not make things worse. Perhaps, we can fill the rest of
the period with silence in this case.

Fixes: https://github.com/alsa-project/alsa-lib/issues/274
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_rate.c

index e8815e8b4f67f1a3f995b5c1ad8564cb13ad16ca..e5d8eddd13f9ed964c3ad1e7578275c684b26ffa 100644 (file)
@@ -770,7 +770,7 @@ static snd_pcm_sframes_t snd_pcm_rate_forward(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
 
 static int snd_pcm_rate_commit_area(snd_pcm_t *pcm, snd_pcm_rate_t *rate,
                                    snd_pcm_uframes_t appl_offset,
-                                   snd_pcm_uframes_t size,
+                                   snd_pcm_uframes_t size ATTRIBUTE_UNUSED,
                                    snd_pcm_uframes_t slave_size)
 {
        snd_pcm_uframes_t cont = pcm->buffer_size - appl_offset;
@@ -816,7 +816,7 @@ static int snd_pcm_rate_commit_area(snd_pcm_t *pcm, snd_pcm_rate_t *rate,
                                   pcm->format);
                snd_pcm_areas_copy(rate->pareas, cont,
                                   areas, 0,
-                                  pcm->channels, size - cont,
+                                  pcm->channels, pcm->period_size - cont,
                                   pcm->format);
 
                snd_pcm_rate_write_areas1(pcm, rate->pareas, 0, rate->sareas, 0);