mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-01 22:58:49 -04:00
ucm: add PlaybackCTL and CaptureCTL default values when they are not set
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
c01e3d30b8
commit
530e8ea4c6
3 changed files with 76 additions and 28 deletions
|
|
@ -882,6 +882,45 @@ static int set_device(snd_use_case_mgr_t *uc_mgr,
|
|||
return err;
|
||||
}
|
||||
|
||||
static int add_auto_value(snd_use_case_mgr_t *uc_mgr, const char *key, char *value)
|
||||
{
|
||||
char *s;
|
||||
int err;
|
||||
|
||||
err = get_value1(uc_mgr, &value, &uc_mgr->value_list, key);
|
||||
if (err == -ENOENT) {
|
||||
s = strdup(value);
|
||||
if (s == NULL)
|
||||
return -ENOMEM;
|
||||
return uc_mgr_add_value(&uc_mgr->value_list, key, s);
|
||||
} else if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
free(value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add_auto_values(snd_use_case_mgr_t *uc_mgr)
|
||||
{
|
||||
struct ctl_list *ctl_list;
|
||||
const char *id;
|
||||
char buf[40];
|
||||
int err;
|
||||
|
||||
ctl_list = uc_mgr_get_one_ctl(uc_mgr);
|
||||
if (ctl_list) {
|
||||
id = snd_ctl_card_info_get_id(ctl_list->ctl_info);
|
||||
snprintf(buf, sizeof(buf), "hw:%s", id);
|
||||
err = add_auto_value(uc_mgr, "PlaybackCTL", buf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = add_auto_value(uc_mgr, "CaptureCTL", buf);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Init sound card use case manager.
|
||||
* \param uc_mgr Returned use case manager pointer
|
||||
|
|
@ -920,6 +959,10 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr,
|
|||
goto err;
|
||||
}
|
||||
|
||||
err = add_auto_values(mgr);
|
||||
if (err < 0)
|
||||
goto err;
|
||||
|
||||
*uc_mgr = mgr;
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue