bluetooth: Abstract speaker gain in transport

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.
This commit is contained in:
Mikel Astiz 2012-12-14 15:14:29 +01:00 committed by Tanu Kaskinen
parent ce24ef460a
commit 0b524c1078
2 changed files with 28 additions and 0 deletions

View file

@ -549,6 +549,21 @@ static int parse_audio_property(pa_bluetooth_device *d, const char *interface, D
transport->microphone_gain = gain;
pa_hook_fire(&d->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED], transport);
} else if (pa_streq(key, "SpeakerGain")) {
uint16_t gain;
pa_log_debug("dbus: property '%s' changed to value '%u'", key, value);
if (!transport) {
pa_log("Volume change does not have an associated transport");
return -1;
}
if ((gain = PA_MIN(value, HSP_MAX_GAIN)) == transport->speaker_gain)
break;
transport->speaker_gain = gain;
pa_hook_fire(&d->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED], transport);
}
break;
@ -1141,6 +1156,16 @@ void pa_bluetooth_transport_set_microphone_gain(pa_bluetooth_transport *t, uint1
"MicrophoneGain", DBUS_TYPE_UINT16, &gain);
}
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_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);
}
static int setup_dbus(pa_bluetooth_discovery *y) {
DBusError err;