bluez5: close sco socket if bluetooth daemon disappeared

Fixes pipewire/pipewire#853
This commit is contained in:
Huang-Huang Bao 2021-03-13 18:46:54 +08:00
parent e2ac16ccbd
commit d6be84ddd0
No known key found for this signature in database
GPG key ID: 33C3271387A13D1B
2 changed files with 13 additions and 1 deletions

View file

@ -1387,7 +1387,7 @@ void backend_native_register_profiles(struct spa_bt_backend *backend)
sco_listen(backend);
}
void backend_native_unregister_profiles(struct spa_bt_backend *backend)
void sco_close(struct spa_bt_backend *backend)
{
if (backend->sco.fd >= 0) {
if (backend->sco.loop)
@ -1396,6 +1396,11 @@ void backend_native_unregister_profiles(struct spa_bt_backend *backend)
close (backend->sco.fd);
backend->sco.fd = -1;
}
}
void backend_native_unregister_profiles(struct spa_bt_backend *backend)
{
sco_close(backend);
#ifdef HAVE_BLUEZ_5_BACKEND_HSP_NATIVE
if (backend->enabled_profiles & SPA_BT_PROFILE_HSP_AG)
@ -1416,6 +1421,8 @@ void backend_native_free(struct spa_bt_backend *backend)
{
struct rfcomm *rfcomm;
sco_close(backend);
#ifdef HAVE_BLUEZ_5_BACKEND_HSP_NATIVE
dbus_connection_unregister_object_path(backend->conn, PROFILE_HSP_AG);
dbus_connection_unregister_object_path(backend->conn, PROFILE_HSP_HS);

View file

@ -2917,6 +2917,11 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
spa_log_debug(monitor->log, "Bluetooth daemon disappeared");
monitor->objects_listed = false;
if (monitor->backend_native_registered) {
backend_native_unregister_profiles(monitor->backend_native);
monitor->backend_native_registered = false;
}
spa_list_consume(t, &monitor->transport_list, link)
spa_bt_transport_free(t);
spa_list_consume(ep, &monitor->remote_endpoint_list, link)