Create a handle and open a connection to a specified audio interface
#include <sys/asoundlib.h> int snd_pcm_open( snd_pcm_t **handle, int card, int device, int mode );
- A pointer to a location where snd_pcm_open() stores a handle for the audio interface. You'll need this handle when you call the other snd_pcm_* functions.
- The card number.
- The audio device number.
- One of:
- SND_PCM_OPEN_PLAYBACK — open the playback channel (direction).
- SND_PCM_OPEN_CAPTURE — open the capture channel (direction).
You can OR this flag with any of the above:
- SND_PCM_OPEN_NONBLOCK — force the mode to be
This affects any reading from or writing to the device that you do later;
you can query the device any time without blocking.
You can change the blocking setup later by calling snd_pcm_nonblock_mode()
Use the -l asound option to qcc to link against this library.
The snd_pcm_open() function creates a handle and opens a connection to the audio interface for sound card number card and audio device number device. It also checks if the protocol is compatible to prevent the use of programs written to an older API with newer drivers.
There are no defaults; your application must specify all the arguments to this function.
Zero on success, or a negative error code.
- Not enough memory to allocate control structures.
See the example in Opening your PCM device in the Playing and Capturing Audio Data chapter.
Last modified: 2013-10-30