[PATCH v1 1/4] device-port: Add volume to the ports struct.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds a volume to the ports.
Now we can save and restore the volume per port.

This adds a new hook:
    PA_CORE_HOOK_PORT_VOLUME_CHANGED

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=55262
---
 src/pulsecore/core.h        |  1 +
 src/pulsecore/device-port.c | 15 +++++++++++++++
 src/pulsecore/device-port.h |  3 +++
 3 files changed, 19 insertions(+)

diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index 381897a..078c237 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -118,6 +118,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_PORT_AVAILABLE_CHANGED,
     PA_CORE_HOOK_PORT_ADDED,
     PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED,
+    PA_CORE_HOOK_PORT_VOLUME_CHANGED,
     PA_CORE_HOOK_MAX
 } pa_core_hook_t;
 
diff --git a/src/pulsecore/device-port.c b/src/pulsecore/device-port.c
index f16de3a..608effa 100644
--- a/src/pulsecore/device-port.c
+++ b/src/pulsecore/device-port.c
@@ -84,6 +84,7 @@ pa_device_port *pa_device_port_new(pa_core *c, const char *name, const char *des
     p->is_input = FALSE;
     p->is_output = FALSE;
     p->latency_offset = 0;
+    pa_cvolume_init(&p->volume);
     p->proplist = pa_proplist_new();
 
     return p;
@@ -123,3 +124,17 @@ void pa_device_port_set_latency_offset(pa_device_port *p, int64_t offset) {
     pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, p->card->index);
     pa_hook_fire(&core->hooks[PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED], p);
 }
+
+void pa_device_port_set_volume(pa_device_port *p, pa_cvolume volume) {
+    pa_core *core;
+
+    pa_assert(p);
+
+    if (pa_cvolume_equal(&p->volume, &volume))
+        return;
+
+    p->volume = volume;
+
+    pa_assert_se(core = p->core);
+    pa_hook_fire(&core->hooks[PA_CORE_HOOK_PORT_VOLUME_CHANGED], p);
+}
diff --git a/src/pulsecore/device-port.h b/src/pulsecore/device-port.h
index c0c00cf..9796707 100644
--- a/src/pulsecore/device-port.h
+++ b/src/pulsecore/device-port.h
@@ -33,6 +33,7 @@ typedef struct pa_device_port pa_device_port;
 #include <inttypes.h>
 
 #include <pulse/def.h>
+#include <pulse/volume.h>
 #include <pulsecore/object.h>
 #include <pulsecore/hashmap.h>
 #include <pulsecore/core.h>
@@ -54,6 +55,7 @@ struct pa_device_port {
     pa_bool_t is_input:1;
     pa_bool_t is_output:1;
     int64_t latency_offset;
+    pa_cvolume volume;
 
     /* .. followed by some implementation specific data */
 };
@@ -70,4 +72,5 @@ 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_volume(pa_device_port *p, pa_cvolume volume);
 #endif
-- 
1.8.2



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux