Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: media/audio/audio_manager_base.h

Issue 1901583005: Revert of Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/audio_manager.cc ('k') | media/audio/audio_manager_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
66 base::string16 GetAudioInputDeviceModel() override; 68 base::string16 GetAudioInputDeviceModel() override;
67 void ShowAudioInputSettings() override; 69 void ShowAudioInputSettings() override;
68 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override; 70 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override;
69 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override; 71 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override;
70 AudioOutputStream* MakeAudioOutputStream( 72 AudioOutputStream* MakeAudioOutputStream(
71 const AudioParameters& params, 73 const AudioParameters& params,
72 const std::string& device_id) override; 74 const std::string& device_id) override;
73 AudioInputStream* MakeAudioInputStream(const AudioParameters& params, 75 AudioInputStream* MakeAudioInputStream(const AudioParameters& params,
74 const std::string& device_id) override; 76 const std::string& device_id) override;
75 AudioOutputStream* MakeAudioOutputStreamProxy( 77 AudioOutputStream* MakeAudioOutputStreamProxy(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 115
114 // Creates the input stream for the |AUDIO_PCM_LOW_LATENCY| format. 116 // Creates the input stream for the |AUDIO_PCM_LOW_LATENCY| format.
115 virtual AudioInputStream* MakeLowLatencyInputStream( 117 virtual AudioInputStream* MakeLowLatencyInputStream(
116 const AudioParameters& params, const std::string& device_id) = 0; 118 const AudioParameters& params, const std::string& device_id) = 0;
117 119
118 // Get number of input or output streams. 120 // Get number of input or output streams.
119 int input_stream_count() const { return num_input_streams_; } 121 int input_stream_count() const { return num_input_streams_; }
120 int output_stream_count() const { return num_output_streams_; } 122 int output_stream_count() const { return num_output_streams_; }
121 123
122 protected: 124 protected:
123 AudioManagerBase( 125 AudioManagerBase(AudioLogFactory* audio_log_factory);
124 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
125 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
126 AudioLogFactory* audio_log_factory);
127 126
128 // Releases all the audio output dispatchers. 127 // Shuts down the audio thread and releases all the audio output dispatchers
129 // All audio streams should be closed before Shutdown() is called. 128 // on the audio thread. All audio streams should be freed before Shutdown()
130 // This must be called in the destructor of every AudioManagerBase 129 // is called. This must be called in the destructor of every AudioManagerBase
131 // implementation. 130 // implementation.
132 void Shutdown(); 131 void Shutdown();
133 132
134 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } 133 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; }
135 134
136 // Called by each platform specific AudioManager to notify output state change 135 // Called by each platform specific AudioManager to notify output state change
137 // listeners that a state change has occurred. Must be called from the audio 136 // listeners that a state change has occurred. Must be called from the audio
138 // thread. 137 // thread.
139 void NotifyAllOutputDeviceChangeListeners(); 138 void NotifyAllOutputDeviceChangeListeners();
140 139
(...skipping 15 matching lines...) Expand all
156 // Returns the ID of the default audio output device. 155 // Returns the ID of the default audio output device.
157 // Implementations that don't yet support this should return an empty string. 156 // Implementations that don't yet support this should return an empty string.
158 virtual std::string GetDefaultOutputDeviceID(); 157 virtual std::string GetDefaultOutputDeviceID();
159 158
160 private: 159 private:
161 struct DispatcherParams; 160 struct DispatcherParams;
162 typedef ScopedVector<DispatcherParams> AudioOutputDispatchers; 161 typedef ScopedVector<DispatcherParams> AudioOutputDispatchers;
163 162
164 class CompareByParams; 163 class CompareByParams;
165 164
165 // Called by Shutdown().
166 void ShutdownOnAudioThread();
167
166 // Max number of open output streams, modified by 168 // Max number of open output streams, modified by
167 // SetMaxOutputStreamsAllowed(). 169 // SetMaxOutputStreamsAllowed().
168 int max_num_output_streams_; 170 int max_num_output_streams_;
169 171
170 // Max number of open input streams. 172 // Max number of open input streams.
171 int max_num_input_streams_; 173 int max_num_input_streams_;
172 174
173 // Number of currently open output streams. 175 // Number of currently open output streams.
174 int num_output_streams_; 176 int num_output_streams_;
175 177
176 // Number of currently open input streams. 178 // Number of currently open input streams.
177 int num_input_streams_; 179 int num_input_streams_;
178 180
179 // Track output state change listeners. 181 // Track output state change listeners.
180 base::ObserverList<AudioDeviceListener> output_listeners_; 182 base::ObserverList<AudioDeviceListener> output_listeners_;
181 183
184 // Thread used to interact with audio streams created by this audio manager.
185 scoped_ptr<base::Thread> audio_thread_;
186
182 // Map of cached AudioOutputDispatcher instances. Must only be touched 187 // Map of cached AudioOutputDispatcher instances. Must only be touched
183 // from the audio thread (no locking). 188 // from the audio thread (no locking).
184 AudioOutputDispatchers output_dispatchers_; 189 AudioOutputDispatchers output_dispatchers_;
185 190
186 // Proxy for creating AudioLog objects. 191 // Proxy for creating AudioLog objects.
187 AudioLogFactory* const audio_log_factory_; 192 AudioLogFactory* const audio_log_factory_;
188 193
189 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); 194 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase);
190 }; 195 };
191 196
192 } // namespace media 197 } // namespace media
193 198
194 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ 199 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_
OLDNEW
« no previous file with comments | « media/audio/audio_manager.cc ('k') | media/audio/audio_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698