Re: [PATCH] alsa-lib: snd_pcm_delay and friends do not account for a write being currently in progress

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

 



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.

>From http://alsa-project.org/main/index.php/Main_Page:

        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?

John Lindgren

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel


[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux