mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
bluez5: don't claim sbc is supported when there's no A2DP at all
Handle failure to register legacy A2DP endpoints.
This commit is contained in:
parent
cfee662f0b
commit
987b772b97
1 changed files with 16 additions and 11 deletions
|
|
@ -1935,7 +1935,8 @@ bool spa_bt_device_supports_media_codec(struct spa_bt_device *device, const stru
|
|||
|
||||
if (!device->adapter->a2dp_application_registered && !codec->bap) {
|
||||
/* Codec switching not supported: only plain SBC allowed */
|
||||
return (codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc"));
|
||||
return (codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc") &&
|
||||
device->adapter->legacy_endpoints_registered);
|
||||
}
|
||||
if (!device->adapter->bap_application_registered && codec->bap)
|
||||
return false;
|
||||
|
|
@ -3755,7 +3756,8 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
|
|||
|
||||
static void bluez_register_endpoint_legacy_reply(DBusPendingCall *pending, void *user_data)
|
||||
{
|
||||
struct spa_bt_monitor *monitor = user_data;
|
||||
struct spa_bt_adapter *adapter = user_data;
|
||||
struct spa_bt_monitor *monitor = adapter->monitor;
|
||||
DBusMessage *r;
|
||||
|
||||
r = dbus_pending_call_steal_reply(pending);
|
||||
|
|
@ -3774,6 +3776,8 @@ static void bluez_register_endpoint_legacy_reply(DBusPendingCall *pending, void
|
|||
goto finish;
|
||||
}
|
||||
|
||||
adapter->legacy_endpoints_registered = true;
|
||||
|
||||
finish:
|
||||
dbus_message_unref(r);
|
||||
}
|
||||
|
|
@ -3802,10 +3806,12 @@ static void append_basic_array_variant_dict_entry(DBusMessageIter *dict, const c
|
|||
dbus_message_iter_close_container(dict, &dict_entry_it);
|
||||
}
|
||||
|
||||
static int bluez_register_endpoint_legacy(struct spa_bt_monitor *monitor,
|
||||
const char *path, enum spa_bt_media_direction direction,
|
||||
static int bluez_register_endpoint_legacy(struct spa_bt_adapter *adapter,
|
||||
enum spa_bt_media_direction direction,
|
||||
const char *uuid, const struct media_codec *codec)
|
||||
{
|
||||
struct spa_bt_monitor *monitor = adapter->monitor;
|
||||
const char *path = adapter->path;
|
||||
char *object_path = NULL;
|
||||
DBusMessage *m;
|
||||
DBusMessageIter object_it, dict_it;
|
||||
|
|
@ -3846,7 +3852,7 @@ static int bluez_register_endpoint_legacy(struct spa_bt_monitor *monitor,
|
|||
dbus_message_iter_close_container(&object_it, &dict_it);
|
||||
|
||||
dbus_connection_send_with_reply(monitor->conn, m, &call, -1);
|
||||
dbus_pending_call_set_notify(call, bluez_register_endpoint_legacy_reply, monitor, NULL);
|
||||
dbus_pending_call_set_notify(call, bluez_register_endpoint_legacy_reply, adapter, NULL);
|
||||
dbus_message_unref(m);
|
||||
|
||||
free(object_path);
|
||||
|
|
@ -3864,6 +3870,7 @@ static int adapter_register_endpoints_legacy(struct spa_bt_adapter *a)
|
|||
const struct media_codec * const * const media_codecs = monitor->media_codecs;
|
||||
int i;
|
||||
int err = 0;
|
||||
bool registered = false;
|
||||
|
||||
if (a->legacy_endpoints_registered)
|
||||
return err;
|
||||
|
|
@ -3885,26 +3892,24 @@ static int adapter_register_endpoints_legacy(struct spa_bt_adapter *a)
|
|||
continue;
|
||||
|
||||
if (endpoint_should_be_registered(monitor, codec, SPA_BT_MEDIA_SOURCE)) {
|
||||
if ((err = bluez_register_endpoint_legacy(monitor, a->path,
|
||||
SPA_BT_MEDIA_SOURCE,
|
||||
if ((err = bluez_register_endpoint_legacy(a, SPA_BT_MEDIA_SOURCE,
|
||||
SPA_BT_UUID_A2DP_SOURCE,
|
||||
codec)))
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (endpoint_should_be_registered(monitor, codec, SPA_BT_MEDIA_SINK)) {
|
||||
if ((err = bluez_register_endpoint_legacy(monitor, a->path,
|
||||
SPA_BT_MEDIA_SINK,
|
||||
if ((err = bluez_register_endpoint_legacy(a, SPA_BT_MEDIA_SINK,
|
||||
SPA_BT_UUID_A2DP_SINK,
|
||||
codec)))
|
||||
goto out;
|
||||
}
|
||||
|
||||
a->legacy_endpoints_registered = true;
|
||||
registered = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!a->legacy_endpoints_registered) {
|
||||
if (!registered) {
|
||||
/* Should never happen as SBC support is always enabled */
|
||||
spa_log_error(monitor->log, "Broken PipeWire build - unable to locate SBC codec");
|
||||
err = -ENOSYS;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue