Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: chromeos/audio/cras_audio_handler.cc

Issue 2190773002: Fix Volume slider is captured in screenshot done in touchview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable hiding animation; restoring volume does not notify UI Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chromeos/audio/cras_audio_handler.h" 5 #include "chromeos/audio/cras_audio_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 // Set all active devices to the same volume. 369 // Set all active devices to the same volume.
370 for (AudioDeviceMap::const_iterator it = audio_devices_.begin(); 370 for (AudioDeviceMap::const_iterator it = audio_devices_.begin();
371 it != audio_devices_.end(); 371 it != audio_devices_.end();
372 it++) { 372 it++) {
373 const AudioDevice& device = it->second; 373 const AudioDevice& device = it->second;
374 if (!device.is_input && device.active) 374 if (!device.is_input && device.active)
375 SetOutputNodeVolumePercent(device.id, volume_percent); 375 SetOutputNodeVolumePercent(device.id, volume_percent);
376 } 376 }
377 } 377 }
378 378
379 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.
380 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
381 // Set all active devices to the same volume.
382 for (AudioDeviceMap::const_iterator it = audio_devices_.begin();
383 it != audio_devices_.end(); it++) {
384 const AudioDevice& device = it->second;
385 if (!device.is_input && device.active)
386 SetOutputNodeVolumePercent(device.id, volume_percent);
387 }
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.
388 }
389
379 // TODO: Rename the 'Percent' to something more meaningful. 390 // TODO: Rename the 'Percent' to something more meaningful.
380 void CrasAudioHandler::SetInputGainPercent(int gain_percent) { 391 void CrasAudioHandler::SetInputGainPercent(int gain_percent) {
381 // TODO(jennyz): Should we set all input devices' gain to the same level? 392 // TODO(jennyz): Should we set all input devices' gain to the same level?
382 for (AudioDeviceMap::const_iterator it = audio_devices_.begin(); 393 for (AudioDeviceMap::const_iterator it = audio_devices_.begin();
383 it != audio_devices_.end(); 394 it != audio_devices_.end();
384 it++) { 395 it++) {
385 const AudioDevice& device = it->second; 396 const AudioDevice& device = it->second;
386 if (device.is_input && device.active) 397 if (device.is_input && device.active)
387 SetInputNodeGainPercent(active_input_node_id_, gain_percent); 398 SetInputNodeGainPercent(active_input_node_id_, gain_percent);
388 } 399 }
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 return; 636 return;
626 } else { 637 } else {
627 // Reset the initializing_audio_state_ in case SetOutputNodeVolume request 638 // Reset the initializing_audio_state_ in case SetOutputNodeVolume request
628 // is lost by cras due to cras is not ready when CrasAudioHandler is being 639 // is lost by cras due to cras is not ready when CrasAudioHandler is being
629 // initialized. 640 // initialized.
630 initializing_audio_state_ = false; 641 initializing_audio_state_ = false;
631 init_volume_count_ = 0; 642 init_volume_count_ = 0;
632 } 643 }
633 } 644 }
634 645
646 // Do not notify the observers for the volume changed event if that is
647 // initiated internally, not by users. For example, a volume restoring
648 // comes from maximize mode screenshot volume-down, power down accelerators.
649 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.
650 volume_internally_changed_ = false;
651 return;
652 }
653
635 FOR_EACH_OBSERVER(AudioObserver, observers_, 654 FOR_EACH_OBSERVER(AudioObserver, observers_,
636 OnOutputNodeVolumeChanged(node_id, volume)); 655 OnOutputNodeVolumeChanged(node_id, volume));
637 } 656 }
638 657
639 void CrasAudioHandler::ActiveOutputNodeChanged(uint64_t node_id) { 658 void CrasAudioHandler::ActiveOutputNodeChanged(uint64_t node_id) {
640 if (active_output_node_id_ == node_id) 659 if (active_output_node_id_ == node_id)
641 return; 660 return;
642 661
643 // Active audio output device should always be changed by chrome. 662 // Active audio output device should always be changed by chrome.
644 // During system boot, cras may change active input to unknown device 0x1, 663 // During system boot, cras may change active input to unknown device 0x1,
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 hdmi_rediscover_grace_period_duration_in_ms_), 1391 hdmi_rediscover_grace_period_duration_in_ms_),
1373 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); 1392 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod);
1374 } 1393 }
1375 1394
1376 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( 1395 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting(
1377 int duration_in_ms) { 1396 int duration_in_ms) {
1378 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; 1397 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms;
1379 } 1398 }
1380 1399
1381 } // namespace chromeos 1400 } // namespace chromeos
OLDNEW
« chromeos/audio/cras_audio_handler.h ('K') | « chromeos/audio/cras_audio_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698