Chromium Code Reviews| Index: chrome/browser/chromeos/audio/audio_handler.h |
| =================================================================== |
| --- chrome/browser/chromeos/audio/audio_handler.h (revision 119229) |
| +++ chrome/browser/chromeos/audio/audio_handler.h (working copy) |
| @@ -7,6 +7,7 @@ |
| #pragma once |
| #include "base/basictypes.h" |
| +#include "base/observer_list.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/threading/thread.h" |
| @@ -18,17 +19,28 @@ |
| class AudioHandler { |
| public: |
| + class VolumeObserver { |
| + public: |
| + virtual void OnVolumeChanged() = 0; |
| + protected: |
| + // VolumeObserver registers/de-registers itself with AudioHandler in the |
| + // ctor/dtor. |
| + VolumeObserver(); |
| + virtual ~VolumeObserver(); |
| + }; |
| + |
| static void Initialize(); |
| static void Shutdown(); |
| // GetInstance returns NULL if not initialized or if already shutdown. |
|
Daniel Erat
2012/01/27 18:03:57
not your fault, but mind updating this comment to
achuithb
2012/01/31 00:58:43
Done.
|
| static AudioHandler* GetInstance(); |
| - // Is the mixer initialized? |
| + // GetInstanceIfInitialized returns NULL if GetInstance returns NULL or if |
| + // the mixer has not finished initializing. |
| // TODO(derat): All of the volume-percent methods will produce "interesting" |
| // results before the mixer is initialized, since the driver's volume range |
| // isn't known at that point. This could be avoided if AudioMixer objects |
| // instead took percentages and did their own conversions to decibels. |
| - bool IsInitialized(); |
| + static AudioHandler* GetInstanceIfInitialized(); |
| // Gets volume level in our internal 0-100% range, 0 being pure silence. |
| double GetVolumePercent(); |
| @@ -49,16 +61,24 @@ |
| // Defines the delete on exit Singleton traits we like. Best to have this |
| // and constructor/destructor private as recommended for Singletons. |
| friend struct DefaultSingletonTraits<AudioHandler>; |
| + friend class VolumeObserver; |
| AudioHandler(); |
| virtual ~AudioHandler(); |
| + bool IsMixerInitialized(); |
| + |
| // Conversion between our internal scaling (0-100%) and decibels. |
| double VolumeDbToPercent(double volume_db) const; |
| double PercentToVolumeDb(double volume_percent) const; |
| + void AddVolumeObserver(VolumeObserver* observer); |
| + void RemoveVolumeObserver(VolumeObserver* observer); |
| + |
| scoped_ptr<AudioMixer> mixer_; |
| + ObserverList<VolumeObserver> volume_observers_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(AudioHandler); |
| }; |