Index: chromeos/audio/cras_audio_handler.cc |
diff --git a/chromeos/audio/cras_audio_handler.cc b/chromeos/audio/cras_audio_handler.cc |
index a8f8036134ead71310d5a6748f4230045971f1f3..084a18aeba7a53127671baa76af8cc8c76b0b2b2 100644 |
--- a/chromeos/audio/cras_audio_handler.cc |
+++ b/chromeos/audio/cras_audio_handler.cc |
@@ -376,6 +376,17 @@ void CrasAudioHandler::SetOutputVolumePercent(int volume_percent) { |
} |
} |
+void CrasAudioHandler::SetOutputVolumePercentInternally(int volume_percent) { |
jennyz
2016/07/28 21:10:05
Please add a unit test for this new API.
Qiang(Joe) Xu
2016/07/28 23:15:57
Done.
|
+ volume_internally_changed_ = true; |
jennyz
2016/07/28 21:02:17
Will it be possible for SetOutputVolumePercentInte
Qiang(Joe) Xu
2016/07/28 23:15:57
Currently only maximize mode screenshot calls this
|
+ // Set all active devices to the same volume. |
+ for (AudioDeviceMap::const_iterator it = audio_devices_.begin(); |
+ it != audio_devices_.end(); it++) { |
+ const AudioDevice& device = it->second; |
+ if (!device.is_input && device.active) |
+ SetOutputNodeVolumePercent(device.id, volume_percent); |
+ } |
jennyz
2016/07/28 21:02:17
line 381-387 is the same as SetOutputVolumePercent
Qiang(Joe) Xu
2016/07/28 23:15:57
Done.
|
+} |
+ |
// TODO: Rename the 'Percent' to something more meaningful. |
void CrasAudioHandler::SetInputGainPercent(int gain_percent) { |
// TODO(jennyz): Should we set all input devices' gain to the same level? |
@@ -632,6 +643,14 @@ void CrasAudioHandler::OutputNodeVolumeChanged(uint64_t node_id, int volume) { |
} |
} |
+ // Do not notify the observers for the volume changed event if that is |
+ // initiated internally, not by users. For example, a volume restoring |
+ // comes from maximize mode screenshot volume-down, power down accelerators. |
+ if (volume_internally_changed_) { |
jennyz
2016/07/28 21:02:17
volume_internally_changed_ is similar to initializ
Qiang(Joe) Xu
2016/07/28 23:15:57
I use a mask to merge them.
|
+ volume_internally_changed_ = false; |
+ return; |
+ } |
+ |
FOR_EACH_OBSERVER(AudioObserver, observers_, |
OnOutputNodeVolumeChanged(node_id, volume)); |
} |