Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/arc/audio/arc_audio_bridge.h" | 5 #include "components/arc/audio/arc_audio_bridge.h" |
| 6 | 6 |
| 7 #include "ash/system/audio/tray_audio.h" | 7 #include "ash/system/audio/tray_audio.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chromeos/audio/audio_device.h" | 9 #include "chromeos/audio/audio_device.h" |
| 10 #include "components/arc/arc_bridge_service.h" | 10 #include "components/arc/arc_bridge_service.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->audio(), Init); | 32 ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->audio(), Init); |
| 33 DCHECK(audio_instance); // the instance on ARC side is too old. | 33 DCHECK(audio_instance); // the instance on ARC side is too old. |
| 34 audio_instance->Init(binding_.CreateInterfacePtrAndBind()); | 34 audio_instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void ArcAudioBridge::ShowVolumeControls() { | 37 void ArcAudioBridge::ShowVolumeControls() { |
| 38 DVLOG(2) << "ArcAudioBridge::ShowVolumeControls"; | 38 DVLOG(2) << "ArcAudioBridge::ShowVolumeControls"; |
| 39 ash::TrayAudio::ShowPopUpVolumeView(); | 39 ash::TrayAudio::ShowPopUpVolumeView(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void ArcAudioBridge::OnSystemVolumeUpdateRequest(int32_t percent) { | |
| 43 if (percent < 0 || percent > 100) | |
| 44 return; | |
| 45 cras_audio_handler_->SetOutputVolumePercent(percent); | |
| 46 bool is_muted = | |
| 47 percent <= cras_audio_handler_->GetOutputDefaultVolumeMuteThreshold(); | |
|
dcheng
2017/06/06 18:45:38
FWIW, it seems like this is already down in CrasAu
yueli
2017/06/06 20:01:40
IIUC SetOutputMute will change the device mute set
| |
| 48 if (cras_audio_handler_->IsOutputMuted() != is_muted) | |
| 49 cras_audio_handler_->SetOutputMute(is_muted); | |
| 50 } | |
| 51 | |
| 42 void ArcAudioBridge::OnAudioNodesChanged() { | 52 void ArcAudioBridge::OnAudioNodesChanged() { |
| 43 uint64_t output_id = cras_audio_handler_->GetPrimaryActiveOutputNode(); | 53 uint64_t output_id = cras_audio_handler_->GetPrimaryActiveOutputNode(); |
| 44 const chromeos::AudioDevice* output_device = | 54 const chromeos::AudioDevice* output_device = |
| 45 cras_audio_handler_->GetDeviceFromId(output_id); | 55 cras_audio_handler_->GetDeviceFromId(output_id); |
| 46 bool headphone_inserted = | 56 bool headphone_inserted = |
| 47 (output_device && | 57 (output_device && |
| 48 output_device->type == chromeos::AudioDeviceType::AUDIO_TYPE_HEADPHONE); | 58 output_device->type == chromeos::AudioDeviceType::AUDIO_TYPE_HEADPHONE); |
| 49 | 59 |
| 50 uint64_t input_id = cras_audio_handler_->GetPrimaryActiveInputNode(); | 60 uint64_t input_id = cras_audio_handler_->GetPrimaryActiveInputNode(); |
| 51 const chromeos::AudioDevice* input_device = | 61 const chromeos::AudioDevice* input_device = |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 102 |
| 93 void ArcAudioBridge::SendVolumeState() { | 103 void ArcAudioBridge::SendVolumeState() { |
| 94 DVLOG(1) << "Send volume " << volume_ << " muted " << muted_; | 104 DVLOG(1) << "Send volume " << volume_ << " muted " << muted_; |
| 95 mojom::AudioInstance* audio_instance = ARC_GET_INSTANCE_FOR_METHOD( | 105 mojom::AudioInstance* audio_instance = ARC_GET_INSTANCE_FOR_METHOD( |
| 96 arc_bridge_service()->audio(), NotifyVolumeState); | 106 arc_bridge_service()->audio(), NotifyVolumeState); |
| 97 if (audio_instance) | 107 if (audio_instance) |
| 98 audio_instance->NotifyVolumeState(volume_, muted_); | 108 audio_instance->NotifyVolumeState(volume_, muted_); |
| 99 } | 109 } |
| 100 | 110 |
| 101 } // namespace arc | 111 } // namespace arc |
| OLD | NEW |