Re: How to interrupt a blocking call to snd_pcm_writei

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

 



Clemens Ladisch wrote:
> Florian Winter wrote:
>   
>> Suppose, an ALSA playback device is opened in blocking mode, and one
>> thread calls snd_pcm_writei. If the snd_pcm_writei call blocks, because
>> the internal buffer of the ALSA device is full, is there a way by which
>> another thread can interrupt the call, so it returns immediately without
>> writing any data to the device?
>>     
>
> No.  As far as the user-space library is concerned, ALSA is not thread
> safe.
>
> You have to use non-blocking mode and poll() so that you can send a
> message through a file descriptor (e.g. pipe or eventfd).
>   
Thank you. This is also the only option I see.

This leads to some more questions:

I can't derive from the documentation when exactly my poll() call will
wake up. Is there a way to tell ALSA something like: "I want to write at
least N frames to the device without blocking. Please don't wake up my
poll() call until I can do this" (assuming that N is a meaningful value,
i.e. less than the total buffer size)?

If I can not control this parameter N, is there at least a way to query
it from ALSA?
Will the ALSA device always become writeable when N bytes can be
written, or is the ALSA implementation (driver implementation) free to
decide when and when not to block?

Best regards,
Florian

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
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