mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-05 13:30:00 -05:00
Definitely fixed the sorting/find problems for hcontrol & mixer.
This commit is contained in:
parent
6ea4260c1c
commit
e02f9a9650
4 changed files with 22 additions and 22 deletions
|
|
@ -233,9 +233,9 @@ static int _snd_mixer_find_elem(snd_mixer_t *mixer, snd_mixer_elem_t *elem, int
|
|||
while (l < u) {
|
||||
idx = (l + u) / 2;
|
||||
c = mixer->compare(elem, mixer->pelems[idx]);
|
||||
if (c > 0)
|
||||
if (c < 0)
|
||||
u = idx;
|
||||
else if (c < 0)
|
||||
else if (c > 0)
|
||||
l = idx + 1;
|
||||
else
|
||||
break;
|
||||
|
|
@ -268,9 +268,9 @@ int snd_mixer_elem_add(snd_mixer_elem_t *elem, snd_mixer_class_t *class)
|
|||
assert(dir != 0);
|
||||
if (dir > 0) {
|
||||
list_add(&elem->list, &mixer->pelems[idx]->list);
|
||||
idx++;
|
||||
} else {
|
||||
list_add_tail(&elem->list, &mixer->pelems[idx]->list);
|
||||
idx++;
|
||||
}
|
||||
memmove(mixer->pelems + idx + 1,
|
||||
mixer->pelems + idx,
|
||||
|
|
@ -431,7 +431,7 @@ static int snd_mixer_sort(snd_mixer_t *mixer)
|
|||
assert(mixer);
|
||||
assert(mixer->compare);
|
||||
INIT_LIST_HEAD(&mixer->elems);
|
||||
qsort(mixer->pelems, mixer->count, sizeof(snd_mixer_elem_t), compar);
|
||||
qsort(mixer->pelems, mixer->count, sizeof(snd_mixer_elem_t*), compar);
|
||||
for (k = 0; k < mixer->count; k++)
|
||||
list_add_tail(&mixer->pelems[k]->list, &mixer->elems);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -97,13 +97,11 @@ static const char *get_short_name(const char *lname)
|
|||
static int get_compare_weight(const char *name, int index)
|
||||
{
|
||||
static char *names[] = {
|
||||
"Master",
|
||||
"Master Mono",
|
||||
"Master Digital",
|
||||
"Master",
|
||||
"Tone Control - Bass",
|
||||
"Tone Control - Treble",
|
||||
"Synth Tone Control - Bass",
|
||||
"Synth Tone Control - Treble",
|
||||
"Bass",
|
||||
"Treble",
|
||||
"PCM",
|
||||
"Surround",
|
||||
"Synth",
|
||||
|
|
@ -692,6 +690,7 @@ int simple_add1(snd_mixer_class_t *class, const char *name,
|
|||
melem->private_data = simple;
|
||||
melem->private_free = selem_free;
|
||||
INIT_LIST_HEAD(&melem->helems);
|
||||
melem->compare_weight = get_compare_weight(simple->id.name, simple->id.index);
|
||||
new = 1;
|
||||
} else {
|
||||
simple = melem->private_data;
|
||||
|
|
@ -712,7 +711,6 @@ int simple_add1(snd_mixer_class_t *class, const char *name,
|
|||
err = snd_mixer_elem_attach(melem, helem);
|
||||
if (err < 0)
|
||||
return err;
|
||||
melem->compare_weight = get_compare_weight(simple->id.name, simple->id.index);
|
||||
err = simple_update(melem);
|
||||
assert(err >= 0);
|
||||
if (new)
|
||||
|
|
@ -812,7 +810,10 @@ static int simple_compare(const snd_mixer_elem_t *c1, const snd_mixer_elem_t *c2
|
|||
{
|
||||
selem_t *s1 = c1->private_data;
|
||||
selem_t *s2 = c2->private_data;
|
||||
return strcmp(s1->id.name, s2->id.name);
|
||||
int res = strcmp(s1->id.name, s2->id.name);
|
||||
if (res)
|
||||
return res;
|
||||
return s1->id.index - s2->id.index;
|
||||
}
|
||||
|
||||
int snd_mixer_selem_register(snd_mixer_t *mixer, snd_mixer_class_t **classp)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue