summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/sink.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-08-29 04:31:33 +0200
committerLennart Poettering <lennart@poettering.net>2009-08-29 04:31:33 +0200
commit8bf2e3fe94e0dcd0a39a67c461b787d79adcd0dd (patch)
treeac6744c2b24713b5a1c51ebfac1e963ec15d6bd3 /src/pulsecore/sink.c
parent18b13a89a516dbc33acbddbd9600c05cb9cb0246 (diff)
core: initialize sink/source priorities automatically based on their proplists
Diffstat (limited to 'src/pulsecore/sink.c')
-rw-r--r--src/pulsecore/sink.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 49a5167e..48c50b0b 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -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;
+}