summaryrefslogtreecommitdiffstats
path: root/chromeos/audio
diff options
context:
space:
mode:
authorjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 04:54:59 +0000
committerjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 04:54:59 +0000
commitefa21732316bf5bdea2baa97ce220373b5a1f524 (patch)
tree1f787722159c8614c4b46337fe9844f5a14f27bf /chromeos/audio
parent8468d2885dd17bb1837b589d6b3719d23d3160ba (diff)
downloadchromium_src-efa21732316bf5bdea2baa97ce220373b5a1f524.zip
chromium_src-efa21732316bf5bdea2baa97ce220373b5a1f524.tar.gz
chromium_src-efa21732316bf5bdea2baa97ce220373b5a1f524.tar.bz2
Fix the volume bubble pop up on device reboot issue. Fix the volume bubble pop up on device reboot issue. The problem is caused by CrasAudioHandler::SetupAudioOutput made 2 SetOutputVolume consecutively, the 1st one set volume to 4 which is from SetOutputMute for adjusting minimum volume level when user clicks unmute button and should not be called from here, and the other set volume to the default or saved volume by user to a regular default or saved volume level which may not be 4. The callback of the first volume setting(volume 4) comes back and unmatched the internal volume level and therefore triggers the UI observer for volume change.
Also separate ApplyAudioPolicy out of SetupAudioOutputState and SetupAudioInputState which are called by callback of GetNodes. ApplyAudioPolicy only needs to be called for initialization, cras restart, and policy change notified. BUG=241816 Review URL: https://chromiumcodereview.appspot.com/15746012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201701 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/audio')
-rw-r--r--chromeos/audio/cras_audio_handler.cc49
-rw-r--r--chromeos/audio/cras_audio_handler.h9
2 files changed, 38 insertions, 20 deletions
diff --git a/chromeos/audio/cras_audio_handler.cc b/chromeos/audio/cras_audio_handler.cc
index 0e4b26f..1088333 100644
--- a/chromeos/audio/cras_audio_handler.cc
+++ b/chromeos/audio/cras_audio_handler.cc
@@ -193,21 +193,30 @@ void CrasAudioHandler::AdjustOutputVolumeByPercent(int adjust_by_percent) {
}
void CrasAudioHandler::SetOutputMute(bool mute_on) {
- if (output_mute_locked_)
+ if (!SetOutputMuteInternal(mute_on))
+ return;
+
+ if (mute_on)
return;
+ // Adjust volume level if user unmute the device and makes sure the volume
+ // is set to a minimum audible level.
+ if (output_volume_ <= kMuteThresholdPercent) {
+ // Avoid the situation when sound has been unmuted, but the volume
+ // is set to a very low value, so user still can't hear any sound.
+ SetOutputVolumeInternal(kDefaultUnmuteVolumePercent);
+ }
+}
+
+bool CrasAudioHandler::SetOutputMuteInternal(bool mute_on) {
+ if (output_mute_locked_)
+ return false;
+
output_mute_on_ = mute_on;
audio_pref_handler_->SetMuteValue(active_output_node_id_, mute_on);
chromeos::DBusThreadManager::Get()->GetCrasAudioClient()->
SetOutputMute(mute_on);
-
- if (!mute_on) {
- if (output_volume_ <= kMuteThresholdPercent) {
- // Avoid the situation when sound has been unmuted, but the volume
- // is set to a very low value, so user still can't hear any sound.
- SetOutputVolumeInternal(kDefaultUnmuteVolumePercent);
- }
- }
+ return true;
}
void CrasAudioHandler::SetInputMute(bool mute_on) {
@@ -282,7 +291,7 @@ CrasAudioHandler::CrasAudioHandler(
return;
chromeos::DBusThreadManager::Get()->GetCrasAudioClient()->AddObserver(this);
audio_pref_handler_->AddAudioPrefObserver(this);
- GetNodes();
+ InitializeAudioState();
}
CrasAudioHandler::~CrasAudioHandler() {
@@ -298,7 +307,7 @@ CrasAudioHandler::~CrasAudioHandler() {
}
void CrasAudioHandler::AudioClientRestarted() {
- GetNodes();
+ InitializeAudioState();
}
void CrasAudioHandler::OutputVolumeChanged(int volume) {
@@ -367,8 +376,6 @@ void CrasAudioHandler::OnAudioPolicyPrefChanged() {
}
void CrasAudioHandler::SetupAudioInputState() {
- ApplyAudioPolicy();
-
// Set the initial audio state to the ones read from audio prefs.
if (active_input_node_id_) {
input_mute_on_ = audio_pref_handler_->GetMuteValue(active_input_node_id_);
@@ -383,18 +390,22 @@ void CrasAudioHandler::SetupAudioInputState() {
}
void CrasAudioHandler::SetupAudioOutputState() {
- ApplyAudioPolicy();
-
if (active_output_node_id_) {
output_mute_on_ = audio_pref_handler_->GetMuteValue(active_output_node_id_);
output_volume_ = audio_pref_handler_->GetVolumeGainValue(
active_output_node_id_);
- SetOutputMute(output_mute_on_);
- SetOutputVolumeInternal(output_volume_);
} else {
- SetOutputMute(kPrefMuteOff);
- SetOutputVolumeInternal(kDefaultVolumeGainPercent);
+ output_mute_on_ = kPrefMuteOff;
+ output_volume_ = kDefaultVolumeGainPercent;
}
+
+ SetOutputMuteInternal(output_mute_on_);
+ SetOutputVolumeInternal(output_volume_);
+}
+
+void CrasAudioHandler::InitializeAudioState() {
+ ApplyAudioPolicy();
+ GetNodes();
}
void CrasAudioHandler::ApplyAudioPolicy() {
diff --git a/chromeos/audio/cras_audio_handler.h b/chromeos/audio/cras_audio_handler.h
index d7449de..54afeb8 100644
--- a/chromeos/audio/cras_audio_handler.h
+++ b/chromeos/audio/cras_audio_handler.h
@@ -187,13 +187,20 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer,
void SetupAudioInputState();
void SetupAudioOutputState();
+ // Initializes audio state, which should only be called when CrasAudioHandler
+ // is created or cras audio client is restarted.
+ void InitializeAudioState();
+
// Applies the audio muting policies whenever the user logs in or policy
// change notification is received.
void ApplyAudioPolicy();
- // Sets output volume to specified value and notifies observers.
+ // Sets output volume to specified value of |volume|.
void SetOutputVolumeInternal(int volume);
+ // Sets output mute state to |mute_on|.
+ bool SetOutputMuteInternal(bool mute_on);
+
// Sets output volume to specified value and notifies observers.
void SetInputGainInternal(int gain);