QNX Developer Support
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 handle for the PCM device, which you must have opened by calling snd_pcm_open() or snd_pcm_open_preferred().
- If this argument is nonzero, non-blocking mode is in effect for subsequent calls to snd_pcm_read() and snd_pcm_write().
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.
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.