summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-01-20 20:35:18 +0100
committerLennart Poettering <lennart@poettering.net>2009-01-20 20:35:18 +0100
commit7368a6e6be5dbbdc8e13003ef6841fe3fe1840bc (patch)
tree0c1fbef18992fcdb5d782f4988d54e25e8e00b10 /src/pulsecore
parentb3a043fd3179fcb60730466ae43f16ffe14a9b4c (diff)
add priority logic to find best default profile
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/card.c17
-rw-r--r--src/pulsecore/card.h2
-rw-r--r--src/pulsecore/cli-text.c2
3 files changed, 18 insertions, 3 deletions
diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
index 8e29f0a5..cb775534 100644
--- a/src/pulsecore/card.c
+++ b/src/pulsecore/card.c
@@ -45,6 +45,10 @@ pa_card_profile *pa_card_profile_new(const char *name, const char *description,
c->name = pa_xstrdup(name);
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;
}
@@ -125,8 +129,17 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
c->profiles = data->profiles;
data->profiles = NULL;
if (!(c->active_profile = data->active_profile))
- if (c->profiles)
- c->active_profile = pa_hashmap_first(c->profiles);
+ if (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;
c->userdata = NULL;
diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
index b4e68b04..17733c51 100644
--- a/src/pulsecore/card.h
+++ b/src/pulsecore/card.h
@@ -33,6 +33,8 @@ typedef struct pa_card_profile {
char *name;
char *description;
+ unsigned priority;
+
/* We probably want to have different properties later on here */
unsigned n_sinks;
unsigned n_sources;
diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c
index f52968d7..947598b5 100644
--- a/src/pulsecore/cli-text.c
+++ b/src/pulsecore/cli-text.c
@@ -142,7 +142,7 @@ char *pa_card_list_to_string(pa_core *c) {
"\tprofiles:\n");
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)