diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-28 23:27:00 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-28 23:27:00 +0000 |
commit | 4a897672921049e8e2d6422c688a502ba30f8cd1 (patch) | |
tree | 86c16e5ede06f751aae258cc61f57c9776bd20a0 /chrome/browser/chromeos/audio_mixer.h | |
parent | 5bfe52255baf07910a03d48b686675741a15cb9b (diff) | |
download | chromium_src-4a897672921049e8e2d6422c688a502ba30f8cd1.zip chromium_src-4a897672921049e8e2d6422c688a502ba30f8cd1.tar.gz chromium_src-4a897672921049e8e2d6422c688a502ba30f8cd1.tar.bz2 |
chromeos: Simplify audio mixer code.
This cleans up the code that talks to ALSA. All changes are
now made asynchronously on a background thread. The volume
and muting states are now tracked separately, as well.
This makes it possible to make some requested changes to the
behavior of the volume keys. I'm hoping that there's also a
chance that it'll fix some related bugs that people have
been seeing, or at least make it easier to debug them.
BUG=chromium-os:17588,chromium-os:14058,chromium-os:13618,chromium-os:8473
TEST=manual: cleared audio prefs and made sure that reasonable defaults were used; pressed volume keys just after boot and checked that nothing happened; waited a few seconds more and started seeing volume bubble; checked that muting and going to min and max volume worked as expected
Review URL: http://codereview.chromium.org/7508006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94579 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/audio_mixer.h')
-rw-r--r-- | chrome/browser/chromeos/audio_mixer.h | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/chrome/browser/chromeos/audio_mixer.h b/chrome/browser/chromeos/audio_mixer.h index f936c7c..3187ed5 100644 --- a/chrome/browser/chromeos/audio_mixer.h +++ b/chrome/browser/chromeos/audio_mixer.h @@ -13,49 +13,38 @@ namespace chromeos { class AudioMixer { public: - // Approximation of pure silence expressed in decibels. - static const double kSilenceDb; - - enum State { - UNINITIALIZED = 0, - INITIALIZING, - READY, - SHUTTING_DOWN, - IN_ERROR, - }; - AudioMixer() {} virtual ~AudioMixer() {} - // Non-Blocking call. Connect to Mixer, find a default device, then call the - // callback when complete with success code. - typedef Callback1<bool>::Type InitDoneCallback; - virtual void Init(InitDoneCallback* callback) = 0; + // Initializes the connection to the device. This must be called on the UI + // thread; blocking tasks may take place in the background. IsInitialized() + // may be called to check if initialization is done. + virtual void Init() = 0; - // Call may block. Mixer will be connected before returning, unless error. - virtual bool InitSync() = 0; + // Returns true if device initialization is complete. + virtual bool IsInitialized() = 0; - // Call may block. Returns a default of kSilenceDb on error. - virtual double GetVolumeDb() const = 0; + // Returns the actual volume range available, according to the mixer. + // Values will be incorrect if called before initialization is complete. + virtual void GetVolumeLimits(double* min_volume_db, + double* max_volume_db) = 0; - // Non-Blocking call. Returns the actual volume limits possible according - // to the mixer. Limits are left unchanged on error - virtual bool GetVolumeLimits(double* vol_min, double* vol_max) = 0; + // Gets the most-recently-set volume, in decibels. + virtual double GetVolumeDb() = 0; - // Non-blocking call. - virtual void SetVolumeDb(double vol_db) = 0; + // Sets the volume, in decibels. + // If initialization is still in progress, the value will be applied once + // initialization is complete. + virtual void SetVolumeDb(double volume_db) = 0; - // Call may block. Gets the mute state of the default device (true == mute). - // Returns a default of false on error. - virtual bool IsMute() const = 0; + // Gets the most-recently set mute state of the default device (true means + // muted). + virtual bool IsMuted() = 0; - // Non-Blocking call. - virtual void SetMute(bool mute) = 0; - - // Returns READY if we have a valid working connection to the Mixer. - // This can return IN_ERROR if we lose the connection, even after an original - // successful init. Non-blocking call. - virtual State GetState() const = 0; + // Sets the mute state of the default device. + // If initialization is still in progress, the value will be applied once + // initialization is complete. + virtual void SetMuted(bool mute) = 0; private: DISALLOW_COPY_AND_ASSIGN(AudioMixer); @@ -64,4 +53,3 @@ class AudioMixer { } // namespace chromeos #endif // CHROME_BROWSER_CHROMEOS_AUDIO_MIXER_H_ - |