Chromium Code Reviews| 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 "base/win/scoped_com_initializer.h" | |
| 15 #include "media/audio/audio_manager.h" | 17 #include "media/audio/audio_manager.h" |
| 16 | 18 |
| 17 namespace base { | |
| 18 class Thread; | |
| 19 } | |
| 20 | |
| 21 namespace media { | 19 namespace media { |
| 22 | 20 |
| 23 class AudioOutputDispatcher; | 21 class AudioOutputDispatcher; |
| 24 | 22 |
| 23 // Initializes the COM library for use by this thread and sets the thread's | |
| 24 // concurrency model to multi-threaded. | |
|
tommi (sloooow) - chröme
2012/09/17 15:56:45
s/concurrency model to multi-threaded/COM threadin
henrika (OOO until Aug 14)
2012/09/17 16:43:29
Done.
| |
| 25 class AudioThread : public base::Thread { | |
|
scherkus (not reviewing)
2012/09/17 16:23:48
nit: this class can be forward declared + moved to
henrika (OOO until Aug 14)
2012/09/17 16:43:29
Done.
| |
| 26 public: | |
|
tommi (sloooow) - chröme
2012/09/17 15:56:45
indent (and below)
henrika (OOO until Aug 14)
2012/09/17 16:43:29
Done.
| |
| 27 explicit AudioThread(const char* name); | |
| 28 virtual ~AudioThread(); | |
| 29 | |
| 30 protected: | |
| 31 virtual void Init() OVERRIDE; | |
| 32 virtual void CleanUp() OVERRIDE; | |
| 33 | |
| 34 private: | |
| 35 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_; | |
| 36 DISALLOW_COPY_AND_ASSIGN(AudioThread); | |
| 37 }; | |
| 38 | |
| 25 // AudioManagerBase provides AudioManager functions common for all platforms. | 39 // AudioManagerBase provides AudioManager functions common for all platforms. |
| 26 class MEDIA_EXPORT AudioManagerBase : public AudioManager { | 40 class MEDIA_EXPORT AudioManagerBase : public AudioManager { |
| 27 public: | 41 public: |
| 28 // Name of the generic "default" device. | 42 // Name of the generic "default" device. |
| 29 static const char kDefaultDeviceName[]; | 43 static const char kDefaultDeviceName[]; |
| 30 // Unique Id of the generic "default" device. | 44 // Unique Id of the generic "default" device. |
| 31 static const char kDefaultDeviceId[]; | 45 static const char kDefaultDeviceId[]; |
| 32 | 46 |
| 33 virtual ~AudioManagerBase(); | 47 virtual ~AudioManagerBase(); |
| 34 | 48 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 // Shutdown is called. | 115 // Shutdown is called. |
| 102 // This must be called in the destructor of the AudioManager<Platform>. | 116 // This must be called in the destructor of the AudioManager<Platform>. |
| 103 void Shutdown(); | 117 void Shutdown(); |
| 104 | 118 |
| 105 void ShutdownOnAudioThread(); | 119 void ShutdownOnAudioThread(); |
| 106 | 120 |
| 107 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } | 121 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } |
| 108 | 122 |
| 109 // Thread used to interact with AudioOutputStreams created by this | 123 // Thread used to interact with AudioOutputStreams created by this |
| 110 // audio manger. | 124 // audio manger. |
| 111 scoped_ptr<base::Thread> audio_thread_; | 125 scoped_ptr<media::AudioThread> audio_thread_; |
| 112 mutable base::Lock audio_thread_lock_; | 126 mutable base::Lock audio_thread_lock_; |
| 113 | 127 |
| 114 // Map of cached AudioOutputDispatcher instances. Must only be touched | 128 // Map of cached AudioOutputDispatcher instances. Must only be touched |
| 115 // from the audio thread (no locking). | 129 // from the audio thread (no locking). |
| 116 AudioOutputDispatchersMap output_dispatchers_; | 130 AudioOutputDispatchersMap output_dispatchers_; |
| 117 | 131 |
| 118 private: | 132 private: |
| 119 // Counts the number of active input streams to find out if something else | 133 // Counts the number of active input streams to find out if something else |
| 120 // is currently recording in Chrome. | 134 // is currently recording in Chrome. |
| 121 base::AtomicRefCount num_active_input_streams_; | 135 base::AtomicRefCount num_active_input_streams_; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 132 | 146 |
| 133 // Number of currently open input streams. | 147 // Number of currently open input streams. |
| 134 int num_input_streams_; | 148 int num_input_streams_; |
| 135 | 149 |
| 136 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); | 150 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); |
| 137 }; | 151 }; |
| 138 | 152 |
| 139 } // namespace media | 153 } // namespace media |
| 140 | 154 |
| 141 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 155 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
| OLD | NEW |