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> | |
scherkus (not reviewing)
2011/12/09 22:47:30
nit: blank lines between <system includes.h> and "
tommi (sloooow) - chröme
2011/12/10 00:11:14
Done.
| |
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> { | |
scherkus (not reviewing)
2011/12/09 22:47:30
we really shouldn't require refcounting but let's
tommi (sloooow) - chröme
2011/12/10 00:11:14
Will do. crbug seems to be down at the moment so I
scherkus (not reviewing)
2011/12/10 00:16:52
agree 100%
tommi (sloooow) - chröme
2011/12/10 09:59:57
bug filed and comment added: crbug.com/107087
willchan no longer on Chromium
2011/12/12 16:44:05
This plan sounds great to me! It looks like as lon
| |
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 static scoped_refptr<AudioManager> Create(); | |
40 | |
26 // Returns true if the OS reports existence of audio devices. This does not | 41 // 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. | 42 // guarantee that the existing devices support all formats and sample rates. |
28 virtual bool HasAudioOutputDevices() = 0; | 43 virtual bool HasAudioOutputDevices() = 0; |
29 | 44 |
30 // Returns true if the OS reports existence of audio recording devices. This | 45 // Returns true if the OS reports existence of audio recording devices. This |
31 // does not guarantee that the existing devices support all formats and | 46 // does not guarantee that the existing devices support all formats and |
32 // sample rates. | 47 // sample rates. |
33 virtual bool HasAudioInputDevices() = 0; | 48 virtual bool HasAudioInputDevices() = 0; |
34 | 49 |
35 // Returns a human readable string for the model/make of the active audio | 50 // 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. | 114 // Un-muting returns the volume to the previous level. |
100 virtual void MuteAll() = 0; | 115 virtual void MuteAll() = 0; |
101 virtual void UnMuteAll() = 0; | 116 virtual void UnMuteAll() = 0; |
102 | 117 |
103 // Used to determine if something else is currently making use of audio input. | 118 // Used to determine if something else is currently making use of audio input. |
104 virtual bool IsRecordingInProcess() = 0; | 119 virtual bool IsRecordingInProcess() = 0; |
105 | 120 |
106 // Returns message loop used for audio IO. | 121 // Returns message loop used for audio IO. |
107 virtual MessageLoop* GetMessageLoop() = 0; | 122 virtual MessageLoop* GetMessageLoop() = 0; |
108 | 123 |
109 // Get AudioManager singleton. | |
110 // TODO(cpu): Define threading requirements for interacting with AudioManager. | |
111 static AudioManager* GetAudioManager(); | |
112 | |
113 protected: | 124 protected: |
114 virtual ~AudioManager() {} | 125 // Called from Create() to initialize the instance. |
115 | |
116 // Called from GetAudioManager() to initialiaze the instance. | |
117 virtual void Init() = 0; | 126 virtual void Init() = 0; |
118 | 127 |
119 // Called by Destroy() to cleanup the instance before destruction. | 128 friend class base::RefCountedThreadSafe<AudioManager>; |
120 virtual void Cleanup() = 0; | 129 virtual ~AudioManager(); |
121 | 130 |
122 private: | 131 private: |
123 // Allow unit tests to delete and recreate the singleton. | 132 // 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(); | 133 static AudioManager* CreateAudioManager(); |
scherkus (not reviewing)
2011/12/09 22:47:30
could we move this to the .cc or do implementors r
tommi (sloooow) - chröme
2011/12/10 00:11:14
Done.
| |
131 }; | 134 }; |
132 | 135 |
133 DISABLE_RUNNABLE_METHOD_REFCOUNT(AudioManager); | 136 DISABLE_RUNNABLE_METHOD_REFCOUNT(AudioManager); |
134 | 137 |
135 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ | 138 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ |
OLD | NEW |