| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "base/prefs/public/pref_change_registrar.h" | 11 #include "base/prefs/public/pref_change_registrar.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 | 13 |
| 14 template <typename T> struct DefaultSingletonTraits; | 14 template <typename T> struct DefaultSingletonTraits; |
| 15 | 15 |
| 16 class PrefChangeRegistrar; | 16 class PrefChangeRegistrar; |
| 17 class PrefService; | 17 class PrefService; |
| 18 class PrefServiceSimple; |
| 18 | 19 |
| 19 namespace chromeos { | 20 namespace chromeos { |
| 20 | 21 |
| 21 class AudioMixer; | 22 class AudioMixer; |
| 22 | 23 |
| 23 class AudioHandler { | 24 class AudioHandler { |
| 24 public: | 25 public: |
| 25 class VolumeObserver { | 26 class VolumeObserver { |
| 26 public: | 27 public: |
| 27 virtual void OnVolumeChanged() = 0; | 28 virtual void OnVolumeChanged() = 0; |
| 28 virtual void OnMuteToggled() = 0; | 29 virtual void OnMuteToggled() = 0; |
| 29 protected: | 30 protected: |
| 30 VolumeObserver() {} | 31 VolumeObserver() {} |
| 31 virtual ~VolumeObserver() {} | 32 virtual ~VolumeObserver() {} |
| 32 DISALLOW_COPY_AND_ASSIGN(VolumeObserver); | 33 DISALLOW_COPY_AND_ASSIGN(VolumeObserver); |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 static void Initialize(); | 36 static void Initialize(); |
| 36 static void Shutdown(); | 37 static void Shutdown(); |
| 37 | 38 |
| 38 // Same as Initialize but using the specified audio mixer. It takes | 39 // Same as Initialize but using the specified audio mixer. It takes |
| 39 // ownership of |mixer|. | 40 // ownership of |mixer|. |
| 40 static void InitializeForTesting(AudioMixer* mixer); | 41 static void InitializeForTesting(AudioMixer* mixer); |
| 41 | 42 |
| 42 // GetInstance returns NULL if not initialized or if already shutdown. | 43 // GetInstance returns NULL if not initialized or if already shutdown. |
| 43 static AudioHandler* GetInstance(); | 44 static AudioHandler* GetInstance(); |
| 44 | 45 |
| 45 // Registers volume and mute preferences. | 46 // Registers volume and mute preferences. |
| 46 static void RegisterPrefs(PrefService* local_state); | 47 static void RegisterPrefs(PrefServiceSimple* local_state); |
| 47 | 48 |
| 48 // Gets volume level in our internal 0-100% range, 0 being pure silence. | 49 // Gets volume level in our internal 0-100% range, 0 being pure silence. |
| 49 double GetVolumePercent(); | 50 double GetVolumePercent(); |
| 50 | 51 |
| 51 // Sets volume level from 0-100%. If less than kMuteThresholdPercent, then | 52 // Sets volume level from 0-100%. If less than kMuteThresholdPercent, then |
| 52 // mutes the sound. If it was muted, and |volume_percent| is larger than | 53 // mutes the sound. If it was muted, and |volume_percent| is larger than |
| 53 // the threshold, then the sound is unmuted. | 54 // the threshold, then the sound is unmuted. |
| 54 void SetVolumePercent(double volume_percent); | 55 void SetVolumePercent(double volume_percent); |
| 55 | 56 |
| 56 // Adjusts volume up (positive percentage) or down (negative percentage). | 57 // Adjusts volume up (positive percentage) or down (negative percentage). |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 PrefService* local_state_; // not owned | 99 PrefService* local_state_; // not owned |
| 99 | 100 |
| 100 PrefChangeRegistrar pref_change_registrar_; | 101 PrefChangeRegistrar pref_change_registrar_; |
| 101 | 102 |
| 102 DISALLOW_COPY_AND_ASSIGN(AudioHandler); | 103 DISALLOW_COPY_AND_ASSIGN(AudioHandler); |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 } // namespace chromeos | 106 } // namespace chromeos |
| 106 | 107 |
| 107 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ | 108 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ |
| OLD | NEW |