snd_pcm_open_name()
Create a handle and open a connection to an audio interface specified by name
Synopsis:
#include <sys/asoundlib.h>
int snd_pcm_open_name( snd_pcm_t **handle,
char *name,
int mode );
Arguments:
- handle
- A pointer to a location where snd_pcm_open_name() can store a handle for the audio interface. You'll need this handle when you call the other snd_pcm_* functions.
- name
- The name of the PCM device to open. Can be one of the following names (all found under /dev/snd):
- mode
- One of:
- SND_PCM_OPEN_PLAYBACK — open the playback channel (direction).
- SND_PCM_OPEN_CAPTURE — open the capture channel (direction).
You can OR the following flag with any of the above:
- SND_PCM_OPEN_NONBLOCK — force the mode to be
nonblocking.
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().
Library:
libasound.so
Use the -l asound option with qcc to link against this library.
Description:
The snd_pcm_open_name() function creates a handle and opens a connection to the named PCM audio interface.
Using names for audio devices (snd_pcm_open_name()) is preferred to using numbers (snd_pcm_open()), although snd_pcm_open_preferred(). remains a good alternative to both.
Returns:
EOK on success, a negative errno upon failure. The errno values are available in the errno.h file.
Errors:
- -EINVAL
- The state of handle is invalid, the mode is invalid, or an invalid state change occurred. You can call snd_pcm_channel_status() to check if the state change was invalid.
- -ENOENT
- The named device doesn't exist.
- -ENOMEM
- Not enough memory is available to allocate the control structures.
- -SND_ERROR_INCOMPATIBLE_VERSION
- The audio driver version is incompatible with the client library that the application is using.
Examples:
snd_pcm_open_name(&pcm_handle, "voice", SND_PCM_OPEN_CAPTURE);
See also the example of snd_pcm_open() in
Opening your PCM device
in the Playing and Capturing Audio Data chapter.
Classification:
QNX Neutrino
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Read the Caveats |
Caveats:
This function is not thread safe if handle (snd_pcm_t) is used across multiple threads.
Successfully opening a PCM channel doesn't guarantee that there are enough audio resources free to handle your application. Audio resources (e.g. subchannels) are allocated when you configure the channel by calling snd_pcm_channel_params() or snd_pcm_plugin_params() .
