Lunar Mushrooms
Lunar Mushrooms

Reputation: 8918

ALSA snd_pcm_drop() is not clearing complete buffer

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

Upvotes: 9

Views: 5175

Answers (2)

Angelo Dureghello
Angelo Dureghello

Reputation: 330

I solved the same issue in this way:

snd_pcm_prepare(pcm_handle);
snd_pcm_drop(pcm_handle);

Upvotes: 1

Bruce
Bruce

Reputation: 1

" 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.

Upvotes: 0

Related Questions