[Previous] [Contents] [Next]

snd_pcm_nonblock_mode()

Set or reset the block behavior

Synopsis:

#include <sys/asoundlib.h>

int snd_pcm_nonblock_mode( snd_pcm_t * handle, 
                           int nonblock );

Library:

libasound.so

Description:

The snd_pcm_nonblock_mode() function sets up block (default) or nonblock behavior for a handle.

Block behavior suspends the execution of a program when there's no room left in the buffer when you're writing, or nothing left to read from when you're reading.

In nonblock behavior, programs aren't suspended and the above functions return immediately with the count of bytes which were read or written by the driver. When used in this way, don't try to use the entire buffer after the call, but instead process the number of bytes returned, and call the function again.

Errors:

-EBADF
The fildes of the handle isn't a valid file descriptor.
-EINVAL
Invalid handle.

Examples:

See the example in Opening your audio device in the Playing audio data chapter.

Classification:

ALSA

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

[Previous] [Contents] [Next]