Commit 7749f446 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Show slider for internal mic for dual internal mic devices

For dual internal mic devices, the internal mic entry in the ui
is a stub. Need to tweak the visibility logic to make sure the
slider for the stub internal mic shows up correctly.

Bug: 1083040
Change-Id: I14d2ef7733142539ae9432bec6a265b553c62d6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2205980Reviewed-by: default avatarJenny Zhang <jennyz@chromium.org>
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769892}
parent 6862c763
...@@ -163,8 +163,10 @@ void AudioDetailedView::UpdateScrollableList() { ...@@ -163,8 +163,10 @@ void AudioDetailedView::UpdateScrollableList() {
AddScrollListCheckableItem(GetAudioDeviceName(device), device.active); AddScrollListCheckableItem(GetAudioDeviceName(device), device.active);
device_map_[container] = device; device_map_[container] = device;
if (features::IsSystemTrayMicGainSettingEnabled()) if (features::IsSystemTrayMicGainSettingEnabled()) {
AddScrollListChild(mic_gain_controller_->CreateMicGainSlider(device.id)); AddScrollListChild(mic_gain_controller_->CreateMicGainSlider(
device.id, device.IsInternalMic()));
}
} }
scroll_content()->SizeToPreferredSize(); scroll_content()->SizeToPreferredSize();
......
...@@ -14,8 +14,9 @@ namespace ash { ...@@ -14,8 +14,9 @@ namespace ash {
MicGainSliderController::MicGainSliderController() = default; MicGainSliderController::MicGainSliderController() = default;
std::unique_ptr<MicGainSliderView> MicGainSliderController::CreateMicGainSlider( std::unique_ptr<MicGainSliderView> MicGainSliderController::CreateMicGainSlider(
uint64_t device_id) { uint64_t device_id,
return std::make_unique<MicGainSliderView>(this, device_id); bool internal) {
return std::make_unique<MicGainSliderView>(this, device_id, internal);
} }
views::View* MicGainSliderController::CreateView() { views::View* MicGainSliderController::CreateView() {
......
...@@ -18,7 +18,8 @@ class MicGainSliderController : public UnifiedSliderListener { ...@@ -18,7 +18,8 @@ class MicGainSliderController : public UnifiedSliderListener {
MicGainSliderController(); MicGainSliderController();
// Create a slider view for a specific input device. // Create a slider view for a specific input device.
std::unique_ptr<MicGainSliderView> CreateMicGainSlider(uint64_t device_id); std::unique_ptr<MicGainSliderView> CreateMicGainSlider(uint64_t device_id,
bool internal);
// UnifiedSliderListener: // UnifiedSliderListener:
views::View* CreateView() override; views::View* CreateView() override;
......
...@@ -19,11 +19,13 @@ using chromeos::CrasAudioHandler; ...@@ -19,11 +19,13 @@ using chromeos::CrasAudioHandler;
namespace ash { namespace ash {
MicGainSliderView::MicGainSliderView(MicGainSliderController* controller, MicGainSliderView::MicGainSliderView(MicGainSliderController* controller,
uint64_t device_id) uint64_t device_id,
bool internal)
: UnifiedSliderView(controller, : UnifiedSliderView(controller,
kImeMenuMicrophoneIcon, kImeMenuMicrophoneIcon,
IDS_ASH_STATUS_TRAY_VOLUME_SLIDER_LABEL), IDS_ASH_STATUS_TRAY_VOLUME_SLIDER_LABEL),
device_id_(device_id) { device_id_(device_id),
internal_(internal) {
CrasAudioHandler::Get()->AddAudioObserver(this); CrasAudioHandler::Get()->AddAudioObserver(this);
auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>( auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
...@@ -42,14 +44,26 @@ MicGainSliderView::~MicGainSliderView() { ...@@ -42,14 +44,26 @@ MicGainSliderView::~MicGainSliderView() {
} }
void MicGainSliderView::Update(bool by_user) { void MicGainSliderView::Update(bool by_user) {
if (CrasAudioHandler::Get()->GetPrimaryActiveInputNode() != device_id_) { auto* audio_handler = CrasAudioHandler::Get();
uint64_t active_device_id = audio_handler->GetPrimaryActiveInputNode();
auto* active_device = audio_handler->GetDeviceFromId(active_device_id);
// If the device has dual internal mics the internal mic shown in the ui is a
// stub. We need to show this slider despite the device_id_ not matching the
// active input node.
bool show_internal_stub = internal_ &&
(active_device && active_device->IsInternalMic()) &&
audio_handler->HasDualInternalMic();
if (audio_handler->GetPrimaryActiveInputNode() != device_id_ &&
!show_internal_stub) {
SetVisible(false); SetVisible(false);
return; return;
} }
SetVisible(true); SetVisible(true);
bool is_muted = CrasAudioHandler::Get()->IsInputMuted(); bool is_muted = audio_handler->IsInputMuted();
float level = CrasAudioHandler::Get()->GetInputGainPercent() / 100.f; float level = audio_handler->GetInputGainPercent() / 100.f;
// To indicate that the volume is muted, set the volume slider to the minimal // To indicate that the volume is muted, set the volume slider to the minimal
// visual style. // visual style.
slider()->SetRenderingStyle( slider()->SetRenderingStyle(
......
...@@ -15,7 +15,9 @@ class MicGainSliderController; ...@@ -15,7 +15,9 @@ class MicGainSliderController;
class MicGainSliderView : public UnifiedSliderView, class MicGainSliderView : public UnifiedSliderView,
public chromeos::CrasAudioHandler::AudioObserver { public chromeos::CrasAudioHandler::AudioObserver {
public: public:
MicGainSliderView(MicGainSliderController* controller, uint64_t device_id); MicGainSliderView(MicGainSliderController* controller,
uint64_t device_id,
bool internal);
~MicGainSliderView() override; ~MicGainSliderView() override;
uint64_t device_id() const { return device_id_; } uint64_t device_id() const { return device_id_; }
...@@ -33,6 +35,9 @@ class MicGainSliderView : public UnifiedSliderView, ...@@ -33,6 +35,9 @@ class MicGainSliderView : public UnifiedSliderView,
// device id for the input device tied to this slider. // device id for the input device tied to this slider.
const uint64_t device_id_; const uint64_t device_id_;
// True if the audio device this slider represents is internal.
const bool internal_;
}; };
} // namespace ash } // namespace ash
......
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