mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-16 08:56:40 -05:00
alsa: legacy card - set available_group
Create automatically the groups per paths where the similar jacks are used. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
1fb449213f
commit
6618527451
2 changed files with 50 additions and 0 deletions
|
|
@ -739,6 +739,7 @@ void pa_alsa_path_free(pa_alsa_path *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_proplist_free(p->proplist);
|
pa_proplist_free(p->proplist);
|
||||||
|
pa_xfree(p->available_group);
|
||||||
pa_xfree(p->name);
|
pa_xfree(p->name);
|
||||||
pa_xfree(p->description);
|
pa_xfree(p->description);
|
||||||
pa_xfree(p->description_key);
|
pa_xfree(p->description_key);
|
||||||
|
|
@ -4180,6 +4181,51 @@ fail:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* the logic is simple: if we see the jack in multiple paths */
|
||||||
|
/* assign all those jacks to one available_group */
|
||||||
|
static void mapping_group_available(pa_hashmap *paths)
|
||||||
|
{
|
||||||
|
void *state, *state2;
|
||||||
|
pa_alsa_path *p, *p2;
|
||||||
|
pa_alsa_jack *j, *j2;
|
||||||
|
uint32_t num = 1;
|
||||||
|
|
||||||
|
PA_HASHMAP_FOREACH(p, paths, state) {
|
||||||
|
const char *found = NULL;
|
||||||
|
bool has_control = false;
|
||||||
|
PA_LLIST_FOREACH(j, p->jacks) {
|
||||||
|
if (!j->has_control || j->state_plugged == PA_AVAILABLE_NO)
|
||||||
|
continue;
|
||||||
|
has_control = true;
|
||||||
|
j->state_plugged = PA_AVAILABLE_UNKNOWN;
|
||||||
|
PA_HASHMAP_FOREACH(p2, paths, state2) {
|
||||||
|
if (p2 == p)
|
||||||
|
break;
|
||||||
|
PA_LLIST_FOREACH(j2, p->jacks) {
|
||||||
|
if (!j2->has_control || j->state_plugged == PA_AVAILABLE_NO)
|
||||||
|
continue;
|
||||||
|
if (pa_streq(j->name, j2->name)) {
|
||||||
|
j2->state_plugged = PA_AVAILABLE_UNKNOWN;
|
||||||
|
found = p2->available_group;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!has_control)
|
||||||
|
continue;
|
||||||
|
if (!found) {
|
||||||
|
p->available_group = pa_sprintf_malloc("Legacy %d", num);
|
||||||
|
} else {
|
||||||
|
p->available_group = pa_xstrdup(found);
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void mapping_paths_probe(pa_alsa_mapping *m, pa_alsa_profile *profile,
|
static void mapping_paths_probe(pa_alsa_mapping *m, pa_alsa_profile *profile,
|
||||||
pa_alsa_direction_t direction, pa_hashmap *used_paths,
|
pa_alsa_direction_t direction, pa_hashmap *used_paths,
|
||||||
pa_hashmap *mixers) {
|
pa_hashmap *mixers) {
|
||||||
|
|
@ -4228,6 +4274,8 @@ static void mapping_paths_probe(pa_alsa_mapping *m, pa_alsa_profile *profile,
|
||||||
PA_HASHMAP_FOREACH(p, ps->paths, state)
|
PA_HASHMAP_FOREACH(p, ps->paths, state)
|
||||||
pa_hashmap_put(used_paths, p, p);
|
pa_hashmap_put(used_paths, p, p);
|
||||||
|
|
||||||
|
mapping_group_available(ps->paths);
|
||||||
|
|
||||||
pa_log_debug("Available mixer paths (after tidying):");
|
pa_log_debug("Available mixer paths (after tidying):");
|
||||||
pa_alsa_path_set_dump(ps);
|
pa_alsa_path_set_dump(ps);
|
||||||
}
|
}
|
||||||
|
|
@ -5026,6 +5074,7 @@ static pa_device_port* device_port_alsa_init(pa_hashmap *ports, /* card ports */
|
||||||
pa_device_port_new_data_set_name(&port_data, name);
|
pa_device_port_new_data_set_name(&port_data, name);
|
||||||
pa_device_port_new_data_set_description(&port_data, description);
|
pa_device_port_new_data_set_description(&port_data, description);
|
||||||
pa_device_port_new_data_set_direction(&port_data, path->direction == PA_ALSA_DIRECTION_OUTPUT ? PA_DIRECTION_OUTPUT : PA_DIRECTION_INPUT);
|
pa_device_port_new_data_set_direction(&port_data, path->direction == PA_ALSA_DIRECTION_OUTPUT ? PA_DIRECTION_OUTPUT : PA_DIRECTION_INPUT);
|
||||||
|
pa_device_port_new_data_set_available_group(&port_data, path->available_group);
|
||||||
|
|
||||||
p = pa_device_port_new(core, &port_data, sizeof(pa_alsa_port_data));
|
p = pa_device_port_new(core, &port_data, sizeof(pa_alsa_port_data));
|
||||||
pa_device_port_new_data_done(&port_data);
|
pa_device_port_new_data_done(&port_data);
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,7 @@ struct pa_alsa_path {
|
||||||
char *name;
|
char *name;
|
||||||
char *description_key;
|
char *description_key;
|
||||||
char *description;
|
char *description;
|
||||||
|
char *available_group;
|
||||||
unsigned priority;
|
unsigned priority;
|
||||||
bool autodetect_eld_device;
|
bool autodetect_eld_device;
|
||||||
pa_alsa_mixer *eld_mixer_handle;
|
pa_alsa_mixer *eld_mixer_handle;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue