summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-01-21 02:46:36 +0100
committerLennart Poettering <lennart@poettering.net>2009-01-21 02:46:36 +0100
commit9661cd04442e88fa500654a4b7ccea68ede2e123 (patch)
tree4858b4548cb02a7f223797b0d3bb2d58a04fa661 /src
parente8f93b125e0e0776024ae78a2bdd33daf4442326 (diff)
make pa_card_new_data::active_profile a string
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/card.c34
-rw-r--r--src/pulsecore/card.h3
2 files changed, 26 insertions, 11 deletions
diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
index af2a178b..397c6d7a 100644
--- a/src/pulsecore/card.c
+++ b/src/pulsecore/card.c
@@ -76,6 +76,13 @@ void pa_card_new_data_set_name(pa_card_new_data *data, const char *name) {
data->name = pa_xstrdup(name);
}
+void pa_card_new_data_set_profile(pa_card_new_data *data, const char *profile) {
+ pa_assert(data);
+
+ pa_xfree(data->active_profile);
+ data->active_profile = pa_xstrdup(profile);
+}
+
void pa_card_new_data_done(pa_card_new_data *data) {
pa_assert(data);
@@ -92,6 +99,7 @@ void pa_card_new_data_done(pa_card_new_data *data) {
}
pa_xfree(data->name);
+ pa_xfree(data->active_profile);
}
pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
@@ -126,21 +134,27 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
c->sinks = pa_idxset_new(NULL, NULL);
c->sources = pa_idxset_new(NULL, NULL);
+ /* As a minor optimization we just steal the list instead of
+ * copying it here */
c->profiles = data->profiles;
data->profiles = NULL;
- if (!(c->active_profile = data->active_profile))
- 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 = NULL;
- c->active_profile = p;
- }
+ if (data->active_profile && c->profiles)
+ c->active_profile = pa_hashmap_get(c->profiles, data->active_profile);
+
+ if (!c->active_profile && 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;
c->set_profile = NULL;
diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
index 17733c51..9aa8f374 100644
--- a/src/pulsecore/card.h
+++ b/src/pulsecore/card.h
@@ -77,7 +77,7 @@ typedef struct pa_card_new_data {
pa_module *module;
pa_hashmap *profiles;
- pa_card_profile *active_profile;
+ char *active_profile;
pa_bool_t namereg_fail:1;
} pa_card_new_data;
@@ -87,6 +87,7 @@ void pa_card_profile_free(pa_card_profile *c);
pa_card_new_data *pa_card_new_data_init(pa_card_new_data *data);
void pa_card_new_data_set_name(pa_card_new_data *data, const char *name);
+void pa_card_new_data_set_profile(pa_card_new_data *data, const char *profile);
void pa_card_new_data_done(pa_card_new_data *data);
pa_card *pa_card_new(pa_core *c, pa_card_new_data *data);