mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-10 13:30:01 -05:00
Add snd_{ctl|pcm}_open_fallback() functions
This patch adds new API functions, snd_ctl_open_fallback() and snd_pcm_open_fallback(). These are just like snd_*_open_lconf() but used to open a fallback PCM/control. The difference is that it replaces the name string with the given original name, so that hctl and other upper-layers will recognize it as an alias. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
e6f990e5c9
commit
acb423d937
4 changed files with 50 additions and 0 deletions
|
|
@ -2259,6 +2259,30 @@ int snd_pcm_open_lconf(snd_pcm_t **pcmp, const char *name,
|
|||
return snd_pcm_open_noupdate(pcmp, lconf, name, stream, mode, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Opens a fallback PCM
|
||||
* \param pcmp Returned PCM handle
|
||||
* \param root Configuration root
|
||||
* \param name ASCII identifier of the PCM handle
|
||||
* \param orig_name The original ASCII name
|
||||
* \param stream Wanted stream
|
||||
* \param mode Open mode (see #SND_PCM_NONBLOCK, #SND_PCM_ASYNC)
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*/
|
||||
int snd_pcm_open_fallback(snd_pcm_t **pcmp, snd_config_t *root,
|
||||
const char *name, const char *orig_name,
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
{
|
||||
int err;
|
||||
assert(pcmp && name && root);
|
||||
err = snd_pcm_open_noupdate(pcmp, root, name, stream, mode, 0);
|
||||
if (err >= 0) {
|
||||
free((*pcmp)->name);
|
||||
(*pcmp)->name = orig_name ? strdup(orig_name) : NULL;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifndef DOC_HIDDEN
|
||||
int snd_pcm_new(snd_pcm_t **pcmp, snd_pcm_type_t type, const char *name,
|
||||
snd_pcm_stream_t stream, int mode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue