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" |
15 #include "media/audio/audio_manager.h" | 16 #include "media/audio/audio_manager.h" |
16 | 17 |
| 18 #if defined(OS_WIN) |
| 19 #include "base/win/scoped_com_initializer.h" |
| 20 #endif |
| 21 |
17 namespace media { | 22 namespace media { |
18 | 23 |
19 class AudioOutputDispatcher; | 24 class AudioOutputDispatcher; |
20 class AudioThread; | 25 |
| 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 |
21 | 45 |
22 // AudioManagerBase provides AudioManager functions common for all platforms. | 46 // AudioManagerBase provides AudioManager functions common for all platforms. |
23 class MEDIA_EXPORT AudioManagerBase : public AudioManager { | 47 class MEDIA_EXPORT AudioManagerBase : public AudioManager { |
24 public: | 48 public: |
25 // Name of the generic "default" device. | 49 // Name of the generic "default" device. |
26 static const char kDefaultDeviceName[]; | 50 static const char kDefaultDeviceName[]; |
27 // Unique Id of the generic "default" device. | 51 // Unique Id of the generic "default" device. |
28 static const char kDefaultDeviceId[]; | 52 static const char kDefaultDeviceId[]; |
29 | 53 |
30 virtual ~AudioManagerBase(); | 54 virtual ~AudioManagerBase(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Shutdown is called. | 122 // Shutdown is called. |
99 // This must be called in the destructor of the AudioManager<Platform>. | 123 // This must be called in the destructor of the AudioManager<Platform>. |
100 void Shutdown(); | 124 void Shutdown(); |
101 | 125 |
102 void ShutdownOnAudioThread(); | 126 void ShutdownOnAudioThread(); |
103 | 127 |
104 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } | 128 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } |
105 | 129 |
106 // Thread used to interact with AudioOutputStreams created by this | 130 // Thread used to interact with AudioOutputStreams created by this |
107 // audio manger. | 131 // audio manger. |
108 scoped_ptr<media::AudioThread> audio_thread_; | 132 scoped_ptr<AudioThread> audio_thread_; |
109 mutable base::Lock audio_thread_lock_; | 133 mutable base::Lock audio_thread_lock_; |
110 | 134 |
111 // Map of cached AudioOutputDispatcher instances. Must only be touched | 135 // Map of cached AudioOutputDispatcher instances. Must only be touched |
112 // from the audio thread (no locking). | 136 // from the audio thread (no locking). |
113 AudioOutputDispatchersMap output_dispatchers_; | 137 AudioOutputDispatchersMap output_dispatchers_; |
114 | 138 |
115 private: | 139 private: |
116 // Counts the number of active input streams to find out if something else | 140 // Counts the number of active input streams to find out if something else |
117 // is currently recording in Chrome. | 141 // is currently recording in Chrome. |
118 base::AtomicRefCount num_active_input_streams_; | 142 base::AtomicRefCount num_active_input_streams_; |
(...skipping 10 matching lines...) Expand all Loading... |
129 | 153 |
130 // Number of currently open input streams. | 154 // Number of currently open input streams. |
131 int num_input_streams_; | 155 int num_input_streams_; |
132 | 156 |
133 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); | 157 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); |
134 }; | 158 }; |
135 | 159 |
136 } // namespace media | 160 } // namespace media |
137 | 161 |
138 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 162 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
OLD | NEW |