bluez5: backend-native: set best codec also when retrying on timeout

Try again setting best available codec, not MSBC, when retrying if no
response to previous +BCS: command.
This commit is contained in:
Pauli Virtanen 2025-06-12 20:48:21 +03:00 committed by Wim Taymans
parent d04ee91714
commit 6982bb8c7f

View file

@ -3310,6 +3310,7 @@ static void codec_switch_timer_event(struct spa_source *source)
{ {
struct rfcomm *rfcomm = source->data; struct rfcomm *rfcomm = source->data;
struct impl *backend = rfcomm->backend; struct impl *backend = rfcomm->backend;
const struct media_codec *best_codec;
uint64_t exp; uint64_t exp;
if (spa_system_timerfd_read(backend->main_system, source->fd, &exp) < 0) if (spa_system_timerfd_read(backend->main_system, source->fd, &exp) < 0)
@ -3322,10 +3323,14 @@ static void codec_switch_timer_event(struct spa_source *source)
switch (rfcomm->hfp_ag_initial_codec_setup) { switch (rfcomm->hfp_ag_initial_codec_setup) {
case HFP_AG_INITIAL_CODEC_SETUP_SEND: case HFP_AG_INITIAL_CODEC_SETUP_SEND:
/* Retry codec selection */ /* Retry codec selection */
rfcomm->hfp_ag_initial_codec_setup = HFP_AG_INITIAL_CODEC_SETUP_WAIT; best_codec = codec_list_best(backend, &rfcomm->supported_codec_list);
rfcomm_send_reply(rfcomm, "+BCS: 2"); if (best_codec && best_codec->id != SPA_BLUETOOTH_AUDIO_CODEC_CVSD) {
codec_switch_start_timer(rfcomm, HFP_CODEC_SWITCH_TIMEOUT_MSEC); rfcomm->hfp_ag_initial_codec_setup = HFP_AG_INITIAL_CODEC_SETUP_WAIT;
return; rfcomm_send_reply(rfcomm, "+BCS: %u", best_codec->codec_id);
codec_switch_start_timer(rfcomm, HFP_CODEC_SWITCH_TIMEOUT_MSEC);
return;
}
SPA_FALLTHROUGH;
case HFP_AG_INITIAL_CODEC_SETUP_WAIT: case HFP_AG_INITIAL_CODEC_SETUP_WAIT:
/* Failure, try falling back to CVSD. */ /* Failure, try falling back to CVSD. */
rfcomm->hfp_ag_initial_codec_setup = HFP_AG_INITIAL_CODEC_SETUP_NONE; rfcomm->hfp_ag_initial_codec_setup = HFP_AG_INITIAL_CODEC_SETUP_NONE;