[pulseaudio-discuss] [PATCH v0 01/11] card: Support adding profiles dynamically

Mikel Astiz mikel.astiz.oss at gmail.com
Mon Oct 22 01:46:33 PDT 2012


From: Mikel Astiz <mikel.astiz at bmw-carit.de>

Some cards might need to add profiles during their lifetime, that is,
after the card has been created.
---
 src/pulsecore/card.c | 15 +++++++++++++++
 src/pulsecore/card.h |  2 ++
 2 files changed, 17 insertions(+)

diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
index 492c051..79fe41c 100644
--- a/src/pulsecore/card.c
+++ b/src/pulsecore/card.c
@@ -79,6 +79,21 @@ void pa_card_new_data_set_name(pa_card_new_data *data, const char *name) {
     data->name = pa_xstrdup(name);
 }
 
+int pa_card_add_profile(pa_card *c, struct pa_card_profile *profile) {
+    pa_assert(c);
+    pa_assert(profile);
+
+    if (pa_hashmap_get(c->profiles, profile->name)) {
+        pa_log_error("Card %s already has profile %s", c->name, profile->name);
+        return -1;
+    }
+
+    /* take ownership of the profile */
+    pa_hashmap_put(c->profiles, profile->name, profile);
+
+    return 0;
+}
+
 void pa_card_new_data_set_profile(pa_card_new_data *data, const char *profile) {
     pa_assert(data);
 
diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
index 6f942e8..d181b10 100644
--- a/src/pulsecore/card.h
+++ b/src/pulsecore/card.h
@@ -100,6 +100,8 @@ void pa_card_new_data_done(pa_card_new_data *data);
 pa_card *pa_card_new(pa_core *c, pa_card_new_data *data);
 void pa_card_free(pa_card *c);
 
+int pa_card_add_profile(pa_card *c, struct pa_card_profile *profile);
+
 int pa_card_set_profile(pa_card *c, const char *name, pa_bool_t save);
 
 int pa_card_suspend(pa_card *c, pa_bool_t suspend, pa_suspend_cause_t cause);
-- 
1.7.11.7



More information about the pulseaudio-discuss mailing list