mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
bluetooth: Fix possible adapter duplicates
The D-Bus signal AdapterAdded can be received during our call to GetProperties(), before the reply is received. In this case, the adapter will be listed twice and thus the endpoint registration will fail with "AlreadyExists" as follows: D: [pulseaudio] bluetooth-util.c: dbus: interface=org.bluez.Manager, path=/, member=AdapterAdded D: [pulseaudio] bluetooth-util.c: Adapter /org/bluez/21220/hci0 created D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/HFPAG on adapter /org/bluez/21220/hci0. D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/HFPHS on adapter /org/bluez/21220/hci0. D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/A2DPSource on adapter /org/bluez/21220/hci0. D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/A2DPSink on adapter /org/bluez/21220/hci0. D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/HFPAG on adapter /org/bluez/21220/hci0. D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/HFPHS on adapter /org/bluez/21220/hci0. D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/A2DPSource on adapter /org/bluez/21220/hci0. D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/A2DPSink on adapter /org/bluez/21220/hci0. E: [pulseaudio] bluetooth-util.c: RegisterEndpoint() failed: org.bluez.Error.AlreadyExists: Already Exists E: [pulseaudio] bluetooth-util.c: RegisterEndpoint() failed: org.bluez.Error.AlreadyExists: Already Exists E: [pulseaudio] bluetooth-util.c: RegisterEndpoint() failed: org.bluez.Error.AlreadyExists: Already Exists E: [pulseaudio] bluetooth-util.c: RegisterEndpoint() failed: org.bluez.Error.AlreadyExists: Already Exists
This commit is contained in:
parent
163430f05b
commit
90ae777500
1 changed files with 12 additions and 2 deletions
|
|
@ -67,6 +67,7 @@ struct pa_bluetooth_discovery {
|
||||||
pa_core *core;
|
pa_core *core;
|
||||||
pa_dbus_connection *connection;
|
pa_dbus_connection *connection;
|
||||||
PA_LLIST_HEAD(pa_dbus_pending, pending);
|
PA_LLIST_HEAD(pa_dbus_pending, pending);
|
||||||
|
bool adapters_listed;
|
||||||
pa_hashmap *devices;
|
pa_hashmap *devices;
|
||||||
pa_hashmap *transports;
|
pa_hashmap *transports;
|
||||||
pa_hook hooks[PA_BLUETOOTH_HOOK_MAX];
|
pa_hook hooks[PA_BLUETOOTH_HOOK_MAX];
|
||||||
|
|
@ -278,8 +279,11 @@ static int parse_manager_property(pa_bluetooth_discovery *y, DBusMessageIter *i,
|
||||||
DBusMessageIter ai;
|
DBusMessageIter ai;
|
||||||
dbus_message_iter_recurse(&variant_i, &ai);
|
dbus_message_iter_recurse(&variant_i, &ai);
|
||||||
|
|
||||||
if (dbus_message_iter_get_arg_type(&ai) == DBUS_TYPE_OBJECT_PATH &&
|
if (pa_streq(key, "Adapters")) {
|
||||||
pa_streq(key, "Adapters")) {
|
y->adapters_listed = true;
|
||||||
|
|
||||||
|
if (dbus_message_iter_get_arg_type(&ai) != DBUS_TYPE_OBJECT_PATH)
|
||||||
|
break;
|
||||||
|
|
||||||
while (dbus_message_iter_get_arg_type(&ai) != DBUS_TYPE_INVALID) {
|
while (dbus_message_iter_get_arg_type(&ai) != DBUS_TYPE_INVALID) {
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
@ -959,6 +963,11 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!y->adapters_listed) {
|
||||||
|
pa_log_debug("Ignoring 'AdapterAdded' because initial adapter list has not been received yet.");
|
||||||
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
pa_log_debug("Adapter %s created", path);
|
pa_log_debug("Adapter %s created", path);
|
||||||
|
|
||||||
found_adapter(y, path);
|
found_adapter(y, path);
|
||||||
|
|
@ -1011,6 +1020,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
|
||||||
if (old_owner && *old_owner) {
|
if (old_owner && *old_owner) {
|
||||||
pa_log_debug("Bluetooth daemon disappeared.");
|
pa_log_debug("Bluetooth daemon disappeared.");
|
||||||
remove_all_devices(y);
|
remove_all_devices(y);
|
||||||
|
y->adapters_listed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_owner && *new_owner) {
|
if (new_owner && *new_owner) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue