mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 12:40:42 +00:00
hfp: disable mSBC if eSCO not available
This commit is contained in:
parent
64a157956a
commit
d715cf5114
@ -142,6 +142,20 @@ int hfp_supports_codec(uint8_t codec, int codecs_nr, uint8_t * codecs){
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hfp_hf_drop_mSBC_if_eSCO_not_supported(uint8_t * codecs, uint8_t * codecs_nr){
|
||||
if (hci_extended_sco_link_supported()) return;
|
||||
uint8_t tmp_codecs[HFP_MAX_NUM_CODECS];
|
||||
int i;
|
||||
int tmp_codec_nr = 0;
|
||||
for (i=0; i < *codecs_nr; i++){
|
||||
if (codecs[i] == HFP_CODEC_MSBC) continue;
|
||||
tmp_codecs[tmp_codec_nr++] = codecs[i];
|
||||
}
|
||||
*codecs_nr = tmp_codec_nr;
|
||||
memcpy(codecs, tmp_codecs, tmp_codec_nr);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
void hfp_set_codec(hfp_connection_t * hfp_connection, uint8_t *packet, uint16_t size){
|
||||
// parse available codecs
|
||||
|
@ -657,6 +657,7 @@ void hfp_release_audio_connection(hfp_connection_t * connection);
|
||||
|
||||
void hfp_setup_synchronous_connection(hfp_connection_t * connection);
|
||||
int hfp_supports_codec(uint8_t codec, int codecs_nr, uint8_t * codecs);
|
||||
void hfp_hf_drop_mSBC_if_eSCO_not_supported(uint8_t * codecs, uint8_t * codecs_nr);
|
||||
|
||||
const char * hfp_hf_feature(int index);
|
||||
const char * hfp_ag_feature(int index);
|
||||
|
@ -656,6 +656,7 @@ static int hfp_ag_run_for_context_service_level_connection(hfp_connection_t * hf
|
||||
switch(hfp_connection->state){
|
||||
case HFP_W4_EXCHANGE_SUPPORTED_FEATURES:
|
||||
case HFP_EXCHANGE_SUPPORTED_FEATURES:
|
||||
hfp_hf_drop_mSBC_if_eSCO_not_supported(hfp_codecs, &hfp_codecs_nr);
|
||||
if (has_codec_negotiation_feature(hfp_connection)){
|
||||
hfp_connection->state = HFP_W4_NOTIFY_ON_CODECS;
|
||||
} else {
|
||||
|
@ -408,6 +408,7 @@ static int hfp_hf_run_for_context_service_level_connection(hfp_connection_t * hf
|
||||
|
||||
switch (hfp_connection->state){
|
||||
case HFP_EXCHANGE_SUPPORTED_FEATURES:
|
||||
hfp_hf_drop_mSBC_if_eSCO_not_supported(hfp_codecs, &hfp_codecs_nr);
|
||||
hfp_connection->state = HFP_W4_EXCHANGE_SUPPORTED_FEATURES;
|
||||
hfp_hf_cmd_exchange_supported_features(hfp_connection->rfcomm_cid);
|
||||
break;
|
||||
@ -1129,18 +1130,6 @@ void hfp_hf_init_codecs(int codecs_nr, uint8_t * codecs){
|
||||
for (i=0; i<codecs_nr; i++){
|
||||
hfp_codecs[i] = codecs[i];
|
||||
}
|
||||
|
||||
char buffer[30];
|
||||
int offset = join(buffer, sizeof(buffer), hfp_codecs, hfp_codecs_nr);
|
||||
buffer[offset] = 0;
|
||||
btstack_linked_list_iterator_t it;
|
||||
btstack_linked_list_iterator_init(&it, hfp_get_connections());
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
hfp_connection_t * hfp_connection = (hfp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (! hfp_connection) continue;
|
||||
hfp_connection->command = HFP_CMD_AVAILABLE_CODECS;
|
||||
hfp_run_for_context(hfp_connection);
|
||||
}
|
||||
}
|
||||
|
||||
void hfp_hf_init_supported_features(uint32_t supported_features){
|
||||
|
Loading…
x
Reference in New Issue
Block a user