bluez5: prefer 16khz input for LE Audio duplex configurations

Devices may advertise other values, but not certain they will work well
in duplex configuration.

E.g. my Samsung Galaxy Buds2 Pro emits buzzing sound with 48kHz duplex
input.
This commit is contained in:
Pauli Virtanen 2023-11-27 22:01:18 +02:00 committed by Wim Taymans
parent cde8f9261c
commit 89077d16ec

View file

@ -468,7 +468,16 @@ static bool select_config(bap_lc3_t *conf, const struct pac_data *pac, struct sp
/*
* Select supported rate + frame length combination
*/
bap_qos = select_bap_qos(rate_mask, duration_mask, framelen_min, framelen_max);
if (pac->sink && pac->duplex) {
/* 16KHz input is mandatory in BAP v1.0.1 Table 3.5, so prefer
* it for now for input rate in duplex configuration.
*
* Devices may list other values but not certain they will work properly.
*/
bap_qos = select_bap_qos(rate_mask & LC3_FREQ_16KHZ, duration_mask, framelen_min, framelen_max);
}
if (!bap_qos)
bap_qos = select_bap_qos(rate_mask, duration_mask, framelen_min, framelen_max);
if (!bap_qos) {
spa_debugc(debug_ctx, "no compatible configuration found, rate:0x%08x, duration:0x%08x frame:%u-%u",
@ -565,6 +574,9 @@ static int conf_cmp(const bap_lc3_t *conf1, int res1, const bap_lc3_t *conf2, in
PREFER_BOOL(conf->rate & (LC3_CONFIG_FREQ_48KHZ | LC3_CONFIG_FREQ_32KHZ | \
LC3_CONFIG_FREQ_24KHZ | LC3_CONFIG_FREQ_16KHZ | LC3_CONFIG_FREQ_8KHZ));
if (conf->sink && conf->duplex)
PREFER_BOOL(conf->rate & LC3_CONFIG_FREQ_16KHZ);
PREFER_BOOL(conf->rate & LC3_CONFIG_FREQ_48KHZ);
PREFER_BOOL(conf->rate & LC3_CONFIG_FREQ_32KHZ);
PREFER_BOOL(conf->rate & LC3_CONFIG_FREQ_24KHZ);
@ -924,6 +936,9 @@ static void *codec_init(const struct media_codec *codec, uint32_t flags,
goto error;
}
spa_log_info(log, "LC3 rate:%d frame_duration:%d channels:%d framelen:%d",
this->samplerate, this->frame_dus, this->channels, this->framelen);
this->samples = lc3_frame_samples(this->frame_dus, this->samplerate);
if (this->samples < 0) {
res = -EINVAL;