]> git.alsa-project.org Git - alsa-lib.git/commit
pcm: rate: fix drain of partial period at end of buffer
authorAlan Young <consult.awy@gmail.com>
Wed, 23 Feb 2022 09:37:40 +0000 (09:37 +0000)
committerTakashi Iwai <tiwai@suse.de>
Tue, 8 Mar 2022 09:37:30 +0000 (10:37 +0100)
commit5b035bfa4aa8d926eb61949ec1bd392265eab837
tree4765405ab4b78b24c87fcfd8ee3136db5f987d3d
parentc41d710a69941d052e345fcc883e102c37d6deae
pcm: rate: fix drain of partial period at end of buffer

In the case that:
* the buffer size is not an integer multiple of the period size, and
* drain must flush a partial period located before the end of the buffer
  but without a full period available, where
* these conditions may pertain to the source or slave pcm buffer, and
* because rate conversion is always done on a full period,
it is necessary to check that both a full source period is available
before source pcm buffer wrap and a full slave period is available
before slave pcm buffer wrap in order to use the simple, single-commit
implementation in snd_pcm_rate_commit_area().

The alternative fix would be to change snd_pcm_rate_write_areas1() to
take size and slave_size parameters. This would be more disruptive to
the code base, tricky to get right, and is unnecessary given that
snd_pcm_mmap_commit() only commits the partial period of actually valid
converted samples.

Fixes: 3047f8fa5a3d ("Fix possible problems of playback drain with rate plugin")
Signed-off-by: Alan Young <consult.awy@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm_rate.c