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 MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/atomic_ref_count.h" | 11 #include "base/atomic_ref_count.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "base/threading/thread.h" | |
16 #include "media/audio/audio_manager.h" | 15 #include "media/audio/audio_manager.h" |
17 | 16 |
18 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
19 #include "base/win/scoped_com_initializer.h" | 18 #include "base/win/scoped_com_initializer.h" |
20 #endif | 19 #endif |
21 | 20 |
| 21 namespace base { |
| 22 class Thread; |
| 23 } |
| 24 |
22 namespace media { | 25 namespace media { |
23 | 26 |
24 class AudioOutputDispatcher; | 27 class AudioOutputDispatcher; |
25 | 28 |
26 // Thread that enters MTA on Windows. | |
27 #if defined(OS_WIN) | |
28 class AudioThread : public base::Thread { | |
29 public: | |
30 explicit AudioThread(const char* name); | |
31 virtual ~AudioThread(); | |
32 | |
33 protected: | |
34 virtual void Init() OVERRIDE; | |
35 virtual void CleanUp() OVERRIDE; | |
36 | |
37 private: | |
38 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_; | |
39 | |
40 DISALLOW_COPY_AND_ASSIGN(AudioThread); | |
41 }; | |
42 #else | |
43 typedef base::Thread AudioThread; | |
44 #endif | |
45 | |
46 // AudioManagerBase provides AudioManager functions common for all platforms. | 29 // AudioManagerBase provides AudioManager functions common for all platforms. |
47 class MEDIA_EXPORT AudioManagerBase : public AudioManager { | 30 class MEDIA_EXPORT AudioManagerBase : public AudioManager { |
48 public: | 31 public: |
49 // Name of the generic "default" device. | 32 // Name of the generic "default" device. |
50 static const char kDefaultDeviceName[]; | 33 static const char kDefaultDeviceName[]; |
51 // Unique Id of the generic "default" device. | 34 // Unique Id of the generic "default" device. |
52 static const char kDefaultDeviceId[]; | 35 static const char kDefaultDeviceId[]; |
53 | 36 |
54 virtual ~AudioManagerBase(); | 37 virtual ~AudioManagerBase(); |
55 | 38 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // Shutdown is called. | 105 // Shutdown is called. |
123 // This must be called in the destructor of the AudioManager<Platform>. | 106 // This must be called in the destructor of the AudioManager<Platform>. |
124 void Shutdown(); | 107 void Shutdown(); |
125 | 108 |
126 void ShutdownOnAudioThread(); | 109 void ShutdownOnAudioThread(); |
127 | 110 |
128 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } | 111 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } |
129 | 112 |
130 // Thread used to interact with AudioOutputStreams created by this | 113 // Thread used to interact with AudioOutputStreams created by this |
131 // audio manger. | 114 // audio manger. |
132 scoped_ptr<AudioThread> audio_thread_; | 115 scoped_ptr<base::Thread> audio_thread_; |
133 mutable base::Lock audio_thread_lock_; | 116 mutable base::Lock audio_thread_lock_; |
134 | 117 |
135 // Map of cached AudioOutputDispatcher instances. Must only be touched | 118 // Map of cached AudioOutputDispatcher instances. Must only be touched |
136 // from the audio thread (no locking). | 119 // from the audio thread (no locking). |
137 AudioOutputDispatchersMap output_dispatchers_; | 120 AudioOutputDispatchersMap output_dispatchers_; |
138 | 121 |
139 private: | 122 private: |
140 // Counts the number of active input streams to find out if something else | 123 // Counts the number of active input streams to find out if something else |
141 // is currently recording in Chrome. | 124 // is currently recording in Chrome. |
142 base::AtomicRefCount num_active_input_streams_; | 125 base::AtomicRefCount num_active_input_streams_; |
(...skipping 10 matching lines...) Expand all Loading... |
153 | 136 |
154 // Number of currently open input streams. | 137 // Number of currently open input streams. |
155 int num_input_streams_; | 138 int num_input_streams_; |
156 | 139 |
157 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); | 140 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); |
158 }; | 141 }; |
159 | 142 |
160 } // namespace media | 143 } // namespace media |
161 | 144 |
162 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 145 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
OLD | NEW |