| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/system/chromeos/audio/audio_detailed_view.h" | 5 #include "ash/common/system/chromeos/audio/audio_detailed_view.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/strings/grit/ash_strings.h" | 8 #include "ash/common/strings/grit/ash_strings.h" |
| 9 #include "ash/common/system/tray/hover_highlight_view.h" | 9 #include "ash/common/system/tray/hover_highlight_view.h" |
| 10 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 void AudioDetailedView::CreateItems() { | 161 void AudioDetailedView::CreateItems() { |
| 162 CreateScrollableList(); | 162 CreateScrollableList(); |
| 163 CreateTitleRow(IDS_ASH_STATUS_TRAY_AUDIO); | 163 CreateTitleRow(IDS_ASH_STATUS_TRAY_AUDIO); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void AudioDetailedView::UpdateAudioDevices() { | 166 void AudioDetailedView::UpdateAudioDevices() { |
| 167 output_devices_.clear(); | 167 output_devices_.clear(); |
| 168 input_devices_.clear(); | 168 input_devices_.clear(); |
| 169 chromeos::AudioDeviceList devices; | 169 chromeos::AudioDeviceList devices; |
| 170 CrasAudioHandler::Get()->GetAudioDevices(&devices); | 170 CrasAudioHandler* audio_handler = CrasAudioHandler::Get(); |
| 171 audio_handler->GetAudioDevices(&devices); |
| 172 bool has_dual_internal_mic = audio_handler->HasDualInternalMic(); |
| 173 bool is_front_or_rear_mic_active = false; |
| 171 for (size_t i = 0; i < devices.size(); ++i) { | 174 for (size_t i = 0; i < devices.size(); ++i) { |
| 172 // Don't display keyboard mic or aokr type. | 175 // Don't display keyboard mic or aokr type. |
| 173 if (!devices[i].is_for_simple_usage()) | 176 if (!devices[i].is_for_simple_usage()) |
| 174 continue; | 177 continue; |
| 175 if (devices[i].is_input) | 178 if (devices[i].is_input) { |
| 179 // Do not expose the internal front and rear mic to UI. |
| 180 if (has_dual_internal_mic && |
| 181 audio_handler->IsFrontOrRearMic(devices[i])) { |
| 182 if (devices[i].active) |
| 183 is_front_or_rear_mic_active = true; |
| 184 continue; |
| 185 } |
| 176 input_devices_.push_back(devices[i]); | 186 input_devices_.push_back(devices[i]); |
| 177 else | 187 } else { |
| 178 output_devices_.push_back(devices[i]); | 188 output_devices_.push_back(devices[i]); |
| 189 } |
| 179 } | 190 } |
| 191 |
| 192 // Expose the dual internal mics as one device (internal mic) to user. |
| 193 if (has_dual_internal_mic) { |
| 194 // Create stub internal mic entry for UI rendering, which representing |
| 195 // both internal front and rear mics. |
| 196 chromeos::AudioDevice internal_mic; |
| 197 internal_mic.is_input = true; |
| 198 internal_mic.stable_device_id_version = 2; |
| 199 internal_mic.type = chromeos::AUDIO_TYPE_INTERNAL_MIC; |
| 200 internal_mic.active = is_front_or_rear_mic_active; |
| 201 input_devices_.push_back(internal_mic); |
| 202 } |
| 203 |
| 180 UpdateScrollableList(); | 204 UpdateScrollableList(); |
| 181 } | 205 } |
| 182 | 206 |
| 183 void AudioDetailedView::UpdateScrollableList() { | 207 void AudioDetailedView::UpdateScrollableList() { |
| 184 scroll_content()->RemoveAllChildViews(true); | 208 scroll_content()->RemoveAllChildViews(true); |
| 185 device_map_.clear(); | 209 device_map_.clear(); |
| 186 | 210 |
| 187 // Add audio output devices. | 211 // Add audio output devices. |
| 188 const bool use_md = MaterialDesignController::IsSystemTrayMenuMaterial(); | 212 const bool use_md = MaterialDesignController::IsSystemTrayMenuMaterial(); |
| 189 const bool has_output_devices = output_devices_.size() > 0; | 213 const bool has_output_devices = output_devices_.size() > 0; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 218 | 242 |
| 219 scroll_content()->SizeToPreferredSize(); | 243 scroll_content()->SizeToPreferredSize(); |
| 220 scroller()->Layout(); | 244 scroller()->Layout(); |
| 221 } | 245 } |
| 222 | 246 |
| 223 void AudioDetailedView::HandleViewClicked(views::View* view) { | 247 void AudioDetailedView::HandleViewClicked(views::View* view) { |
| 224 AudioDeviceMap::iterator iter = device_map_.find(view); | 248 AudioDeviceMap::iterator iter = device_map_.find(view); |
| 225 if (iter == device_map_.end()) | 249 if (iter == device_map_.end()) |
| 226 return; | 250 return; |
| 227 chromeos::AudioDevice device = iter->second; | 251 chromeos::AudioDevice device = iter->second; |
| 228 CrasAudioHandler::Get()->SwitchToDevice(device, true, | 252 CrasAudioHandler* audio_handler = CrasAudioHandler::Get(); |
| 229 CrasAudioHandler::ACTIVATE_BY_USER); | 253 if (device.type == chromeos::AUDIO_TYPE_INTERNAL_MIC && |
| 254 audio_handler->HasDualInternalMic()) { |
| 255 audio_handler->SwitchToFrontOrRearMic(); |
| 256 } else { |
| 257 audio_handler->SwitchToDevice(device, true, |
| 258 CrasAudioHandler::ACTIVATE_BY_USER); |
| 259 } |
| 230 } | 260 } |
| 231 | 261 |
| 232 } // namespace tray | 262 } // namespace tray |
| 233 } // namespace ash | 263 } // namespace ash |
| OLD | NEW |