mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
bluez5: enable SBC-XQ codec by default, if allowed by quirks
Enable SBC-XQ by default, and move it at the end of the codecs list, so that bluez does not connect to it automatically except when it is the codec used previously. When the codec is disabled by quirks, it won't appear in the codecs list, and so can't be selected by user (and so won't be connected automatically). However, since SelectConfiguration does not carry information which device is in question, we cannot prevent BlueZ connecting to the codec even if it's disabled for a specific device. If the "impossible" occurs regardless, we won't reject the connection and the profile will be shown as the generic "A2DP" one. If the sound is garbled, the user can select some other profile that works.
This commit is contained in:
parent
f5850af4d8
commit
5071589aea
6 changed files with 11 additions and 16 deletions
|
|
@ -91,7 +91,6 @@ struct spa_bt_monitor {
|
|||
|
||||
struct spa_bt_quirks *quirks;
|
||||
|
||||
unsigned int enable_sbc_xq:1;
|
||||
unsigned int backend_native_registered:1;
|
||||
unsigned int backend_ofono_registered:1;
|
||||
unsigned int backend_hsphfpd_registered:1;
|
||||
|
|
@ -440,10 +439,6 @@ static int a2dp_endpoint_to_profile(const char *endpoint)
|
|||
|
||||
static bool is_a2dp_codec_enabled(struct spa_bt_monitor *monitor, const struct a2dp_codec *codec)
|
||||
{
|
||||
if (!monitor->enable_sbc_xq && codec->feature_flag != NULL &&
|
||||
spa_streq(codec->feature_flag, "sbc-xq"))
|
||||
return false;
|
||||
|
||||
return spa_dict_lookup(&monitor->enabled_codecs, codec->name) != NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1384,6 +1379,7 @@ static int device_update_props(struct spa_bt_device *device,
|
|||
|
||||
bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struct a2dp_codec *codec)
|
||||
{
|
||||
struct spa_bt_monitor *monitor = device->monitor;
|
||||
struct spa_bt_remote_endpoint *ep;
|
||||
|
||||
if (!is_a2dp_codec_enabled(device->monitor, codec))
|
||||
|
|
@ -1394,6 +1390,14 @@ bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struc
|
|||
return (codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc"));
|
||||
}
|
||||
|
||||
if (codec->id == SPA_BLUETOOTH_AUDIO_CODEC_SBC_XQ) {
|
||||
uint32_t bt_features = (uint32_t)-1;
|
||||
if (monitor->quirks)
|
||||
spa_bt_quirks_get_features(monitor->quirks, device->adapter, device, &bt_features);
|
||||
if (!(bt_features & SPA_BT_FEATURE_SBC_XQ))
|
||||
return false;
|
||||
}
|
||||
|
||||
spa_list_for_each(ep, &device->remote_endpoint_list, device_link) {
|
||||
if (a2dp_codec_check_caps(codec, ep->codec, ep->capabilities, ep->capabilities_len,
|
||||
&ep->monitor->default_audio_info))
|
||||
|
|
@ -3861,7 +3865,6 @@ static int impl_clear(struct spa_handle *handle)
|
|||
monitor->objects_listed = false;
|
||||
|
||||
monitor->connection_info_supported = false;
|
||||
monitor->enable_sbc_xq = false;
|
||||
monitor->backend_native_registered = false;
|
||||
monitor->backend_ofono_registered = false;
|
||||
monitor->backend_hsphfpd_registered = false;
|
||||
|
|
@ -4069,10 +4072,6 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
if ((str = spa_dict_lookup(info, "bluez5.default.channels")) != NULL &&
|
||||
((tmp = atoi(str)) > 0))
|
||||
this->default_audio_info.channels = tmp;
|
||||
|
||||
if ((str = spa_dict_lookup(info, "bluez5.enable-sbc-xq")) != NULL &&
|
||||
spa_atob(str))
|
||||
this->enable_sbc_xq = true;
|
||||
}
|
||||
|
||||
register_media_application(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue