[pulseaudio-discuss] [PATCH v3 3/8] device-port: Add preferred_profile field to pa_device_port

David Henningsson david.henningsson at canonical.com
Tue Nov 17 06:10:31 PST 2015


Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
 src/pulsecore/device-port.c | 11 +++++++++++
 src/pulsecore/device-port.h |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/src/pulsecore/device-port.c b/src/pulsecore/device-port.c
index 906ab1f..5807d3e 100644
--- a/src/pulsecore/device-port.c
+++ b/src/pulsecore/device-port.c
@@ -21,6 +21,7 @@
 
 #include "device-port.h"
 #include <pulsecore/card.h>
+#include <pulsecore/core-util.h>
 
 PA_DEFINE_PUBLIC_CLASS(pa_device_port, pa_object);
 
@@ -65,6 +66,15 @@ void pa_device_port_new_data_done(pa_device_port_new_data *data) {
     pa_xfree(data->description);
 }
 
+void pa_device_port_set_preferred_profile(pa_device_port *p, const char *new_pp) {
+    pa_assert(p);
+
+    if (!pa_safe_streq(p->preferred_profile, new_pp)) {
+        pa_xfree(p->preferred_profile);
+        p->preferred_profile = pa_xstrdup(new_pp);
+    }
+}
+
 void pa_device_port_set_available(pa_device_port *p, pa_available_t status) {
     pa_assert(p);
 
@@ -100,6 +110,7 @@ static void device_port_free(pa_object *o) {
     if (p->profiles)
         pa_hashmap_free(p->profiles);
 
+    pa_xfree(p->preferred_profile);
     pa_xfree(p->name);
     pa_xfree(p->description);
     pa_xfree(p);
diff --git a/src/pulsecore/device-port.h b/src/pulsecore/device-port.h
index f35d07c..e3224fd 100644
--- a/src/pulsecore/device-port.h
+++ b/src/pulsecore/device-port.h
@@ -43,6 +43,7 @@ struct pa_device_port {
 
     char *name;
     char *description;
+    char *preferred_profile;
 
     unsigned priority;
     pa_available_t available;         /* PA_AVAILABLE_UNKNOWN, PA_AVAILABLE_NO or PA_AVAILABLE_YES */
@@ -80,6 +81,7 @@ pa_device_port *pa_device_port_new(pa_core *c, pa_device_port_new_data *data, si
 void pa_device_port_set_available(pa_device_port *p, pa_available_t available);
 
 void pa_device_port_set_latency_offset(pa_device_port *p, int64_t offset);
+void pa_device_port_set_preferred_profile(pa_device_port *p, const char *new_pp);
 
 pa_device_port *pa_device_port_find_best(pa_hashmap *ports);
 
-- 
1.9.1



More information about the pulseaudio-discuss mailing list