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