mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
bluez5: check if we have any codecs before trying to register
Don't try to register A2DP / BAP with BlueZ if we don't have any codecs for that.
This commit is contained in:
parent
ae9262409f
commit
1d23d21ffe
1 changed files with 25 additions and 1 deletions
|
|
@ -4906,10 +4906,28 @@ static void unregister_media_application(struct spa_bt_monitor * monitor)
|
||||||
dbus_connection_unregister_object_path(monitor->conn, A2DP_OBJECT_MANAGER_PATH);
|
dbus_connection_unregister_object_path(monitor->conn, A2DP_OBJECT_MANAGER_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool have_codec_endpoints(struct spa_bt_monitor *monitor, bool bap)
|
||||||
|
{
|
||||||
|
const struct media_codec * const * const media_codecs = monitor->media_codecs;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; media_codecs[i]; i++) {
|
||||||
|
const struct media_codec *codec = media_codecs[i];
|
||||||
|
|
||||||
|
if (codec->bap != bap)
|
||||||
|
continue;
|
||||||
|
if (endpoint_should_be_registered(monitor, codec, SPA_BT_MEDIA_SINK) ||
|
||||||
|
endpoint_should_be_registered(monitor, codec, SPA_BT_MEDIA_SOURCE))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static int adapter_register_application(struct spa_bt_adapter *a, bool bap)
|
static int adapter_register_application(struct spa_bt_adapter *a, bool bap)
|
||||||
{
|
{
|
||||||
const char *object_manager_path = bap ? BAP_OBJECT_MANAGER_PATH : A2DP_OBJECT_MANAGER_PATH;
|
const char *object_manager_path = bap ? BAP_OBJECT_MANAGER_PATH : A2DP_OBJECT_MANAGER_PATH;
|
||||||
struct spa_bt_monitor *monitor = a->monitor;
|
struct spa_bt_monitor *monitor = a->monitor;
|
||||||
|
const char *ep_type_name = (bap ? "LE Audio" : "A2DP");
|
||||||
DBusMessage *m;
|
DBusMessage *m;
|
||||||
DBusMessageIter i, d;
|
DBusMessageIter i, d;
|
||||||
DBusPendingCall *call;
|
DBusPendingCall *call;
|
||||||
|
|
@ -4925,8 +4943,14 @@ static int adapter_register_application(struct spa_bt_adapter *a, bool bap)
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!have_codec_endpoints(monitor, bap)) {
|
||||||
|
spa_log_warn(monitor->log, "No available %s codecs to register on adapter %s",
|
||||||
|
ep_type_name, a->path);
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
spa_log_debug(monitor->log, "Registering bluez5 %s media application on adapter %s",
|
spa_log_debug(monitor->log, "Registering bluez5 %s media application on adapter %s",
|
||||||
(bap ? "LE Audio" : "A2DP"), a->path);
|
ep_type_name, a->path);
|
||||||
|
|
||||||
m = dbus_message_new_method_call(BLUEZ_SERVICE,
|
m = dbus_message_new_method_call(BLUEZ_SERVICE,
|
||||||
a->path,
|
a->path,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue