diff --git a/src/classic/hfp.c b/src/classic/hfp.c index e067d7a5c..c8a1bade6 100644 --- a/src/classic/hfp.c +++ b/src/classic/hfp.c @@ -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 diff --git a/src/classic/hfp.h b/src/classic/hfp.h index 2e29a3637..8c6ac3007 100644 --- a/src/classic/hfp.h +++ b/src/classic/hfp.h @@ -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); diff --git a/src/classic/hfp_ag.c b/src/classic/hfp_ag.c index 316ccea77..7818f8efa 100644 --- a/src/classic/hfp_ag.c +++ b/src/classic/hfp_ag.c @@ -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 { diff --git a/src/classic/hfp_hf.c b/src/classic/hfp_hf.c index 440dd22c9..2bac88752 100644 --- a/src/classic/hfp_hf.c +++ b/src/classic/hfp_hf.c @@ -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; icommand = HFP_CMD_AVAILABLE_CODECS; - hfp_run_for_context(hfp_connection); - } } void hfp_hf_init_supported_features(uint32_t supported_features){