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/common/system/chromeos/audio/tray_audio.h" | 7 #include "ash/common/system/chromeos/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::OnVolumeUpdateRequest(float volume) { | |
| 43 cras_audio_handler_->SetOutputVolumePercent(volume); | |
|
dcheng
2017/04/14 03:36:42
This should check that the input is in range.
(Ou
yueli
2017/06/02 19:10:13
It seems the range is already handled in SetOutput
dcheng
2017/06/02 23:25:35
This is OK, but I will note that it makes it a bit
yueli
2017/06/06 16:43:09
Done.
| |
| 44 bool is_muted = | |
| 45 volume <= cras_audio_handler_->GetOutputDefaultVolumeMuteThreshold(); | |
| 46 if (cras_audio_handler_->IsOutputMuted() != is_muted) | |
| 47 cras_audio_handler_->SetOutputMute(is_muted); | |
| 48 } | |
| 49 | |
| 42 void ArcAudioBridge::OnAudioNodesChanged() { | 50 void ArcAudioBridge::OnAudioNodesChanged() { |
| 43 uint64_t output_id = cras_audio_handler_->GetPrimaryActiveOutputNode(); | 51 uint64_t output_id = cras_audio_handler_->GetPrimaryActiveOutputNode(); |
| 44 const chromeos::AudioDevice* output_device = | 52 const chromeos::AudioDevice* output_device = |
| 45 cras_audio_handler_->GetDeviceFromId(output_id); | 53 cras_audio_handler_->GetDeviceFromId(output_id); |
| 46 bool headphone_inserted = | 54 bool headphone_inserted = |
| 47 (output_device && | 55 (output_device && |
| 48 output_device->type == chromeos::AudioDeviceType::AUDIO_TYPE_HEADPHONE); | 56 output_device->type == chromeos::AudioDeviceType::AUDIO_TYPE_HEADPHONE); |
| 49 | 57 |
| 50 uint64_t input_id = cras_audio_handler_->GetPrimaryActiveInputNode(); | 58 uint64_t input_id = cras_audio_handler_->GetPrimaryActiveInputNode(); |
| 51 const chromeos::AudioDevice* input_device = | 59 const chromeos::AudioDevice* input_device = |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 100 |
| 93 void ArcAudioBridge::SendVolumeState() { | 101 void ArcAudioBridge::SendVolumeState() { |
| 94 DVLOG(1) << "Send volume " << volume_ << " muted " << muted_; | 102 DVLOG(1) << "Send volume " << volume_ << " muted " << muted_; |
| 95 mojom::AudioInstance* audio_instance = ARC_GET_INSTANCE_FOR_METHOD( | 103 mojom::AudioInstance* audio_instance = ARC_GET_INSTANCE_FOR_METHOD( |
| 96 arc_bridge_service()->audio(), NotifyVolumeState); | 104 arc_bridge_service()->audio(), NotifyVolumeState); |
| 97 if (audio_instance) | 105 if (audio_instance) |
| 98 audio_instance->NotifyVolumeState(volume_, muted_); | 106 audio_instance->NotifyVolumeState(volume_, muted_); |
| 99 } | 107 } |
| 100 | 108 |
| 101 } // namespace arc | 109 } // namespace arc |
| OLD | NEW |