| 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 <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // device should be selected basing on |device_id|. | 56 // device should be selected basing on |device_id|. |
| 57 // If |device_id| is empty and |session_id| is nonzero, output device | 57 // If |device_id| is empty and |session_id| is nonzero, output device |
| 58 // associated with the opened input device designated by |session_id| should | 58 // associated with the opened input device designated by |session_id| should |
| 59 // be used. | 59 // be used. |
| 60 static bool UseSessionIdToSelectDevice(int session_id, | 60 static bool UseSessionIdToSelectDevice(int session_id, |
| 61 const std::string& device_id); | 61 const std::string& device_id); |
| 62 | 62 |
| 63 ~AudioManagerBase() override; | 63 ~AudioManagerBase() override; |
| 64 | 64 |
| 65 // AudioManager: | 65 // AudioManager: |
| 66 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override; | |
| 67 scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() override; | |
| 68 base::string16 GetAudioInputDeviceModel() override; | 66 base::string16 GetAudioInputDeviceModel() override; |
| 69 void ShowAudioInputSettings() override; | 67 void ShowAudioInputSettings() override; |
| 70 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override; | 68 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override; |
| 71 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override; | 69 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override; |
| 72 AudioOutputStream* MakeAudioOutputStream( | 70 AudioOutputStream* MakeAudioOutputStream( |
| 73 const AudioParameters& params, | 71 const AudioParameters& params, |
| 74 const std::string& device_id) override; | 72 const std::string& device_id) override; |
| 75 AudioInputStream* MakeAudioInputStream(const AudioParameters& params, | 73 AudioInputStream* MakeAudioInputStream(const AudioParameters& params, |
| 76 const std::string& device_id) override; | 74 const std::string& device_id) override; |
| 77 AudioOutputStream* MakeAudioOutputStreamProxy( | 75 AudioOutputStream* MakeAudioOutputStreamProxy( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 113 |
| 116 // Creates the input stream for the |AUDIO_PCM_LOW_LATENCY| format. | 114 // Creates the input stream for the |AUDIO_PCM_LOW_LATENCY| format. |
| 117 virtual AudioInputStream* MakeLowLatencyInputStream( | 115 virtual AudioInputStream* MakeLowLatencyInputStream( |
| 118 const AudioParameters& params, const std::string& device_id) = 0; | 116 const AudioParameters& params, const std::string& device_id) = 0; |
| 119 | 117 |
| 120 // Get number of input or output streams. | 118 // Get number of input or output streams. |
| 121 int input_stream_count() const { return num_input_streams_; } | 119 int input_stream_count() const { return num_input_streams_; } |
| 122 int output_stream_count() const { return num_output_streams_; } | 120 int output_stream_count() const { return num_output_streams_; } |
| 123 | 121 |
| 124 protected: | 122 protected: |
| 125 AudioManagerBase(AudioLogFactory* audio_log_factory); | 123 AudioManagerBase( |
| 124 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 125 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, |
| 126 AudioLogFactory* audio_log_factory); |
| 126 | 127 |
| 127 // Shuts down the audio thread and releases all the audio output dispatchers | 128 // Releases all the audio output dispatchers. |
| 128 // on the audio thread. All audio streams should be freed before Shutdown() | 129 // All audio streams should be closed before Shutdown() is called. |
| 129 // is called. This must be called in the destructor of every AudioManagerBase | 130 // This must be called in the destructor of every AudioManagerBase |
| 130 // implementation. | 131 // implementation. |
| 131 void Shutdown(); | 132 void Shutdown(); |
| 132 | 133 |
| 133 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } | 134 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } |
| 134 | 135 |
| 135 // Called by each platform specific AudioManager to notify output state change | 136 // Called by each platform specific AudioManager to notify output state change |
| 136 // listeners that a state change has occurred. Must be called from the audio | 137 // listeners that a state change has occurred. Must be called from the audio |
| 137 // thread. | 138 // thread. |
| 138 void NotifyAllOutputDeviceChangeListeners(); | 139 void NotifyAllOutputDeviceChangeListeners(); |
| 139 | 140 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 155 // Returns the ID of the default audio output device. | 156 // Returns the ID of the default audio output device. |
| 156 // Implementations that don't yet support this should return an empty string. | 157 // Implementations that don't yet support this should return an empty string. |
| 157 virtual std::string GetDefaultOutputDeviceID(); | 158 virtual std::string GetDefaultOutputDeviceID(); |
| 158 | 159 |
| 159 private: | 160 private: |
| 160 struct DispatcherParams; | 161 struct DispatcherParams; |
| 161 typedef ScopedVector<DispatcherParams> AudioOutputDispatchers; | 162 typedef ScopedVector<DispatcherParams> AudioOutputDispatchers; |
| 162 | 163 |
| 163 class CompareByParams; | 164 class CompareByParams; |
| 164 | 165 |
| 165 // Called by Shutdown(). | |
| 166 void ShutdownOnAudioThread(); | |
| 167 | |
| 168 // Max number of open output streams, modified by | 166 // Max number of open output streams, modified by |
| 169 // SetMaxOutputStreamsAllowed(). | 167 // SetMaxOutputStreamsAllowed(). |
| 170 int max_num_output_streams_; | 168 int max_num_output_streams_; |
| 171 | 169 |
| 172 // Max number of open input streams. | 170 // Max number of open input streams. |
| 173 int max_num_input_streams_; | 171 int max_num_input_streams_; |
| 174 | 172 |
| 175 // Number of currently open output streams. | 173 // Number of currently open output streams. |
| 176 int num_output_streams_; | 174 int num_output_streams_; |
| 177 | 175 |
| 178 // Number of currently open input streams. | 176 // Number of currently open input streams. |
| 179 int num_input_streams_; | 177 int num_input_streams_; |
| 180 | 178 |
| 181 // Track output state change listeners. | 179 // Track output state change listeners. |
| 182 base::ObserverList<AudioDeviceListener> output_listeners_; | 180 base::ObserverList<AudioDeviceListener> output_listeners_; |
| 183 | 181 |
| 184 // Thread used to interact with audio streams created by this audio manager. | |
| 185 scoped_ptr<base::Thread> audio_thread_; | |
| 186 | |
| 187 // Map of cached AudioOutputDispatcher instances. Must only be touched | 182 // Map of cached AudioOutputDispatcher instances. Must only be touched |
| 188 // from the audio thread (no locking). | 183 // from the audio thread (no locking). |
| 189 AudioOutputDispatchers output_dispatchers_; | 184 AudioOutputDispatchers output_dispatchers_; |
| 190 | 185 |
| 191 // Proxy for creating AudioLog objects. | 186 // Proxy for creating AudioLog objects. |
| 192 AudioLogFactory* const audio_log_factory_; | 187 AudioLogFactory* const audio_log_factory_; |
| 193 | 188 |
| 194 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); | 189 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); |
| 195 }; | 190 }; |
| 196 | 191 |
| 197 } // namespace media | 192 } // namespace media |
| 198 | 193 |
| 199 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 194 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
| OLD | NEW |