Commit 57524159 authored by Marijn Suijten's avatar Marijn Suijten 🦀

bluetooth: Report a2dp_source volume changes to the source device

Write the current volume to the `Volume` DBus property to keep the
volume on the remote in sync. Without this the remote device shows the
wrong volume, and any attempts to change it will cause an unexpected
jump when the local volume has also been adjusted.
parent 6458e09b
......@@ -661,7 +661,7 @@ finish:
pa_dbus_pending_free(p);
}
static void bluez5_transport_set_sink_volume(pa_bluetooth_transport *t, uint16_t gain) {
static void bluez5_transport_set_volume(pa_bluetooth_transport *t, uint16_t gain) {
static const char *volume_str = "Volume";
static const char *mediatransport_str = BLUEZ_MEDIA_TRANSPORT_INTERFACE;
struct set_volume_and_transport *call_data;
......@@ -670,7 +670,7 @@ static void bluez5_transport_set_sink_volume(pa_bluetooth_transport *t, uint16_t
pa_assert(t);
pa_assert(t->device);
pa_assert(pa_bluetooth_profile_is_a2dp_sink(t->profile));
pa_assert(pa_bluetooth_profile_is_a2dp(t->profile));
pa_assert(t->device->discovery);
// TODO: Pali already converted this
......@@ -678,7 +678,9 @@ static void bluez5_transport_set_sink_volume(pa_bluetooth_transport *t, uint16_t
// /* Propagate rounding and bound checks */
// volume = a2dp_gain_to_volume(gain);
if (t->tx_volume_gain == gain)
if (pa_bluetooth_profile_is_a2dp_source(t->profile) && t->rx_volume_gain == gain)
return;
else if (pa_bluetooth_profile_is_a2dp_sink(t->profile) && t->tx_volume_gain == gain)
return;
pa_assert_se(m = dbus_message_new_method_call(BLUEZ_SERVICE, t->path, DBUS_INTERFACE_PROPERTIES, "Set"));
......@@ -695,6 +697,18 @@ static void bluez5_transport_set_sink_volume(pa_bluetooth_transport *t, uint16_t
send_and_add_to_pending(t->device->discovery, m, set_volume_reply, call_data);
}
static void bluez5_transport_set_sink_volume(pa_bluetooth_transport *t, uint16_t gain) {
pa_assert(t);
pa_assert(pa_bluetooth_profile_is_a2dp_sink(t->profile));
bluez5_transport_set_volume(t, gain);
}
static void bluez5_transport_set_source_volume(pa_bluetooth_transport *t, uint16_t gain) {
pa_assert(t);
pa_assert(pa_bluetooth_profile_is_a2dp_source(t->profile));
bluez5_transport_set_volume(t, gain);
}
bool pa_bluetooth_device_any_transport_connected(const pa_bluetooth_device *d) {
unsigned i, bluetooth_profile_count;
......@@ -2403,6 +2417,7 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
t->max_tx_volume_gain = A2DP_MAX_GAIN;
t->acquire = bluez5_transport_acquire_cb;
t->release = bluez5_transport_release_cb;
t->set_rx_volume_gain = bluez5_transport_set_source_volume;
t->set_tx_volume_gain = bluez5_transport_set_sink_volume;
pa_bluetooth_transport_put(t);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment