mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-01 22:58:49 -04:00
ucm: add ValueDefaults section to the master file
- the get_value() function is recoded (tries to find the value in parent's list) Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
aaf55f1641
commit
d8b7816196
4 changed files with 60 additions and 25 deletions
|
|
@ -445,6 +445,7 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **mgr,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
INIT_LIST_HEAD(&uc_mgr->verb_list);
|
INIT_LIST_HEAD(&uc_mgr->verb_list);
|
||||||
INIT_LIST_HEAD(&uc_mgr->default_list);
|
INIT_LIST_HEAD(&uc_mgr->default_list);
|
||||||
|
INIT_LIST_HEAD(&uc_mgr->value_list);
|
||||||
pthread_mutex_init(&uc_mgr->mutex, NULL);
|
pthread_mutex_init(&uc_mgr->mutex, NULL);
|
||||||
|
|
||||||
uc_mgr->card_name = strdup(card_name);
|
uc_mgr->card_name = strdup(card_name);
|
||||||
|
|
@ -688,6 +689,9 @@ static int get_value_list(snd_use_case_mgr_t *uc_mgr,
|
||||||
if (verb == NULL)
|
if (verb == NULL)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
INIT_LIST_HEAD(&mylist);
|
INIT_LIST_HEAD(&mylist);
|
||||||
|
err = add_values(&mylist, identifier, &uc_mgr->value_list);
|
||||||
|
if (err < 0)
|
||||||
|
goto __fail;
|
||||||
err = add_values(&mylist, identifier, &verb->value_list);
|
err = add_values(&mylist, identifier, &verb->value_list);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __fail;
|
goto __fail;
|
||||||
|
|
@ -821,14 +825,16 @@ static int get_value1(const char **value, struct list_head *value_list,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get value
|
* \brief Get value
|
||||||
* \param list Returned list
|
* \param uc_mgr Use case manager
|
||||||
* \param verbname For verb (NULL = current)
|
* \param identifier Value identifier (string)
|
||||||
* \return Number of list entries if success, otherwise a negative error code
|
* \param value Returned value string
|
||||||
|
* \param modifier modifier name (string)
|
||||||
|
* \return Zero on success (value is filled), otherwise a negative error code
|
||||||
*/
|
*/
|
||||||
static int get_value(snd_use_case_mgr_t *uc_mgr,
|
static int get_value(snd_use_case_mgr_t *uc_mgr,
|
||||||
const char *identifier,
|
const char *identifier,
|
||||||
|
|
@ -836,16 +842,23 @@ static int get_value(snd_use_case_mgr_t *uc_mgr,
|
||||||
const char *modifier)
|
const char *modifier)
|
||||||
{
|
{
|
||||||
struct use_case_modifier *mod;
|
struct use_case_modifier *mod;
|
||||||
|
int err;
|
||||||
|
|
||||||
if (uc_mgr->active_verb == NULL)
|
if (modifier != NULL) {
|
||||||
return -ENOENT;
|
mod = find_modifier(uc_mgr->active_verb, modifier);
|
||||||
if (modifier == NULL)
|
if (mod != NULL) {
|
||||||
return get_value1(value, &uc_mgr->active_verb->value_list,
|
err = get_value1(value, &mod->value_list, identifier);
|
||||||
identifier);
|
if (err >= 0 || err != -ENOENT)
|
||||||
mod = find_modifier(uc_mgr->active_verb, modifier);
|
return err;
|
||||||
if (mod == NULL)
|
}
|
||||||
return -EINVAL;
|
}
|
||||||
return get_value1(value, &mod->value_list, identifier);
|
err = get_value1(value, &uc_mgr->active_verb->value_list, identifier);
|
||||||
|
if (err >= 0 || err != -ENOENT)
|
||||||
|
return err;
|
||||||
|
err = get_value1(value, &uc_mgr->value_list, identifier);
|
||||||
|
if (err >= 0 || err != -ENOENT)
|
||||||
|
return err;
|
||||||
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -930,26 +930,33 @@ static int parse_controls(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
|
||||||
* # The file is divided into Use case sections. One section per use case verb.
|
* # The file is divided into Use case sections. One section per use case verb.
|
||||||
*
|
*
|
||||||
* SectionUseCase."Voice Call" {
|
* SectionUseCase."Voice Call" {
|
||||||
* File "voice_call_blah"
|
* File "voice_call_blah"
|
||||||
* Comment "Make a voice phone call."
|
* Comment "Make a voice phone call."
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* SectionUseCase."HiFi" {
|
* SectionUseCase."HiFi" {
|
||||||
* File "hifi_blah"
|
* File "hifi_blah"
|
||||||
* Comment "Play and record HiFi quality Music."
|
* Comment "Play and record HiFi quality Music."
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* # Define Value defaults
|
||||||
|
*
|
||||||
|
* ValueDefaults {
|
||||||
|
* PlaybackCTL "hw:CARD=0,DEV=0"
|
||||||
|
* CaptureCTL "hw:CARD=0,DEV=0"
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* # This file also stores the default sound card state.
|
* # This file also stores the default sound card state.
|
||||||
*
|
*
|
||||||
* SectionDefaults [
|
* SectionDefaults [
|
||||||
* cset "name='Master Playback Switch',index=2 1,1"
|
* cset "name='Master Playback Switch',index=2 1,1"
|
||||||
* cset "name='Master Playback Volume',index=2 25,25"
|
* cset "name='Master Playback Volume',index=2 25,25"
|
||||||
* cset "name='Master Mono Playback',index=1 0"
|
* cset "name='Master Mono Playback',index=1 0"
|
||||||
* cset "name='Master Mono Playback Volume',index=1 0"
|
* cset "name='Master Mono Playback Volume',index=1 0"
|
||||||
* cset "name='PCM Switch',index=2 1,1"
|
* cset "name='PCM Switch',index=2 1,1"
|
||||||
* exec "some binary here"
|
* exec "some binary here"
|
||||||
* msleep 50
|
* msleep 50
|
||||||
* ........
|
* ........
|
||||||
* ]
|
* ]
|
||||||
*
|
*
|
||||||
* # End of example file.
|
* # End of example file.
|
||||||
|
|
@ -999,6 +1006,17 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
|
||||||
return err;
|
return err;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get the default values */
|
||||||
|
if (strcmp(id, "ValueDefaults") == 0) {
|
||||||
|
err = parse_value(uc_mgr, &uc_mgr->value_list, n);
|
||||||
|
if (err < 0) {
|
||||||
|
uc_error("error: failed to parse ValueDefaults");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
uc_error("uknown master file field %s", id);
|
uc_error("uknown master file field %s", id);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,9 @@ struct snd_use_case_mgr {
|
||||||
/* default settings - sequence */
|
/* default settings - sequence */
|
||||||
struct list_head default_list;
|
struct list_head default_list;
|
||||||
|
|
||||||
|
/* default settings - value list */
|
||||||
|
struct list_head value_list;
|
||||||
|
|
||||||
/* current status */
|
/* current status */
|
||||||
struct use_case_verb *active_verb;
|
struct use_case_verb *active_verb;
|
||||||
struct list_head active_devices;
|
struct list_head active_devices;
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,7 @@ void uc_mgr_free_verb(snd_use_case_mgr_t *uc_mgr)
|
||||||
free(verb);
|
free(verb);
|
||||||
}
|
}
|
||||||
uc_mgr_free_sequence(&uc_mgr->default_list);
|
uc_mgr_free_sequence(&uc_mgr->default_list);
|
||||||
|
uc_mgr_free_value(&uc_mgr->value_list);
|
||||||
free(uc_mgr->comment);
|
free(uc_mgr->comment);
|
||||||
uc_mgr->comment = NULL;
|
uc_mgr->comment = NULL;
|
||||||
uc_mgr->active_verb = NULL;
|
uc_mgr->active_verb = NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue