mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
alsa-mixer: Introduce "description-key" option for paths
Previously the path description was looked up based on the path name only. Since there can be multiple paths that use the same description, it had to be possible to have multiple paths with the same name. Having the same name with multiple paths makes identifying the paths more complex than necessary, so the plan is to make it impossible to have paths with the same name. This patch prepares for that by retaining the possibility to still have the same description with multiple paths. Instead of the path name, the path description is looked up by using the "path description key" if it is set (path name is still used as a fallback lookup key).
This commit is contained in:
parent
66aeea7f72
commit
3c1ca6d4b8
20 changed files with 43 additions and 27 deletions
|
|
@ -53,15 +53,18 @@
|
|||
static int setting_select(pa_alsa_setting *s, snd_mixer_t *m);
|
||||
|
||||
struct description_map {
|
||||
const char *name;
|
||||
const char *key;
|
||||
const char *description;
|
||||
};
|
||||
|
||||
static const char *lookup_description(const char *name, const struct description_map dm[], unsigned n) {
|
||||
static const char *lookup_description(const char *key, const struct description_map dm[], unsigned n) {
|
||||
unsigned i;
|
||||
|
||||
if (!key)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (pa_streq(dm[i].name, name))
|
||||
if (pa_streq(dm[i].key, key))
|
||||
return _(dm[i].description);
|
||||
|
||||
return NULL;
|
||||
|
|
@ -2361,12 +2364,16 @@ static int path_verify(pa_alsa_path *p) {
|
|||
return -1;
|
||||
|
||||
if (!p->description)
|
||||
p->description = pa_xstrdup(lookup_description(p->name,
|
||||
p->description = pa_xstrdup(lookup_description(p->description_key ? p->description_key : p->name,
|
||||
well_known_descriptions,
|
||||
PA_ELEMENTSOF(well_known_descriptions)));
|
||||
|
||||
if (!p->description)
|
||||
if (!p->description) {
|
||||
if (p->description_key)
|
||||
pa_log_warn("Path %s: Unrecognized description key: %s", p->name, p->description_key);
|
||||
|
||||
p->description = pa_xstrdup(p->name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2388,6 +2395,7 @@ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa
|
|||
pa_config_item items[] = {
|
||||
/* [General] */
|
||||
{ "priority", pa_config_parse_unsigned, NULL, "General" },
|
||||
{ "description-key", pa_config_parse_string, NULL, "General" },
|
||||
{ "description", pa_config_parse_string, NULL, "General" },
|
||||
{ "name", pa_config_parse_string, NULL, "General" },
|
||||
{ "mute-during-activation", pa_config_parse_bool, NULL, "General" },
|
||||
|
|
@ -2427,10 +2435,11 @@ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa
|
|||
p->eld_device = -1;
|
||||
|
||||
items[0].data = &p->priority;
|
||||
items[1].data = &p->description;
|
||||
items[2].data = &p->name;
|
||||
items[3].data = &mute_during_activation;
|
||||
items[4].data = &p->eld_device;
|
||||
items[1].data = &p->description_key;
|
||||
items[2].data = &p->description;
|
||||
items[3].data = &p->name;
|
||||
items[4].data = &mute_during_activation;
|
||||
items[5].data = &p->eld_device;
|
||||
|
||||
if (!paths_dir)
|
||||
paths_dir = get_default_paths_dir();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue