Creates a new handle and opens a connection to the kernel sound audio interface for sound card number card (0-N) and audio device number device. Function also checks if protocol is compatible to prevent use of old programs with a new kernel API. Function returns zero if successful otherwise it returns an error code. Error code -EBUSY is returned when some process owns the selected direction and the blocking behaviour is active.
When hardware supports the multi open feature (it means that more exclusive digital audio resources - subdevices - are available per device), the driver returns -EBUSY when all subdevices are exhausted.
After the open, the kernel interface accepts only snd_pcm_channel_params call. There are no default setup, everything must be prepared with an application.
The following modes should be used for the mode argument:
Mode | Description |
---|---|
SND_PCM_OPEN_PLAYBACK | The playback channel (direction) is opened. |
SND_PCM_OPEN_CAPTURE | The capture channel (direction) is opened. |
SND_PCM_OPEN_DUPLEX | Both (playback & capture) channels (directions) are opened. |
SND_PCM_OPEN_NONBLOCK | This flag may be or-ed with any previous modes to force the non-block mode. The blocking setup may be changed with snd_pcm_nonblock_mode function later. When this flag is not used then the driver will wait until the device is not free again. Use this flag, if you want immediate response. |
Function returns zero if successful and handle argument contains valid access handle, otherwise it returns an error code.