[alsa-devel] XRUN handling

Clemens Ladisch clemens at ladisch.de
Tue Jul 6 14:34:55 CEST 2010


melwyn lobo wrote:
>> melwyn lobo wrote:
>>> In case snd_pcm_playback_avail() is less than stop threshold but
>>> greater than 0, then these bytes are missing after Xrun prepare and
>>> start stage.
>>
>> Preparing a stream resets it, i.e., any data currently in the buffer
>> is discarded.
>>
>> If you want to have data in the buffer after preparing, you have to
>> write it again.
> 
> Thanks for the confirmation. Our client is working on aplay to test
> our driver in which already there is this issue.
> Is there any workaround in kernel/driver space that could be done

When the ALSA framework tells the driver to stop, and then resets the
pointers, the driver cannot avoid doing this.


Applications have two choices how xruns are to be handled:
1) Stop the stream; the application must then reset the stream (by
   preparing it).  This mode is selected by using a stop_threshold that
   is lower than the buffer_size.  This is the default mode.
2) Continue playing.  The device will play old data from the ring
   buffer, until the application has caught up and written new data
   to the buffer.  This mode is selected by setting stop_threshold to
   the boundary value.


Regards,
Clemens


More information about the Alsa-devel mailing list