summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEn-Shuo Hsu <enshuo@chromium.org>2021-02-01 19:05:52 +0800
committerCommit Bot <commit-bot@chromium.org>2021-02-02 12:13:55 +0000
commitcb1f53abc38a16258268c2571bf58b79c76033ed (patch)
tree3246c5dcf26dff0c0c1dc6133bf498419cdfd248
parent4f59716f43cebdbb5ee21d5dc01a742bbb899190 (diff)
downloadadhd-cb1f53abc38a16258268c2571bf58b79c76033ed.tar.gz
cras: Set preferred codec to msbc only if WBS is supported
Some headsets reports available codecs through AT+BAC even if AG declares not supporting codec negotiation. This is not disallowed by the Bluetooth HFP spec. We should check if the WBS is supported by the AG also before setting it as our preferred codec. The set to CVSD is required for cases that HF declares different supported codecs after the codec negotiation is done. This case is covered by our unittest. BUG=b:177469064 TEST=unittest and deploy to DUT and verify the bug doesn't repro Change-Id: Idab5c6acfbeeadb94d1c9a44753d02dbd5047382 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2662796 Tested-by: En-Shuo Hsu <enshuo@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org> Commit-Queue: En-Shuo Hsu <enshuo@chromium.org>
-rw-r--r--cras/src/server/cras_hfp_slc.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/cras/src/server/cras_hfp_slc.c b/cras/src/server/cras_hfp_slc.c
index 11c89bec..b83b21d0 100644
--- a/cras/src/server/cras_hfp_slc.c
+++ b/cras/src/server/cras_hfp_slc.c
@@ -441,12 +441,10 @@ static int available_codecs(struct hfp_slc_handle *handle, const char *cmd)
id_str = strtok(NULL, ",");
}
- for (id = HFP_MAX_CODECS - 1; id > 0; id--) {
- if (handle->hf_codec_supported[id]) {
- handle->preferred_codec = id;
- break;
- }
- }
+ if (hfp_slc_get_wideband_speech_supported(handle))
+ handle->preferred_codec = HFP_CODEC_ID_MSBC;
+ else
+ handle->preferred_codec = HFP_CODEC_ID_CVSD;
free(tokens);
return hfp_send(handle, AT_CMD("OK"));