mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04:00
Changed in the compare_weight counting
This commit is contained in:
parent
da62fd77b1
commit
06e79b9828
1 changed files with 20 additions and 8 deletions
|
|
@ -185,7 +185,7 @@ static int snd_hctl_compare_mixer_priority_lookup(const char **name, const char
|
||||||
return NOT_FOUND;
|
return NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_compare_weight(const char *name)
|
static int get_compare_weight(const snd_ctl_elem_id_t *id)
|
||||||
{
|
{
|
||||||
static const char *names[] = {
|
static const char *names[] = {
|
||||||
"Master",
|
"Master",
|
||||||
|
|
@ -204,6 +204,7 @@ static int get_compare_weight(const char *name)
|
||||||
"Mic",
|
"Mic",
|
||||||
"Phone",
|
"Phone",
|
||||||
"Video",
|
"Video",
|
||||||
|
"Zoom Video",
|
||||||
"PC Speaker",
|
"PC Speaker",
|
||||||
"Aux",
|
"Aux",
|
||||||
"Mono",
|
"Mono",
|
||||||
|
|
@ -243,13 +244,26 @@ static int get_compare_weight(const char *name)
|
||||||
"Center",
|
"Center",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
const char *name = id->name, *name1;
|
||||||
int res, res1;
|
int res, res1;
|
||||||
|
|
||||||
if ((res = snd_hctl_compare_mixer_priority_lookup((const char **)&name, names, 1000000)) == NOT_FOUND)
|
if ((res = snd_hctl_compare_mixer_priority_lookup((const char **)&name, names, 1000000)) == NOT_FOUND)
|
||||||
return NOT_FOUND;
|
return NOT_FOUND;
|
||||||
|
if (*name == '\0')
|
||||||
|
return res;
|
||||||
|
for (name1 = name; *name1 != '\0'; name1++);
|
||||||
|
for (name1--; name1 != name && *name1 != ' '; name1--);
|
||||||
|
while (name1 != name && *name1 == ' ')
|
||||||
|
name1--;
|
||||||
|
if (name1 != name) {
|
||||||
|
for (; name1 != name && *name1 != ' '; name1--);
|
||||||
|
name = name1;
|
||||||
if ((res1 = snd_hctl_compare_mixer_priority_lookup((const char **)&name, names1, 1000)) == NOT_FOUND)
|
if ((res1 = snd_hctl_compare_mixer_priority_lookup((const char **)&name, names1, 1000)) == NOT_FOUND)
|
||||||
return res;
|
return res;
|
||||||
res += res1;
|
res += res1;
|
||||||
|
} else {
|
||||||
|
name = name1;
|
||||||
|
}
|
||||||
if ((res1 = snd_hctl_compare_mixer_priority_lookup((const char **)&name, names2, 1)) == NOT_FOUND)
|
if ((res1 = snd_hctl_compare_mixer_priority_lookup((const char **)&name, names2, 1)) == NOT_FOUND)
|
||||||
return res;
|
return res;
|
||||||
return res + res1;
|
return res + res1;
|
||||||
|
|
@ -264,7 +278,7 @@ static int _snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id, in
|
||||||
assert(hctl && id);
|
assert(hctl && id);
|
||||||
assert(hctl->compare);
|
assert(hctl->compare);
|
||||||
el.id = *id;
|
el.id = *id;
|
||||||
el.compare_weight = get_compare_weight(id->name);
|
el.compare_weight = get_compare_weight(id);
|
||||||
l = 0;
|
l = 0;
|
||||||
u = hctl->count;
|
u = hctl->count;
|
||||||
while (l < u) {
|
while (l < u) {
|
||||||
|
|
@ -285,8 +299,7 @@ static int snd_hctl_elem_add(snd_hctl_t *hctl, snd_hctl_elem_t *elem)
|
||||||
{
|
{
|
||||||
int dir;
|
int dir;
|
||||||
int idx;
|
int idx;
|
||||||
if (elem->id.iface == SNDRV_CTL_ELEM_IFACE_MIXER)
|
elem->compare_weight = get_compare_weight(&elem->id);
|
||||||
elem->compare_weight = get_compare_weight(elem->id.name);
|
|
||||||
if (hctl->count == hctl->alloc) {
|
if (hctl->count == hctl->alloc) {
|
||||||
snd_hctl_elem_t **h;
|
snd_hctl_elem_t **h;
|
||||||
hctl->alloc += 32;
|
hctl->alloc += 32;
|
||||||
|
|
@ -520,8 +533,7 @@ int snd_hctl_load(snd_hctl_t *hctl)
|
||||||
}
|
}
|
||||||
elem->id = list.pids[idx];
|
elem->id = list.pids[idx];
|
||||||
elem->hctl = hctl;
|
elem->hctl = hctl;
|
||||||
if (elem->id.iface == SNDRV_CTL_ELEM_IFACE_MIXER)
|
elem->compare_weight = get_compare_weight(&elem->id);
|
||||||
elem->compare_weight = get_compare_weight(elem->id.name);
|
|
||||||
hctl->pelems[idx] = elem;
|
hctl->pelems[idx] = elem;
|
||||||
list_add_tail(&elem->list, &hctl->elems);
|
list_add_tail(&elem->list, &hctl->elems);
|
||||||
hctl->count++;
|
hctl->count++;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue