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 );
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.
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.
snd_pcm_open(), snd_pcm_open_preferred(), snd_pcm_read(), snd_pcm_write()