Commit 8b5134ad authored by Marijn Suijten's avatar Marijn Suijten 🦀

FIXUP: Ignore .Set result for Volume property

The only reason to asynchronously handle a response to this call is to
catch an error. A change notification for the Volume property is
received anyway, allowing us to determine what the actual applied volume
is.

In fact, that notification is received _before_ set_volume_reply is
handled: if bluez and/or the headphones report a change to a different
volume this will not be caught as the _reply handler overwrites it,
leading to more desyncs.
parent eab18870
......@@ -616,55 +616,9 @@ static void bluez5_transport_release_staled_pending_fd(struct pending_transport_
pa_xfree(pending_transport_fd);
}
struct set_volume_and_transport {
pa_bluetooth_transport *t;
uint16_t gain;
};
static void set_volume_reply(DBusPendingCall *pending, void *userdata) {
DBusMessage *r;
pa_dbus_pending *p;
pa_bluetooth_discovery *y;
struct set_volume_and_transport *call_data;
pa_bluetooth_transport *t;
pa_assert(pending);
pa_assert_se(p = userdata);
pa_assert_se(y = p->context_data);
pa_assert_se(call_data = p->call_data);
pa_assert_se(t = call_data->t);
pa_assert_se(r = dbus_pending_call_steal_reply(pending));
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
pa_log_error(DBUS_INTERFACE_PROPERTIES ".Set %s Volume failed: %s: %s",
dbus_message_get_path(p->message),
dbus_message_get_error_name(r),
pa_dbus_get_error_message(r));
goto finish;
}
pa_log_debug("Volume property set to %d on %s", call_data->gain, t->path);
if (pa_bluetooth_profile_is_a2dp_sink(t->profile))
t->tx_volume_gain = call_data->gain;
else if (pa_bluetooth_profile_is_a2dp_source(t->profile))
t->rx_volume_gain= call_data->gain;
else
pa_assert_not_reached();
finish:
pa_xfree(call_data);
dbus_message_unref(r);
PA_LLIST_REMOVE(pa_dbus_pending, y->pending, p);
pa_dbus_pending_free(p);
}
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;
DBusMessage *m;
DBusMessageIter iter;
......@@ -690,11 +644,10 @@ static void bluez5_transport_set_volume(pa_bluetooth_transport *t, uint16_t gain
pa_assert_se(dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &volume_str));
pa_dbus_append_basic_variant(&iter, DBUS_TYPE_UINT16, &gain);
call_data = pa_xnew0(struct set_volume_and_transport, 1);
call_data->t = t;
call_data->gain = gain;
send_and_add_to_pending(t->device->discovery, m, set_volume_reply, call_data);
/* Ignore replies, instead wait for the Volume property changed notification */
dbus_message_set_no_reply(m, true);
pa_assert_se(dbus_connection_send(pa_dbus_connection_get(t->device->discovery->connection), m, NULL));
dbus_message_unref(m);
}
static void bluez5_transport_set_sink_volume(pa_bluetooth_transport *t, uint16_t gain) {
......
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