mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
add priority logic to find best default profile
This commit is contained in:
parent
b3a043fd31
commit
7368a6e6be
6 changed files with 43 additions and 15 deletions
|
|
@ -495,62 +495,72 @@ static const struct pa_alsa_profile_info device_table[] = {
|
||||||
{{ 1, { PA_CHANNEL_POSITION_MONO }},
|
{{ 1, { PA_CHANNEL_POSITION_MONO }},
|
||||||
"hw",
|
"hw",
|
||||||
"Analog Mono",
|
"Analog Mono",
|
||||||
"analog-mono" },
|
"analog-mono",
|
||||||
|
1 },
|
||||||
|
|
||||||
{{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
|
{{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
|
||||||
"front",
|
"front",
|
||||||
"Analog Stereo",
|
"Analog Stereo",
|
||||||
"analog-stereo" },
|
"analog-stereo",
|
||||||
|
10 },
|
||||||
|
|
||||||
{{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
|
{{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
|
||||||
"iec958",
|
"iec958",
|
||||||
"IEC958 Digital Stereo",
|
"IEC958 Digital Stereo",
|
||||||
"iec958-stereo" },
|
"iec958-stereo",
|
||||||
|
5 },
|
||||||
|
|
||||||
{{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
|
{{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
|
||||||
"hdmi",
|
"hdmi",
|
||||||
"HDMI Digital Stereo",
|
"HDMI Digital Stereo",
|
||||||
"hdmi-stereo"},
|
"hdmi-stereo",
|
||||||
|
4 },
|
||||||
|
|
||||||
{{ 4, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
{{ 4, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||||
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }},
|
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }},
|
||||||
"surround40",
|
"surround40",
|
||||||
"Analog Surround 4.0",
|
"Analog Surround 4.0",
|
||||||
"analog-surround-40" },
|
"analog-surround-40",
|
||||||
|
7 },
|
||||||
|
|
||||||
{{ 4, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
{{ 4, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||||
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }},
|
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }},
|
||||||
"a52",
|
"a52",
|
||||||
"IEC958/AC3 Digital Surround 4.0",
|
"IEC958/AC3 Digital Surround 4.0",
|
||||||
"iec958-ac3-surround-40" },
|
"iec958-ac3-surround-40",
|
||||||
|
2 },
|
||||||
|
|
||||||
{{ 5, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
{{ 5, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||||
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
|
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
|
||||||
PA_CHANNEL_POSITION_LFE }},
|
PA_CHANNEL_POSITION_LFE }},
|
||||||
"surround41",
|
"surround41",
|
||||||
"Analog Surround 4.1",
|
"Analog Surround 4.1",
|
||||||
"analog-surround-41"},
|
"analog-surround-41",
|
||||||
|
7 },
|
||||||
|
|
||||||
{{ 5, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
{{ 5, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||||
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
|
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
|
||||||
PA_CHANNEL_POSITION_CENTER }},
|
PA_CHANNEL_POSITION_CENTER }},
|
||||||
"surround50",
|
"surround50",
|
||||||
"Analog Surround 5.0",
|
"Analog Surround 5.0",
|
||||||
"analog-surround-50" },
|
"analog-surround-50",
|
||||||
|
7 },
|
||||||
|
|
||||||
{{ 6, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
{{ 6, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||||
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
|
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
|
||||||
PA_CHANNEL_POSITION_CENTER, PA_CHANNEL_POSITION_LFE }},
|
PA_CHANNEL_POSITION_CENTER, PA_CHANNEL_POSITION_LFE }},
|
||||||
"surround51",
|
"surround51",
|
||||||
"Analog Surround 5.1",
|
"Analog Surround 5.1",
|
||||||
"analog-surround-51" },
|
"analog-surround-51",
|
||||||
|
8 },
|
||||||
|
|
||||||
{{ 6, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_CENTER,
|
{{ 6, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_CENTER,
|
||||||
PA_CHANNEL_POSITION_FRONT_RIGHT, PA_CHANNEL_POSITION_REAR_LEFT,
|
PA_CHANNEL_POSITION_FRONT_RIGHT, PA_CHANNEL_POSITION_REAR_LEFT,
|
||||||
PA_CHANNEL_POSITION_REAR_RIGHT, PA_CHANNEL_POSITION_LFE}},
|
PA_CHANNEL_POSITION_REAR_RIGHT, PA_CHANNEL_POSITION_LFE}},
|
||||||
"a52",
|
"a52",
|
||||||
"IEC958/AC3 Digital Surround 5.1",
|
"IEC958/AC3 Digital Surround 5.1",
|
||||||
"iec958-ac3-surround-51" },
|
"iec958-ac3-surround-51",
|
||||||
|
3 },
|
||||||
|
|
||||||
{{ 8, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
{{ 8, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||||
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
|
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
|
||||||
|
|
@ -558,9 +568,10 @@ static const struct pa_alsa_profile_info device_table[] = {
|
||||||
PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT }},
|
PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT }},
|
||||||
"surround71",
|
"surround71",
|
||||||
"Analog Surround 7.1",
|
"Analog Surround 7.1",
|
||||||
"analog-surround-71" },
|
"analog-surround-71",
|
||||||
|
7 },
|
||||||
|
|
||||||
{{ 0, { 0 }}, NULL, NULL, NULL }
|
{{ 0, { 0 }}, NULL, NULL, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static pa_bool_t channel_map_superset(const pa_channel_map *a, const pa_channel_map *b) {
|
static pa_bool_t channel_map_superset(const pa_channel_map *a, const pa_channel_map *b) {
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ typedef struct pa_alsa_profile_info {
|
||||||
const char *alsa_name;
|
const char *alsa_name;
|
||||||
const char *description;
|
const char *description;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
unsigned priority;
|
||||||
} pa_alsa_profile_info;
|
} pa_alsa_profile_info;
|
||||||
|
|
||||||
int pa_alsa_probe_profiles(
|
int pa_alsa_probe_profiles(
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ static void enumerate_cb(
|
||||||
pa_xfree(t);
|
pa_xfree(t);
|
||||||
pa_xfree(n);
|
pa_xfree(n);
|
||||||
|
|
||||||
|
p->priority = (sink ? sink->priority : 0)*100 + (source ? source->priority : 0);
|
||||||
p->n_sinks = !!sink;
|
p->n_sinks = !!sink;
|
||||||
p->n_sources = !!source;
|
p->n_sources = !!source;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ pa_card_profile *pa_card_profile_new(const char *name, const char *description,
|
||||||
c->name = pa_xstrdup(name);
|
c->name = pa_xstrdup(name);
|
||||||
c->description = pa_xstrdup(description);
|
c->description = pa_xstrdup(description);
|
||||||
|
|
||||||
|
c->priority = 0;
|
||||||
|
c->n_sinks = c->n_sources = 0;
|
||||||
|
c->max_sink_channels = c->max_source_channels = 0;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,8 +129,17 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
|
||||||
c->profiles = data->profiles;
|
c->profiles = data->profiles;
|
||||||
data->profiles = NULL;
|
data->profiles = NULL;
|
||||||
if (!(c->active_profile = data->active_profile))
|
if (!(c->active_profile = data->active_profile))
|
||||||
if (c->profiles)
|
if (c->profiles) {
|
||||||
c->active_profile = pa_hashmap_first(c->profiles);
|
void *state = NULL;
|
||||||
|
pa_card_profile *p;
|
||||||
|
|
||||||
|
while ((p = pa_hashmap_iterate(c->profiles, &state, NULL))) {
|
||||||
|
if (!c->active_profile ||
|
||||||
|
p->priority > c->active_profile->priority)
|
||||||
|
|
||||||
|
c->active_profile = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
data->active_profile = NULL;
|
data->active_profile = NULL;
|
||||||
|
|
||||||
c->userdata = NULL;
|
c->userdata = NULL;
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ typedef struct pa_card_profile {
|
||||||
char *name;
|
char *name;
|
||||||
char *description;
|
char *description;
|
||||||
|
|
||||||
|
unsigned priority;
|
||||||
|
|
||||||
/* We probably want to have different properties later on here */
|
/* We probably want to have different properties later on here */
|
||||||
unsigned n_sinks;
|
unsigned n_sinks;
|
||||||
unsigned n_sources;
|
unsigned n_sources;
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ char *pa_card_list_to_string(pa_core *c) {
|
||||||
"\tprofiles:\n");
|
"\tprofiles:\n");
|
||||||
|
|
||||||
while ((p = pa_hashmap_iterate(card->profiles, &state, NULL)))
|
while ((p = pa_hashmap_iterate(card->profiles, &state, NULL)))
|
||||||
pa_strbuf_printf(s, "\t\t%s: %s\n", p->name, p->description);
|
pa_strbuf_printf(s, "\t\t%s: %s (priority %u)\n", p->name, p->description, p->priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card->active_profile)
|
if (card->active_profile)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue