| 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 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/atomic_ref_count.h" | 12 #include "base/atomic_ref_count.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "media/audio/audio_manager.h" | 17 #include "media/audio/audio_manager.h" |
| 18 | 18 |
| 19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 20 #include "base/win/scoped_com_initializer.h" | 20 #include "base/win/scoped_com_initializer.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 #if defined(OS_ANDROID) | |
| 24 #include "base/android/jni_android.h" | |
| 25 #endif | |
| 26 | |
| 27 namespace base { | 23 namespace base { |
| 28 class Thread; | 24 class Thread; |
| 29 } | 25 } |
| 30 | 26 |
| 31 namespace media { | 27 namespace media { |
| 32 | 28 |
| 33 class AudioOutputDispatcher; | 29 class AudioOutputDispatcher; |
| 34 | 30 |
| 35 // AudioManagerBase provides AudioManager functions common for all platforms. | 31 // AudioManagerBase provides AudioManager functions common for all platforms. |
| 36 class MEDIA_EXPORT AudioManagerBase : public AudioManager { | 32 class MEDIA_EXPORT AudioManagerBase : public AudioManager { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // Listeners will be notified on the AudioManager::GetMessageLoop() loop. | 86 // Listeners will be notified on the AudioManager::GetMessageLoop() loop. |
| 91 virtual void AddOutputDeviceChangeListener( | 87 virtual void AddOutputDeviceChangeListener( |
| 92 AudioDeviceListener* listener) OVERRIDE; | 88 AudioDeviceListener* listener) OVERRIDE; |
| 93 virtual void RemoveOutputDeviceChangeListener( | 89 virtual void RemoveOutputDeviceChangeListener( |
| 94 AudioDeviceListener* listener) OVERRIDE; | 90 AudioDeviceListener* listener) OVERRIDE; |
| 95 | 91 |
| 96 virtual AudioParameters GetDefaultOutputStreamParameters() OVERRIDE; | 92 virtual AudioParameters GetDefaultOutputStreamParameters() OVERRIDE; |
| 97 virtual AudioParameters GetInputStreamParameters( | 93 virtual AudioParameters GetInputStreamParameters( |
| 98 const std::string& device_id) OVERRIDE; | 94 const std::string& device_id) OVERRIDE; |
| 99 | 95 |
| 100 #if defined(OS_ANDROID) | |
| 101 static bool RegisterAudioManager(JNIEnv* env); | |
| 102 #endif | |
| 103 | |
| 104 protected: | 96 protected: |
| 105 AudioManagerBase(); | 97 AudioManagerBase(); |
| 106 | 98 |
| 107 // TODO(dalecurtis): This must change to map both input and output parameters | 99 // TODO(dalecurtis): This must change to map both input and output parameters |
| 108 // to a single dispatcher, otherwise on a device state change we'll just get | 100 // to a single dispatcher, otherwise on a device state change we'll just get |
| 109 // the exact same invalid dispatcher. | 101 // the exact same invalid dispatcher. |
| 110 typedef std::map<std::pair<AudioParameters, AudioParameters>, | 102 typedef std::map<std::pair<AudioParameters, AudioParameters>, |
| 111 scoped_refptr<AudioOutputDispatcher> > | 103 scoped_refptr<AudioOutputDispatcher> > |
| 112 AudioOutputDispatchersMap; | 104 AudioOutputDispatchersMap; |
| 113 | 105 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 133 const AudioParameters& input_params) = 0; | 125 const AudioParameters& input_params) = 0; |
| 134 | 126 |
| 135 // Map of cached AudioOutputDispatcher instances. Must only be touched | 127 // Map of cached AudioOutputDispatcher instances. Must only be touched |
| 136 // from the audio thread (no locking). | 128 // from the audio thread (no locking). |
| 137 AudioOutputDispatchersMap output_dispatchers_; | 129 AudioOutputDispatchersMap output_dispatchers_; |
| 138 | 130 |
| 139 private: | 131 private: |
| 140 // Called by Shutdown(). | 132 // Called by Shutdown(). |
| 141 void ShutdownOnAudioThread(); | 133 void ShutdownOnAudioThread(); |
| 142 | 134 |
| 143 void SetAudioMode(int mode); | |
| 144 | |
| 145 // Counts the number of active input streams to find out if something else | 135 // Counts the number of active input streams to find out if something else |
| 146 // is currently recording in Chrome. | 136 // is currently recording in Chrome. |
| 147 base::AtomicRefCount num_active_input_streams_; | 137 base::AtomicRefCount num_active_input_streams_; |
| 148 | 138 |
| 149 // Max number of open output streams, modified by | 139 // Max number of open output streams, modified by |
| 150 // SetMaxOutputStreamsAllowed(). | 140 // SetMaxOutputStreamsAllowed(). |
| 151 int max_num_output_streams_; | 141 int max_num_output_streams_; |
| 152 | 142 |
| 153 // Max number of open input streams. | 143 // Max number of open input streams. |
| 154 int max_num_input_streams_; | 144 int max_num_input_streams_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 170 // tasks which run on the audio thread even after Shutdown() has been started | 160 // tasks which run on the audio thread even after Shutdown() has been started |
| 171 // and GetMessageLoop() starts returning NULL. | 161 // and GetMessageLoop() starts returning NULL. |
| 172 scoped_refptr<base::MessageLoopProxy> message_loop_; | 162 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 173 | 163 |
| 174 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); | 164 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); |
| 175 }; | 165 }; |
| 176 | 166 |
| 177 } // namespace media | 167 } // namespace media |
| 178 | 168 |
| 179 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 169 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
| OLD | NEW |