[alsa-devel] [PATCH] alsa-lib: snd_pcm_delay and friends do not account for a write being currently in progress
john.lindgren at tds.net
Thu Jun 3 16:00:48 CEST 2010
Thanks for your reply.
On Thu, 2010-06-03 at 08:40 +0200, Clemens Ladisch wrote:
> John Lindgren wrote:
> > In a multi-threaded application it is possible for snd_pcm_delay or an
> > equivalent function to be called by one thread while another is sitting
> > in snd_pcm_writei.
> Alsa-lib is not thread safe. In theory, you are not even allowed to
> call snd_pcm_delay while another function on the same PCM device has not
> yet returned.
ALSA has the following significant features:
SMP and thread-safe design.
So, that's a big lie?
> > On the application side, the playback time counter will be calculated
> > during this time as 0.5 seconds written to ALSA
> This is wrong; as long as the write call has not returned, you do not
> know how much has been written (and when an error occurs, writing can
> stop before).
> To keep track of the actual amount of data written, use non-blocking
> mode and in a loop, write as much as possible in one call, then update
> your write counter, then wait for some more free space in the buffer
> with poll().
Would it work to simply call snd_pcm_wait?
More information about the Alsa-devel