From b1e4799ea64946584acadfaeed23431ba684a15f Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Wed, 8 Jan 2025 17:52:24 +0530 Subject: [PATCH] bluez5: Ensure codec_id comparison is against codec of right type G722 codec id for ASHA is chosen arbitrarily to be different from A2DP and BAP codec IDs. ASHA spec does not specify a codec ID like A2DP/BAP. In places where codec_id comparisons are done, ensure that the check is done against the codec of the right type viz. A2DP/BAP/ASHA. --- spa/plugins/bluez5/bluez5-dbus.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spa/plugins/bluez5/bluez5-dbus.c b/spa/plugins/bluez5/bluez5-dbus.c index ab3a89d03..72128f746 100644 --- a/spa/plugins/bluez5/bluez5-dbus.c +++ b/spa/plugins/bluez5/bluez5-dbus.c @@ -2496,12 +2496,13 @@ bool spa_bt_device_supports_media_codec(struct spa_bt_device *device, const stru { SPA_BLUETOOTH_AUDIO_CODEC_APTX_LL_DUPLEX, SPA_BT_FEATURE_A2DP_DUPLEX }, { SPA_BLUETOOTH_AUDIO_CODEC_FASTSTREAM_DUPLEX, SPA_BT_FEATURE_A2DP_DUPLEX }, }; + bool is_a2dp = !codec->bap && !codec->asha; size_t i; if (!is_media_codec_enabled(device->monitor, codec)) return false; - if (!device->adapter->a2dp_application_registered && !codec->bap) { + if (!device->adapter->a2dp_application_registered && is_a2dp) { /* Codec switching not supported: only plain SBC allowed */ return (codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc") && device->adapter->legacy_endpoints_registered); @@ -4113,6 +4114,8 @@ static int setup_asha_transport(struct spa_bt_remote_endpoint *remote_endpoint, for (int i = 0; media_codecs[i]; i++) { const struct media_codec *mcodec = media_codecs[i]; + if (!mcodec->asha) + continue; if (!spa_streq(mcodec->name, "g722")) continue; codec = mcodec; @@ -5099,6 +5102,8 @@ static DBusHandlerResult object_manager_handler(DBusConnection *c, DBusMessage * if (codec->bap != is_bap) continue; + if (codec->asha) + continue; if (!is_media_codec_enabled(monitor, codec)) continue;