Set or reset the blocking behavior of reads and writes to PCM channels
#include <sys/asoundlib.h> int snd_pcm_nonblock_mode( snd_pcm_t *handle, int nonblock );
Use the -l asound option to qcc to link against this library.
The snd_pcm_nonblock_mode() function sets up blocking (default) or nonblocking behavior for a handle.
Blocking mode suspends the execution of the client application when there's no room left in the buffer it's writing to, or nothing left to read when reading.
In nonblocking mode, programs aren't suspended, and the read and write functions return immediately with the number of bytes that were read or written by the driver. When used in this way, don't try to use the entire buffer after the call; instead, process the number of bytes returned and call the function again.
Zero on success, or a negative error code.
- Invalid file descriptor. Your handle may be corrupt.
- Invalid handle.
|Thread||Read the Caveats|
This function is not thread safe if handle (snd_pcm_t) is used across multiple threads.
If possible, it is recommended that you design your application to call select on the PCM file descriptor, instead of using this function. Asynchronously receiving notification from the driver is much less CPU-intensive than polling it in a non-blocking loop.
Last modified: 2014-06-24