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 PrefRegistrySimple; |
17 class PrefService; | 18 class PrefService; |
18 class PrefServiceSimple; | |
19 | 19 |
20 namespace chromeos { | 20 namespace chromeos { |
21 | 21 |
22 class AudioMixer; | 22 class AudioMixer; |
23 | 23 |
24 class AudioHandler { | 24 class AudioHandler { |
25 public: | 25 public: |
26 class VolumeObserver { | 26 class VolumeObserver { |
27 public: | 27 public: |
28 virtual void OnVolumeChanged() = 0; | 28 virtual void OnVolumeChanged() = 0; |
29 virtual void OnMuteToggled() = 0; | 29 virtual void OnMuteToggled() = 0; |
30 protected: | 30 protected: |
31 VolumeObserver() {} | 31 VolumeObserver() {} |
32 virtual ~VolumeObserver() {} | 32 virtual ~VolumeObserver() {} |
33 DISALLOW_COPY_AND_ASSIGN(VolumeObserver); | 33 DISALLOW_COPY_AND_ASSIGN(VolumeObserver); |
34 }; | 34 }; |
35 | 35 |
36 static void Initialize(); | 36 static void Initialize(); |
37 static void Shutdown(); | 37 static void Shutdown(); |
38 | 38 |
39 // Same as Initialize but using the specified audio mixer. It takes | 39 // Same as Initialize but using the specified audio mixer. It takes |
40 // ownership of |mixer|. | 40 // ownership of |mixer|. |
41 static void InitializeForTesting(AudioMixer* mixer); | 41 static void InitializeForTesting(AudioMixer* mixer); |
42 | 42 |
43 // GetInstance returns NULL if not initialized or if already shutdown. | 43 // GetInstance returns NULL if not initialized or if already shutdown. |
44 static AudioHandler* GetInstance(); | 44 static AudioHandler* GetInstance(); |
45 | 45 |
46 // Registers volume and mute preferences. | 46 // Registers volume and mute preferences. |
47 static void RegisterPrefs(PrefServiceSimple* local_state); | 47 static void RegisterPrefs(PrefRegistrySimple* registry); |
48 | 48 |
49 // 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. |
50 double GetVolumePercent(); | 50 double GetVolumePercent(); |
51 | 51 |
52 // Sets volume level from 0-100%. If less than kMuteThresholdPercent, then | 52 // Sets volume level from 0-100%. If less than kMuteThresholdPercent, then |
53 // 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 |
54 // the threshold, then the sound is unmuted. | 54 // the threshold, then the sound is unmuted. |
55 void SetVolumePercent(double volume_percent); | 55 void SetVolumePercent(double volume_percent); |
56 | 56 |
57 // 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... |
99 PrefService* local_state_; // not owned | 99 PrefService* local_state_; // not owned |
100 | 100 |
101 PrefChangeRegistrar pref_change_registrar_; | 101 PrefChangeRegistrar pref_change_registrar_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(AudioHandler); | 103 DISALLOW_COPY_AND_ASSIGN(AudioHandler); |
104 }; | 104 }; |
105 | 105 |
106 } // namespace chromeos | 106 } // namespace chromeos |
107 | 107 |
108 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ | 108 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ |
OLD | NEW |