ALSA snd_pcm_drop() is not clearing complete buffer
Asked Answered
A

2

9

I am using ALSA API snd_pcm_drop() to clear the buffers. But when I continue audio later with snd_pcm_prepare(), I can hear part of previous audio which was supposed to be cleared. This happens when I have a high value of snd_pcm_sw_params_set_stop_threshold(). If I am using a lower value, the partial audio from previous audio session wont be played.

What is happening here ? How to clear off the buffer completely ?

(I am new to ALSA)

Thanks

Ashburn answered 5/4, 2013 at 4:54 Comment(4)
Is it an option to use snd_pcm_drain() instead of snd_pcm_drop()?Wisner
Sounds like a driver bug, but this is hard to say without more information.Cusp
@Multimedia Mike , As per documentation, snd_pcm_drain() will not drop the buffer immediately. So it is not useful to me.Anyway I tried snd_pcm_drain(), but the observation is same.Ashburn
did you ever figure this out? I am seeing the same thing on the Raspberry Pi.Barram
B
1

I solved the same issue in this way:

snd_pcm_prepare(pcm_handle);
snd_pcm_drop(pcm_handle);
Bonheur answered 29/3, 2019 at 15:4 Comment(0)
S
0

" can hear part of previous audio which was supposed to be cleared." because there is still some audio data left in the ALSA buffer, and the data is not big enough to play.Enlarge the audio package when you put into ALSA buffer may solve the problem.

Supplant answered 10/6, 2014 at 6:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.