[pulseaudio-discuss] [PATCH next v0 02/10] bluetooth: Abstract speaker gain in transport
Mikel Astiz
mikel.astiz.oss at gmail.com
Wed Dec 12 04:17:02 PST 2012
From: Mikel Astiz <mikel.astiz at bmw-carit.de>
Similarly to the microphone gain, the speaker gain can be abstracted
inside the transport object, even though the actual D-Bus interface in
BlueZ differs.
---
src/modules/bluetooth/bluetooth-util.c | 18 ++++++++++++++++++
src/modules/bluetooth/bluetooth-util.h | 3 +++
2 files changed, 21 insertions(+)
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index a319db3..c1ea953 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -545,6 +545,17 @@ static int parse_audio_property(pa_bluetooth_device *d, const char *interface, D
transport->microphone_gain = PA_MIN(value, HSP_MAX_GAIN);
pa_hook_fire(&d->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED], transport);
+ } else if (pa_streq(key, "SpeakerGain")) {
+ pa_log_debug("dbus: property 'State' changed to value '%u'", value);
+
+ if (!transport) {
+ pa_log("Volume change does not have an associated transport");
+ return -1;
+ }
+
+ transport->speaker_gain = PA_MIN(value, HSP_MAX_GAIN);
+
+ pa_hook_fire(&d->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED], transport);
}
break;
@@ -1146,6 +1157,13 @@ void pa_bluetooth_transport_set_microphone_gain(pa_bluetooth_transport *t, uint1
pa_bt_set_property(t->device->discovery, t->device->path, "org.bluez.Headset", "MicrophoneGain", DBUS_TYPE_UINT16, &value);
}
+void pa_bluetooth_transport_set_speaker_gain(pa_bluetooth_transport *t, uint16_t value) {
+ pa_assert(t);
+ pa_assert(t->profile == PROFILE_HSP);
+
+ pa_bt_set_property(t->device->discovery, t->device->path, "org.bluez.Headset", "SpeakerGain", DBUS_TYPE_UINT16, &value);
+}
+
static int setup_dbus(pa_bluetooth_discovery *y) {
DBusError err;
diff --git a/src/modules/bluetooth/bluetooth-util.h b/src/modules/bluetooth/bluetooth-util.h
index 4c909ab..e471e0d 100644
--- a/src/modules/bluetooth/bluetooth-util.h
+++ b/src/modules/bluetooth/bluetooth-util.h
@@ -79,6 +79,7 @@ typedef enum pa_bluetooth_hook {
PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED, /* Call data: pa_bluetooth_transport */
PA_BLUETOOTH_HOOK_TRANSPORT_NREC_CHANGED, /* Call data: pa_bluetooth_transport */
PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED, /* Call data: pa_bluetooth_transport */
+ PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED, /* Call data: pa_bluetooth_transport */
PA_BLUETOOTH_HOOK_MAX
} pa_bluetooth_hook_t;
@@ -100,6 +101,7 @@ struct pa_bluetooth_transport {
pa_bluetooth_transport_state_t state;
pa_bool_t nrec;
uint16_t microphone_gain; /* Used for HSP/HFP */
+ uint16_t speaker_gain; /* Used for HSP/HFP */
};
/* This enum is shared among Audio, Headset, AudioSink, and AudioSource, although not all values are acceptable in all profiles */
@@ -150,6 +152,7 @@ int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, const char *access
void pa_bluetooth_transport_release(pa_bluetooth_transport *t, const char *accesstype);
void pa_bluetooth_transport_set_microphone_gain(pa_bluetooth_transport *t, uint16_t value);
+void pa_bluetooth_transport_set_speaker_gain(pa_bluetooth_transport *t, uint16_t value);
pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook);
--
1.7.11.7
More information about the pulseaudio-discuss
mailing list