[RFC next v0 09/11] bluetooth: Add microphone gain callback to backend

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

 



From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx>

---
 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 d89c7a7..19072d0 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1629,13 +1629,15 @@ static void set_property(pa_bluetooth_discovery *y, const char *bus, const char
 }
 
 void pa_bluetooth_transport_set_microphone_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",
-                 "MicrophoneGain", DBUS_TYPE_UINT16, &gain);
+    backend->set_microphone_gain(y->profiles[t->profile].backend_private, t, PA_MIN(value, HSP_MAX_GAIN));
 }
 
 void pa_bluetooth_transport_set_speaker_gain(pa_bluetooth_transport *t, uint16_t value) {
@@ -2057,10 +2059,22 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
     return DBUS_HANDLER_RESULT_HANDLED;
 }
 
+static void bluez_backend_set_microphone_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",
+                 "MicrophoneGain", 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,
 };
 
 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 3495a1b..28ab209 100644
--- a/src/modules/bluetooth/bluetooth-util.h
+++ b/src/modules/bluetooth/bluetooth-util.h
@@ -185,11 +185,13 @@ typedef void (*pa_bt_backend_transport_removed_cb)(void *bp, pa_bluetooth_transp
 typedef int (*pa_bt_backend_transport_acquire_cb)(void *bp, pa_bluetooth_transport *t, bool optional, size_t *imtu,
                                                   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);
 
 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;
 };
 
 int pa_bt_backend_register(pa_bluetooth_discovery *y, pa_bluetooth_backend *b, enum profile p, void *bp);
-- 
1.8.1.4



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

  Powered by Linux