mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
prefer profiles that match the default channel map
This commit is contained in:
parent
14ee8d471a
commit
1a45569b3e
1 changed files with 26 additions and 5 deletions
|
|
@ -88,6 +88,8 @@ struct userdata {
|
||||||
pa_source *source;
|
pa_source *source;
|
||||||
|
|
||||||
pa_modargs *modargs;
|
pa_modargs *modargs;
|
||||||
|
|
||||||
|
pa_hashmap *profiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct profile_data {
|
struct profile_data {
|
||||||
|
|
@ -99,10 +101,11 @@ static void enumerate_cb(
|
||||||
const pa_alsa_profile_info *source,
|
const pa_alsa_profile_info *source,
|
||||||
void *userdata) {
|
void *userdata) {
|
||||||
|
|
||||||
pa_hashmap *profiles = (pa_hashmap *) userdata;
|
struct userdata *u = userdata;
|
||||||
char *t, *n;
|
char *t, *n;
|
||||||
pa_card_profile *p;
|
pa_card_profile *p;
|
||||||
struct profile_data *d;
|
struct profile_data *d;
|
||||||
|
unsigned bonus = 0;
|
||||||
|
|
||||||
if (sink && source) {
|
if (sink && source) {
|
||||||
n = pa_sprintf_malloc("output-%s+input-%s", sink->name, source->name);
|
n = pa_sprintf_malloc("output-%s+input-%s", sink->name, source->name);
|
||||||
|
|
@ -116,6 +119,20 @@ static void enumerate_cb(
|
||||||
t = pa_sprintf_malloc(_("Input %s"), _(source->description));
|
t = pa_sprintf_malloc(_("Input %s"), _(source->description));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sink) {
|
||||||
|
if (pa_channel_map_equal(&sink->map, &u->core->default_channel_map))
|
||||||
|
bonus += 50000;
|
||||||
|
else if (sink->map.channels == u->core->default_channel_map.channels)
|
||||||
|
bonus += 40000;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source) {
|
||||||
|
if (pa_channel_map_equal(&source->map, &u->core->default_channel_map))
|
||||||
|
bonus += 30000;
|
||||||
|
else if (source->map.channels == u->core->default_channel_map.channels)
|
||||||
|
bonus += 20000;
|
||||||
|
}
|
||||||
|
|
||||||
pa_log_info("Found output profile '%s'", t);
|
pa_log_info("Found output profile '%s'", t);
|
||||||
|
|
||||||
p = pa_card_profile_new(n, t, sizeof(struct profile_data));
|
p = pa_card_profile_new(n, t, sizeof(struct profile_data));
|
||||||
|
|
@ -123,7 +140,11 @@ 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->priority =
|
||||||
|
(sink ? sink->priority : 0) * 100 +
|
||||||
|
(source ? source->priority : 0) +
|
||||||
|
bonus;
|
||||||
|
|
||||||
p->n_sinks = !!sink;
|
p->n_sinks = !!sink;
|
||||||
p->n_sources = !!source;
|
p->n_sources = !!source;
|
||||||
|
|
||||||
|
|
@ -137,7 +158,7 @@ static void enumerate_cb(
|
||||||
d->sink_profile = sink;
|
d->sink_profile = sink;
|
||||||
d->source_profile = source;
|
d->source_profile = source;
|
||||||
|
|
||||||
pa_hashmap_put(profiles, p->name, p);
|
pa_hashmap_put(u->profiles, p->name, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_disabled_profile(pa_hashmap *profiles) {
|
static void add_disabled_profile(pa_hashmap *profiles) {
|
||||||
|
|
@ -289,8 +310,8 @@ int pa__init(pa_module*m) {
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_id);
|
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_id);
|
||||||
set_card_name(&data, ma, u->device_id);
|
set_card_name(&data, ma, u->device_id);
|
||||||
|
|
||||||
data.profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
u->profiles = data.profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||||
if (pa_alsa_probe_profiles(u->device_id, &m->core->default_sample_spec, enumerate_cb, data.profiles) < 0) {
|
if (pa_alsa_probe_profiles(u->device_id, &m->core->default_sample_spec, enumerate_cb, u) < 0) {
|
||||||
pa_card_new_data_done(&data);
|
pa_card_new_data_done(&data);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue