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

Unified Diff: chrome/browser/chromeos/audio/audio_handler.cc

Issue 10411028: Fix the volume controlling behaviors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
Index: chrome/browser/chromeos/audio/audio_handler.cc
diff --git a/chrome/browser/chromeos/audio/audio_handler.cc b/chrome/browser/chromeos/audio/audio_handler.cc
index fc4316294856cd3cb0be3743980e9e9aedff8dda..04b4494bd59359d9f8e885b454f0ed4ed588b777 100644
--- a/chrome/browser/chromeos/audio/audio_handler.cc
+++ b/chrome/browser/chromeos/audio/audio_handler.cc
@@ -40,7 +40,11 @@ static AudioHandler* g_audio_handler = NULL;
// static
void AudioHandler::Initialize() {
CHECK(!g_audio_handler);
- g_audio_handler = new AudioHandler();
+#if defined(USE_CRAS)
+ g_audio_handler = new AudioHandler(new AudioMixerCras());
+#else
+ g_audio_handler = new AudioHandler(new AudioMixerAlsa());
+#endif
}
// static
@@ -53,6 +57,12 @@ void AudioHandler::Shutdown() {
}
// static
+void AudioHandler::InitializeForTesting(AudioMixer* mixer) {
+ CHECK(!g_audio_handler);
+ g_audio_handler = new AudioHandler(mixer);
+}
+
+// static
AudioHandler* AudioHandler::GetInstance() {
VLOG_IF(1, !g_audio_handler)
<< "AudioHandler::GetInstance() called with NULL global instance.";
@@ -81,7 +91,7 @@ void AudioHandler::RegisterPrefs(PrefService* local_state) {
}
double AudioHandler::GetVolumePercent() {
- return mixer_->GetVolumePercent();
+ return (mixer_->IsMuted()) ? 0.0 : mixer_->GetVolumePercent();
Daniel Erat 2012/05/18 23:45:13 I don't think that this UX decision should be refl
Jun Mukai 2012/05/18 23:53:19 Removed. I will make the UI change in another CL.
}
void AudioHandler::SetVolumePercent(double volume_percent) {
@@ -96,7 +106,7 @@ void AudioHandler::AdjustVolumeByPercent(double adjust_by_percent) {
}
bool AudioHandler::IsMuted() {
- return mixer_->IsMuted();
+ return mixer_->GetVolumePercent() == 0 || mixer_->IsMuted();
Daniel Erat 2012/05/18 23:45:13 ditto here
Jun Mukai 2012/05/18 23:53:19 Removed too.
}
void AudioHandler::SetMuted(bool mute) {
@@ -113,12 +123,8 @@ void AudioHandler::RemoveVolumeObserver(VolumeObserver* observer) {
volume_observers_.RemoveObserver(observer);
}
-AudioHandler::AudioHandler()
-#if defined(USE_CRAS)
- : mixer_(new AudioMixerCras()),
-#else
- : mixer_(new AudioMixerAlsa()),
-#endif
+AudioHandler::AudioHandler(AudioMixer* mixer)
+ : mixer_(mixer),
prefs_(g_browser_process->local_state()) {
mixer_->SetVolumePercent(prefs_->GetDouble(prefs::kAudioVolumePercent));
mixer_->SetMuted(prefs_->GetInteger(prefs::kAudioMute) == kPrefMuteOn);

Powered by Google App Engine
This is Rietveld 408576698