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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/audio/cras_audio_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/audio/cras_audio_handler.cc
diff --git a/chromeos/audio/cras_audio_handler.cc b/chromeos/audio/cras_audio_handler.cc
index 64e4271b3d1bb3c714861f07f9ffaf90c4fa383f..456ce6cc54414a3d9f937324eb8f8dd1988c5456 100644
--- a/chromeos/audio/cras_audio_handler.cc
+++ b/chromeos/audio/cras_audio_handler.cc
@@ -613,14 +613,22 @@ void CrasAudioHandler::OutputNodeVolumeChanged(uint64_t node_id, int volume) {
audio_pref_handler_->SetVolumeGainValue(*device, volume);
if (initializing_audio_state_) {
- // Reset the flag after the first OutputNodeVolumeChanged, just in case
- // cras didn't respond to the initial SetOutputNodeVolume request.
- initializing_audio_state_ = false;
// Do not notify the observers for volume changed event if CrasAudioHandler
- // is initializing its state, i.e., the volume change event is not from
- // user action, no need to notify UI to pop uo the volume slider bar.
- if (init_node_id_ == node_id && init_volume_ == volume)
+ // is initializing its state, i.e., the volume change event is in responding
+ // to SetOutputNodeVolume request from intializaing audio state, not
+ // from user action, no need to notify UI to pop uo the volume slider bar.
+ if (init_node_id_ == node_id && init_volume_ == volume) {
+ init_volume_count_--;
+ if (!init_volume_count_)
+ initializing_audio_state_ = false;
return;
+ } else {
+ // Reset the initializing_audio_state_ in case SetOutputNodeVolume request
+ // is lost by cras due to cras is not ready when CrasAudioHandler is being
+ // initialized.
+ initializing_audio_state_ = false;
+ init_volume_count_ = 0;
+ }
}
FOR_EACH_OBSERVER(AudioObserver, observers_,
@@ -730,6 +738,11 @@ void CrasAudioHandler::SetupAudioOutputState() {
SetOutputMuteInternal(output_mute_on_);
if (initializing_audio_state_) {
+ // During power up, InitializeAudioState() could be called twice, first
+ // by CrasAudioHandler constructor, then by cras server restarting signal,
+ // both sending SetOutputNodeVolume requests, and could lead to two
+ // OutputNodeVolumeChanged signals.
+ init_volume_count_++;
init_node_id_ = active_output_node_id_;
init_volume_ = output_volume_;
}
« 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