Re: Reproducible pops on some hardware

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bryan Ischo wrote:
> Here is a technique I have tried to reduce the effect of underrun.  In
> my application, underrun either means that the process that is
> generating audio can't keep up (it's a game emulator, generating audio
> and video frames at a fixed rate, and some games can't be emulated at
> full speed and so don't generate audio fast enough, and in that case,
> the user experience is not going to be great; I'd rather have choppy
> audio than pops though so this is why I tried the following technique):
>
> snd_pcm_sw_params_get_boundary(sw_params, &boundary);
> snd_pcm_sw_params_set_stop_threshold(pcmM, sw_params, boundary);
> snd_pcm_sw_params_set_silence_threshold(pcmM, sw_params, 0);
> snd_pcm_sw_params_set_silence_size(pcmM, sw_params, boundary);
>
> The idea here is to play silence on underrun instead of looping (which
> sounds bad), and also to avoid having to re-prepare the device after
> underrun which takes time and only compounds the performance problem
> that is resulting in underruns.
>
> The thing is, this technique didn't work on some hardware - once ALSA
> played silence instead of underrunning one time, it never would play
> anything again.

If an underrun happens, you have to catch up, i.e., you have to write
all the data even though it was not played.  This works only if there
was a temporary delay, not if the generated audio is consistently too
slow.

You can avoid generating that data by checking for an underrun
(snd_pcm_avail will be larger than the buffer size) and skipping
over the lost part of the buffer (snd_pcm_forward, if supported,
or just write zeroes ).


Regards,
Clemens

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user


[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux