hfp_ag: always initiate codec connection setup before establishing audio

This commit is contained in:
Matthias Ringwald 2024-07-22 12:39:39 +02:00
parent d72e9d4b1d
commit d09b259dd6
2 changed files with 4 additions and 17 deletions

View File

@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Scan Parameter Service Client: emit disconnected event on HCI disconnect and free connection struct
- PBAP Client: fix PBAP_SUBEVENT_OPERATION_COMPLETED with OBEX_DISCONNECTED for pbap_disconnect
- HFP HF: send HF Indicator update only if enabled by AG
- HFP AG: always initiate codec connection setup before establishing audio
### Changed
- GAP: return command disallowed if disconnect already requested

View File

@ -2760,22 +2760,8 @@ static uint8_t hfp_ag_setup_audio_connection(hfp_connection_t * hfp_connection){
return ERROR_CODE_SUCCESS;
}
uint8_t i;
bool codec_was_in_use = false;
bool better_codec_can_be_used = false;
for (i = 0; i<hfp_connection->remote_codecs_nr; i++){
if (hfp_connection->negotiated_codec == hfp_connection->remote_codecs[i]){
codec_was_in_use = true;
} else if (hfp_connection->negotiated_codec < hfp_connection->remote_codecs[i]){
better_codec_can_be_used = true;
}
}
if (!codec_was_in_use || better_codec_can_be_used){
hfp_connection->ag_send_common_codec = true;
hfp_connection->codecs_state = HFP_CODECS_IDLE;
}
hfp_connection->ag_send_common_codec = true;
hfp_connection->codecs_state = HFP_CODECS_IDLE;
return ERROR_CODE_SUCCESS;
}