Create a handle and open a connection to an audio interface specified by name
#include <sys/asoundlib.h> int snd_pcm_open_name( snd_pcm_t **handle, char *name, int mode );
Use this device: | For: |
---|---|
pcmPreferred | The default to use under most circumstances |
tones | The default to use for system sounds. Sounds played through this device aren't attenuated by the global volume setting. |
bluetooth | Accessing a Bluetooth headset |
voice | Acoustic echo cancellation and noise suppression, as well as lower latency |
hdmi_mix | Playback through a receiver connected over HDMI |
usb_mix | Playback through a receiver connected over USB |
usb | Capture over a microphone connected over USB |
You can OR the following flag with any of the above:
You can change the blocking setup later by calling snd_pcm_nonblock_mode().
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.
EOK on success, a negative errno upon failure. The errno values are available in the errno.h file.
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.
QNX Neutrino
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Read the 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() .