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

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

Issue 9169033: Support for showing/hiding status area volume controls in desktop devices (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 8 years, 11 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 | « chrome/browser/chromeos/audio/audio_handler.h ('k') | chrome/browser/chromeos/status/volume_menu_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/audio/audio_handler.cc
===================================================================
--- chrome/browser/chromeos/audio/audio_handler.cc (revision 119932)
+++ chrome/browser/chromeos/audio/audio_handler.cc (working copy)
@@ -49,8 +49,10 @@
return g_audio_handler;
}
-bool AudioHandler::IsInitialized() {
- return mixer_->IsInitialized();
+// static
+AudioHandler* AudioHandler::GetInstanceIfInitialized() {
+ return g_audio_handler && g_audio_handler->IsMixerInitialized() ?
+ g_audio_handler : NULL;
}
double AudioHandler::GetVolumePercent() {
@@ -60,6 +62,7 @@
void AudioHandler::SetVolumePercent(double volume_percent) {
volume_percent = min(max(volume_percent, 0.0), 100.0);
mixer_->SetVolumeDb(PercentToVolumeDb(volume_percent));
+ FOR_EACH_OBSERVER(VolumeObserver, volume_observers_, OnVolumeChanged());
}
void AudioHandler::AdjustVolumeByPercent(double adjust_by_percent) {
@@ -74,8 +77,17 @@
void AudioHandler::SetMuted(bool mute) {
mixer_->SetMuted(mute);
+ FOR_EACH_OBSERVER(VolumeObserver, volume_observers_, OnVolumeChanged());
}
+void AudioHandler::AddVolumeObserver(VolumeObserver* observer) {
+ volume_observers_.AddObserver(observer);
+}
+
+void AudioHandler::RemoveVolumeObserver(VolumeObserver* observer) {
+ volume_observers_.RemoveObserver(observer);
+}
+
AudioHandler::AudioHandler()
: mixer_(new AudioMixerAlsa()) {
mixer_->Init();
@@ -85,6 +97,10 @@
mixer_.reset();
};
+bool AudioHandler::IsMixerInitialized() {
+ return mixer_->IsInitialized();
+}
+
// VolumeDbToPercent() and PercentToVolumeDb() conversion functions allow us
// complete control over how the 0 to 100% range is mapped to actual loudness.
//
« no previous file with comments | « chrome/browser/chromeos/audio/audio_handler.h ('k') | chrome/browser/chromeos/status/volume_menu_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698