[Stk] default number of buffers should be higher for alsa

Stephen Sinclair sinclair at music.mcgill.ca
Tue Dec 21 12:31:17 PST 2010


On Tue, Dec 21, 2010 at 1:28 AM, Tristan Matthews
<le.businessman at gmail.com> wrote:
> Hi Stephen,
>
> I wonder if this behaviour could be related to the fact that in
> RtAudio, snd_pcm_open is called with the SND_PCM_ASYNC flag, rather
> than the SND_PCM_NONBLOCK flag. The difference is described here:
>
>    /* If SND_PCM_NONBLOCK is used, read / write access to the    */
>    /* PCM device will return immediately. If SND_PCM_ASYNC is    */
>    /* specified, SIGIO will be emitted whenever a period has             */
>    /* been completely processed by the soundcard.                           */
>
> source: http://www.suse.de/~mana/alsa090_howto.html
>
> I noticed this because I've been comparing RtAudio's ALSA backend
> against GStreamer's, and this one of the noticeable differences. If
> RtAudio used the NONBLOCK flag, the steps would be to wait for free
> space in the pcm buffer for at most a specified timeout (in GStreamer,
> it's 4 times the period time) before writing to the pcm buffer,
> something like:
>
> snd_pcm_wait(handle[0], TIMEOUT);
> result = snd_pcm_writei( handle[0], buffer, stream_.bufferSize );
>
> I was thinking of starting a branch to improve RtApiAlsa, namely to
> allow it to work when another program is using the sound card.
> Resolving this clicking issue would be another good fix to have in
> this branch.

Hi Tristan,

I tried randomly disabling the ASYNC flag just to see what effect it
had but it didn't seem to help.  I didn't play with NONBLOCK at all,
but what you say makes some sense.  It would be worth trying.

If you want to try doing this modification and sharing it with me on
github maybe we can prepare patches there, and then submit them to
this list when we've both fully tested it.

Steve



More information about the Stk mailing list