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

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

Issue 2250963003: Count the SetOutputNodeVolume requests sent during the audio initialization and track them with the… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: 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
« no previous file with comments | « chromeos/audio/cras_audio_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 606
607 // Sync internal volume state and notify UI for the change. We trust cras 607 // Sync internal volume state and notify UI for the change. We trust cras
608 // signal to report the volume state of the device, no matter which source 608 // signal to report the volume state of the device, no matter which source
609 // set the volume, i.e., volume could be set from non-chrome source, like 609 // set the volume, i.e., volume could be set from non-chrome source, like
610 // Bluetooth headset, etc. Assume all active output devices share a single 610 // Bluetooth headset, etc. Assume all active output devices share a single
611 // volume. 611 // volume.
612 output_volume_ = volume; 612 output_volume_ = volume;
613 audio_pref_handler_->SetVolumeGainValue(*device, volume); 613 audio_pref_handler_->SetVolumeGainValue(*device, volume);
614 614
615 if (initializing_audio_state_) { 615 if (initializing_audio_state_) {
616 // Reset the flag after the first OutputNodeVolumeChanged, just in case
617 // cras didn't respond to the initial SetOutputNodeVolume request.
618 initializing_audio_state_ = false;
619 // Do not notify the observers for volume changed event if CrasAudioHandler 616 // Do not notify the observers for volume changed event if CrasAudioHandler
620 // is initializing its state, i.e., the volume change event is not from 617 // is initializing its state, i.e., the volume change event is in responding
621 // user action, no need to notify UI to pop uo the volume slider bar. 618 // to SetOutputNodeVolume request from intializaing audio state, not
622 if (init_node_id_ == node_id && init_volume_ == volume) 619 // from user action, no need to notify UI to pop uo the volume slider bar.
620 if (init_node_id_ == node_id && init_volume_ == volume) {
621 init_volume_count_--;
622 if (!init_volume_count_)
623 initializing_audio_state_ = false;
623 return; 624 return;
625 } else {
626 // Reset the initializing_audio_state_ in case SetOutputNodeVolume request
627 // is lost by cras due to cras is not ready when CrasAudioHandler is being
628 // initialized.
629 initializing_audio_state_ = false;
630 init_volume_count_ = 0;
631 }
624 } 632 }
625 633
626 FOR_EACH_OBSERVER(AudioObserver, observers_, 634 FOR_EACH_OBSERVER(AudioObserver, observers_,
627 OnOutputNodeVolumeChanged(node_id, volume)); 635 OnOutputNodeVolumeChanged(node_id, volume));
628 } 636 }
629 637
630 void CrasAudioHandler::ActiveOutputNodeChanged(uint64_t node_id) { 638 void CrasAudioHandler::ActiveOutputNodeChanged(uint64_t node_id) {
631 if (active_output_node_id_ == node_id) 639 if (active_output_node_id_ == node_id)
632 return; 640 return;
633 641
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 VLOG(1) << "Mute the output during HDMI re-discovering grace period"; 731 VLOG(1) << "Mute the output during HDMI re-discovering grace period";
724 output_mute_on_ = true; 732 output_mute_on_ = true;
725 } else { 733 } else {
726 output_mute_on_ = audio_pref_handler_->GetMuteValue(*device); 734 output_mute_on_ = audio_pref_handler_->GetMuteValue(*device);
727 } 735 }
728 output_volume_ = audio_pref_handler_->GetOutputVolumeValue(device); 736 output_volume_ = audio_pref_handler_->GetOutputVolumeValue(device);
729 737
730 SetOutputMuteInternal(output_mute_on_); 738 SetOutputMuteInternal(output_mute_on_);
731 739
732 if (initializing_audio_state_) { 740 if (initializing_audio_state_) {
741 // During power up, InitializeAudioState() could be called twice, first
742 // by CrasAudioHandler constructor, then by cras server restarting signal,
743 // both sending SetOutputNodeVolume requests, and could lead to two
744 // OutputNodeVolumeChanged signals.
745 init_volume_count_++;
733 init_node_id_ = active_output_node_id_; 746 init_node_id_ = active_output_node_id_;
734 init_volume_ = output_volume_; 747 init_volume_ = output_volume_;
735 } 748 }
736 SetOutputNodeVolume(active_output_node_id_, output_volume_); 749 SetOutputNodeVolume(active_output_node_id_, output_volume_);
737 } 750 }
738 751
739 // This sets up the state of an additional active node. 752 // This sets up the state of an additional active node.
740 void CrasAudioHandler::SetupAdditionalActiveAudioNodeState(uint64_t node_id) { 753 void CrasAudioHandler::SetupAdditionalActiveAudioNodeState(uint64_t node_id) {
741 const AudioDevice* device = GetDeviceFromId(node_id); 754 const AudioDevice* device = GetDeviceFromId(node_id);
742 if (!device) { 755 if (!device) {
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 hdmi_rediscover_grace_period_duration_in_ms_), 1359 hdmi_rediscover_grace_period_duration_in_ms_),
1347 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); 1360 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod);
1348 } 1361 }
1349 1362
1350 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( 1363 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting(
1351 int duration_in_ms) { 1364 int duration_in_ms) {
1352 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; 1365 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms;
1353 } 1366 }
1354 1367
1355 } // namespace chromeos 1368 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/audio/cras_audio_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698