Commit c0e6e832 authored by Hsin-Yu Chao's avatar Hsin-Yu Chao Committed by Commit Bot

CrOS audio: handle bluetooth wideband node

Some CrOS platform will support BT wideband speech, and CRAS will
change to report type BLUETOOTH_NB_MIC for the legacy narrow band
input, while output and wideband speech input stay in type BLUETOOTH.

In commit 087ec22e we lowered the priority of BT input because
using HFP means BT output falls to lower quality. Users don't like
it and don't understand the technical detail behind that.
With the support of wideband speech, we think the audio quality
is acceptable and deserves equal node priority as BT output.

Bug: 1000576
Change-Id: I3c027afe349c6b9c3d55cf0e3a0472e28863cedb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1828765
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Auto-Submit: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704089}
parent a257a85d
......@@ -35,6 +35,8 @@ base::string16 GetAudioDeviceName(const chromeos::AudioDevice& device) {
return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_AUDIO_USB_DEVICE,
base::UTF8ToUTF16(device.display_name));
case chromeos::AUDIO_TYPE_BLUETOOTH:
FALLTHROUGH;
case chromeos::AUDIO_TYPE_BLUETOOTH_NB_MIC:
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_AUDIO_BLUETOOTH_DEVICE,
base::UTF8ToUTF16(device.display_name));
......
......@@ -18,11 +18,6 @@ namespace {
// Get the priority for a particular device type. The priority returned
// will be between 0 to 3, the higher number meaning a higher priority.
uint8_t GetDevicePriority(AudioDeviceType type, bool is_input) {
// Lower the priority of bluetooth mic to prevent unexpected bad eperience
// to user because of bluetooth audio profile switching. Make priority to
// zero so this mic will never be automatically chosen.
if (type == AUDIO_TYPE_BLUETOOTH && is_input)
return 0;
switch (type) {
case AUDIO_TYPE_HEADPHONE:
case AUDIO_TYPE_LINEOUT:
......@@ -36,6 +31,10 @@ uint8_t GetDevicePriority(AudioDeviceType type, bool is_input) {
case AUDIO_TYPE_INTERNAL_MIC:
case AUDIO_TYPE_FRONT_MIC:
return 1;
// Lower the priority of bluetooth mic to prevent unexpected bad eperience
// to user because of bluetooth audio profile switching. Make priority to
// zero so this mic will never be automatically chosen.
case AUDIO_TYPE_BLUETOOTH_NB_MIC:
// Rear mic should have priority lower than front mic to prevent poor
// quality input caused by accidental selecting to rear side mic.
case AUDIO_TYPE_REAR_MIC:
......@@ -62,6 +61,8 @@ std::string AudioDevice::GetTypeString(AudioDeviceType type) {
return "USB";
case AUDIO_TYPE_BLUETOOTH:
return "BLUETOOTH";
case AUDIO_TYPE_BLUETOOTH_NB_MIC:
return "BLUETOOTH_NB_MIC";
case AUDIO_TYPE_HDMI:
return "HDMI";
case AUDIO_TYPE_INTERNAL_SPEAKER:
......@@ -101,6 +102,8 @@ AudioDeviceType AudioDevice::GetAudioType(
return AUDIO_TYPE_REAR_MIC;
else if (node_type.find("KEYBOARD_MIC") != std::string::npos)
return AUDIO_TYPE_KEYBOARD_MIC;
else if (node_type.find("BLUETOOTH_NB_MIC") != std::string::npos)
return AUDIO_TYPE_BLUETOOTH_NB_MIC;
else if (node_type.find("MIC") != std::string::npos)
return AUDIO_TYPE_MIC;
else if (node_type.find("USB") != std::string::npos)
......
......@@ -22,6 +22,7 @@ enum AudioDeviceType {
AUDIO_TYPE_MIC,
AUDIO_TYPE_USB,
AUDIO_TYPE_BLUETOOTH,
AUDIO_TYPE_BLUETOOTH_NB_MIC,
AUDIO_TYPE_HDMI,
AUDIO_TYPE_INTERNAL_SPEAKER,
AUDIO_TYPE_INTERNAL_MIC,
......@@ -58,6 +59,7 @@ struct COMPONENT_EXPORT(CHROMEOS_AUDIO) AudioDevice {
type == AUDIO_TYPE_MIC ||
type == AUDIO_TYPE_USB ||
type == AUDIO_TYPE_BLUETOOTH ||
type == AUDIO_TYPE_BLUETOOTH_NB_MIC ||
type == AUDIO_TYPE_HDMI ||
type == AUDIO_TYPE_INTERNAL_SPEAKER ||
type == AUDIO_TYPE_LINEOUT);
......
......@@ -36,6 +36,7 @@ api::audio::DeviceType GetAsAudioApiDeviceType(chromeos::AudioDeviceType type) {
case chromeos::AUDIO_TYPE_USB:
return api::audio::DEVICE_TYPE_USB;
case chromeos::AUDIO_TYPE_BLUETOOTH:
case chromeos::AUDIO_TYPE_BLUETOOTH_NB_MIC:
return api::audio::DEVICE_TYPE_BLUETOOTH;
case chromeos::AUDIO_TYPE_HDMI:
return api::audio::DEVICE_TYPE_HDMI;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment