[pulseaudio-discuss] [RFC next v0 10/11] bluetooth: Add speaker gain callback to backend

Mikel Astiz mikel.astiz.oss at gmail.com
Wed May 15 01:46:55 PDT 2013


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

---
 src/modules/bluetooth/bluetooth-util.c | 20 +++++++++++++++++---
 src/modules/bluetooth/bluetooth-util.h |  2 ++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 19072d0..92094bf 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1641,13 +1641,15 @@ void pa_bluetooth_transport_set_microphone_gain(pa_bluetooth_transport *t, uint1
 }
 
 void pa_bluetooth_transport_set_speaker_gain(pa_bluetooth_transport *t, uint16_t value) {
-    dbus_uint16_t gain = PA_MIN(value, HSP_MAX_GAIN);
+    pa_bluetooth_discovery *y;
+    pa_bluetooth_backend *backend;
 
     pa_assert(t);
     pa_assert(t->profile == PROFILE_HSP);
+    pa_assert_se(y = t->device->discovery);
+    pa_assert_se(backend = y->profiles[t->profile].backend);
 
-    set_property(t->device->discovery, "org.bluez", t->device->path, "org.bluez.Headset",
-                 "SpeakerGain", DBUS_TYPE_UINT16, &gain);
+    backend->set_speaker_gain(y->profiles[t->profile].backend_private, t, PA_MIN(value, HSP_MAX_GAIN));
 }
 
 static int setup_dbus(pa_bluetooth_discovery *y) {
@@ -2070,11 +2072,23 @@ static void bluez_backend_set_microphone_gain(void *bp, pa_bluetooth_transport *
                  "MicrophoneGain", DBUS_TYPE_UINT16, &gain);
 }
 
+static void bluez_backend_set_speaker_gain(void *bp, pa_bluetooth_transport *t, uint16_t value)
+{
+    dbus_uint16_t gain = value;
+
+    pa_assert(t);
+    pa_assert(t->profile == PROFILE_HSP);
+
+    set_property(t->device->discovery, "org.bluez", t->device->path, "org.bluez.Headset",
+                 "SpeakerGain", DBUS_TYPE_UINT16, &gain);
+}
+
 pa_bluetooth_backend bluez_backend = {
     .transport_removed = bluez_backend_transport_removed,
     .transport_acquire = bluez_backend_transport_acquire,
     .transport_release = bluez_backend_transport_release,
     .set_microphone_gain = bluez_backend_set_microphone_gain,
+    .set_speaker_gain = bluez_backend_set_speaker_gain,
 };
 
 static void bluez_backend_init(pa_bluetooth_discovery *y) {
diff --git a/src/modules/bluetooth/bluetooth-util.h b/src/modules/bluetooth/bluetooth-util.h
index 28ab209..1e26274 100644
--- a/src/modules/bluetooth/bluetooth-util.h
+++ b/src/modules/bluetooth/bluetooth-util.h
@@ -186,12 +186,14 @@ typedef int (*pa_bt_backend_transport_acquire_cb)(void *bp, pa_bluetooth_transpo
                                                   size_t *omtu);
 typedef void (*pa_bt_backend_transport_release_cb)(void *bp, pa_bluetooth_transport *t);
 typedef void (*pa_bt_backend_set_microphone_gain_cb)(void *bp, pa_bluetooth_transport *t, uint16_t value);
+typedef void (*pa_bt_backend_set_speaker_gain_cb)(void *bp, pa_bluetooth_transport *t, uint16_t value);
 
 struct pa_bluetooth_backend {
     pa_bt_backend_transport_removed_cb transport_removed;
     pa_bt_backend_transport_acquire_cb transport_acquire;
     pa_bt_backend_transport_release_cb transport_release;
     pa_bt_backend_set_microphone_gain_cb set_microphone_gain;
+    pa_bt_backend_set_speaker_gain_cb set_speaker_gain;
 };
 
 int pa_bt_backend_register(pa_bluetooth_discovery *y, pa_bluetooth_backend *b, enum profile p, void *bp);
-- 
1.8.1.4



More information about the pulseaudio-discuss mailing list