summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2023-05-03 22:24:47 +0200
committerJaroslav Kysela <perex@perex.cz>2023-05-03 22:27:40 +0200
commit58077e2f0d896ff848f3551518b1d9fc6c97d695 (patch)
tree4fce978a9115a825dc972f70b3c076105a84fa17
parent798f387fe9e5b5ddd705229ec7fff14f54c4e24e (diff)
downloadalsa-lib-58077e2f0d896ff848f3551518b1d9fc6c97d695.tar.gz
pcm: hw: fix the silence size setup in drain
The silence size cannot exceed the silence threshold. Move the check from the manual condition to the common code. This may happen for small ring buffers (where the 1/10th second is too large). Suggested-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--src/pcm/pcm_hw.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 180a3e84..8ffebed9 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -747,8 +747,6 @@ static int snd_pcm_hw_drain(snd_pcm_t *pcm)
snd_pcm_sw_params_current_no_lock(pcm, &sw_params);
if (hw->drain_silence > 0) {
silence_size = (pcm->rate * hw->drain_silence) / 1000;
- if (silence_size > pcm->buffer_size)
- silence_size = pcm->buffer_size;
goto __manual_silence;
}
/* compute end silence size, align to period size + extra time */
@@ -770,6 +768,8 @@ __manual_silence:
* or the next period wake up)
*/
sw_params.silence_threshold = pcm->buffer_size;
+ if (silence_size > pcm->buffer_size)
+ silence_size = pcm->buffer_size;
sw_params.silence_size = silence_size;
if (ioctl(hw->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sw_params) < 0) {
err = -errno;