mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
core: initialize sink/source priorities automatically based on their proplists
This commit is contained in:
parent
18b13a89a5
commit
8bf2e3fe94
3 changed files with 50 additions and 0 deletions
|
|
@ -244,6 +244,8 @@ pa_sink* pa_sink_new(
|
|||
s->module = data->module;
|
||||
s->card = data->card;
|
||||
|
||||
s->priority = pa_device_init_priority(s->proplist);
|
||||
|
||||
s->sample_spec = data->sample_spec;
|
||||
s->channel_map = data->channel_map;
|
||||
|
||||
|
|
@ -2696,3 +2698,48 @@ pa_bool_t pa_device_init_intended_roles(pa_proplist *p) {
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
unsigned pa_device_init_priority(pa_proplist *p) {
|
||||
const char *s;
|
||||
unsigned priority = 0;
|
||||
|
||||
pa_assert(p);
|
||||
|
||||
if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_CLASS))) {
|
||||
|
||||
if (pa_streq(s, "sound"))
|
||||
priority += 9000;
|
||||
else if (!pa_streq(s, "modem"))
|
||||
priority += 1000;
|
||||
}
|
||||
|
||||
if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_FORM_FACTOR))) {
|
||||
|
||||
if (pa_streq(s, "internal"))
|
||||
priority += 900;
|
||||
else if (pa_streq(s, "speaker"))
|
||||
priority += 500;
|
||||
else if (pa_streq(s, "headphone"))
|
||||
priority += 400;
|
||||
}
|
||||
|
||||
if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_BUS))) {
|
||||
|
||||
if (pa_streq(s, "pci"))
|
||||
priority += 50;
|
||||
else if (pa_streq(s, "usb"))
|
||||
priority += 40;
|
||||
else if (pa_streq(s, "bluetooth"))
|
||||
priority += 30;
|
||||
}
|
||||
|
||||
if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_PROFILE_NAME))) {
|
||||
|
||||
if (pa_startswith(s, "analog-"))
|
||||
priority += 9;
|
||||
else if (pa_startswith(s, "iec958-"))
|
||||
priority += 8;
|
||||
}
|
||||
|
||||
return priority;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,6 +290,7 @@ void pa_sink_update_flags(pa_sink *s, pa_sink_flags_t mask, pa_sink_flags_t valu
|
|||
pa_bool_t pa_device_init_description(pa_proplist *p);
|
||||
pa_bool_t pa_device_init_icon(pa_proplist *p, pa_bool_t is_sink);
|
||||
pa_bool_t pa_device_init_intended_roles(pa_proplist *p);
|
||||
unsigned pa_device_init_priority(pa_proplist *p);
|
||||
|
||||
/**** May be called by everyone, from main context */
|
||||
|
||||
|
|
|
|||
|
|
@ -213,6 +213,8 @@ pa_source* pa_source_new(
|
|||
s->module = data->module;
|
||||
s->card = data->card;
|
||||
|
||||
s->priority = pa_device_init_priority(s->proplist);
|
||||
|
||||
s->sample_spec = data->sample_spec;
|
||||
s->channel_map = data->channel_map;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue