OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 MEDIA_AUDIO_AUDIO_MANAGER_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_MANAGER_H_ |
6 #define MEDIA_AUDIO_AUDIO_MANAGER_H_ | 6 #define MEDIA_AUDIO_AUDIO_MANAGER_H_ |
7 | 7 |
8 #include <string> | |
8 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/ref_counted.h" | |
9 #include "base/string16.h" | 11 #include "base/string16.h" |
10 #include "base/task.h" | 12 #include "base/task.h" |
11 #include "media/audio/audio_device_name.h" | 13 #include "media/audio/audio_device_name.h" |
12 #include "media/audio/audio_parameters.h" | 14 #include "media/audio/audio_parameters.h" |
13 | 15 |
14 class AudioInputStream; | 16 class AudioInputStream; |
15 class AudioOutputStream; | 17 class AudioOutputStream; |
16 class MessageLoop; | 18 class MessageLoop; |
17 | 19 |
18 // TODO(sergeyu): In this interface and some other places AudioParameters struct | |
19 // is passed by value. It is better to change it to const reference. | |
20 | |
21 // Manages all audio resources. In particular it owns the AudioOutputStream | 20 // Manages all audio resources. In particular it owns the AudioOutputStream |
22 // objects. Provides some convenience functions that avoid the need to provide | 21 // objects. Provides some convenience functions that avoid the need to provide |
23 // iterators over the existing streams. | 22 // iterators over the existing streams. |
24 class MEDIA_EXPORT AudioManager { | 23 class MEDIA_EXPORT AudioManager |
24 : public base::RefCountedThreadSafe<AudioManager> { | |
henrika (OOO until Aug 14)
2011/12/07 10:08:34
nit, indent two more?
tommi (sloooow) - chröme
2011/12/07 12:26:44
Done.
| |
25 public: | 25 public: |
26 AudioManager(); | |
27 | |
28 #ifndef NDEBUG | |
29 // Allow base classes in debug builds to override the reference counting | |
30 // functions. This allows us to protect against regressions and enforce | |
31 // correct usage. The default implementation just calls the base class. | |
32 virtual void AddRef() const; | |
33 virtual void Release() const; | |
34 #endif | |
35 | |
36 // Use to construct the audio manager. | |
37 // NOTE: There should only be one instance. If you try to create more than | |
38 // one instance, it will hit a CHECK(). | |
39 // TODO(cpu): Define threading requirements for interacting with AudioManager. | |
henrika (OOO until Aug 14)
2011/12/07 10:08:34
Still a valid comment?
tommi (sloooow) - chröme
2011/12/07 12:26:44
Nope. Removed.
| |
40 static scoped_refptr<AudioManager> Create(); | |
41 | |
26 // Returns true if the OS reports existence of audio devices. This does not | 42 // Returns true if the OS reports existence of audio devices. This does not |
27 // guarantee that the existing devices support all formats and sample rates. | 43 // guarantee that the existing devices support all formats and sample rates. |
28 virtual bool HasAudioOutputDevices() = 0; | 44 virtual bool HasAudioOutputDevices() = 0; |
29 | 45 |
30 // Returns true if the OS reports existence of audio recording devices. This | 46 // Returns true if the OS reports existence of audio recording devices. This |
31 // does not guarantee that the existing devices support all formats and | 47 // does not guarantee that the existing devices support all formats and |
32 // sample rates. | 48 // sample rates. |
33 virtual bool HasAudioInputDevices() = 0; | 49 virtual bool HasAudioInputDevices() = 0; |
34 | 50 |
35 // Returns a human readable string for the model/make of the active audio | 51 // Returns a human readable string for the model/make of the active audio |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 // Un-muting returns the volume to the previous level. | 115 // Un-muting returns the volume to the previous level. |
100 virtual void MuteAll() = 0; | 116 virtual void MuteAll() = 0; |
101 virtual void UnMuteAll() = 0; | 117 virtual void UnMuteAll() = 0; |
102 | 118 |
103 // Used to determine if something else is currently making use of audio input. | 119 // Used to determine if something else is currently making use of audio input. |
104 virtual bool IsRecordingInProcess() = 0; | 120 virtual bool IsRecordingInProcess() = 0; |
105 | 121 |
106 // Returns message loop used for audio IO. | 122 // Returns message loop used for audio IO. |
107 virtual MessageLoop* GetMessageLoop() = 0; | 123 virtual MessageLoop* GetMessageLoop() = 0; |
108 | 124 |
109 // Get AudioManager singleton. | |
110 // TODO(cpu): Define threading requirements for interacting with AudioManager. | |
111 static AudioManager* GetAudioManager(); | |
112 | |
113 protected: | 125 protected: |
114 virtual ~AudioManager() {} | 126 // Called from Create() to initialize the instance. |
115 | |
116 // Called from GetAudioManager() to initialiaze the instance. | |
117 virtual void Init() = 0; | 127 virtual void Init() = 0; |
118 | 128 |
119 // Called by Destroy() to cleanup the instance before destruction. | 129 friend class base::RefCountedThreadSafe<AudioManager>; |
120 virtual void Cleanup() = 0; | 130 virtual ~AudioManager(); |
121 | 131 |
122 private: | 132 private: |
123 // Allow unit tests to delete and recreate the singleton. | 133 // Called by Create() to create platform-specific audio manager. |
124 friend class AutoAudioManagerCleanup; | |
125 static void Destroy(void*); | |
126 static bool SingletonExists(); | |
127 static void Resurrect(); | |
128 | |
129 // Called by GetAudioManager() to create platform-specific audio manager. | |
130 static AudioManager* CreateAudioManager(); | 134 static AudioManager* CreateAudioManager(); |
131 }; | 135 }; |
132 | 136 |
133 DISABLE_RUNNABLE_METHOD_REFCOUNT(AudioManager); | 137 DISABLE_RUNNABLE_METHOD_REFCOUNT(AudioManager); |
134 | 138 |
135 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ | 139 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ |
OLD | NEW |