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

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

Issue 1839723002: Experimental: Unmute Audio During Tab Sourced Desktop Share (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Loopback Sink (Rebased) 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
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_OUTPUT_CONTROLLER_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
7 7
8 #include <set>
8 #include <stdint.h> 9 #include <stdint.h>
9 10
10 #include "base/atomic_ref_count.h" 11 #include "base/atomic_ref_count.h"
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "media/audio/audio_io.h" 18 #include "media/audio/audio_io.h"
18 #include "media/audio/audio_manager.h" 19 #include "media/audio/audio_manager.h"
19 #include "media/audio/audio_power_monitor.h" 20 #include "media/audio/audio_power_monitor.h"
20 #include "media/audio/audio_source_diverter.h" 21 #include "media/audio/audio_source_diverter.h"
21 #include "media/audio/simple_sources.h" 22 #include "media/audio/simple_sources.h"
23 #include "media/audio/virtual_audio_output_stream.h"
22 #include "media/base/media_export.h" 24 #include "media/base/media_export.h"
23 25
24 // An AudioOutputController controls an AudioOutputStream and provides data 26 // An AudioOutputController controls an AudioOutputStream and provides data
25 // to this output stream. It has an important function that it executes 27 // to this output stream. It has an important function that it executes
26 // audio operations like play, pause, stop, etc. on a separate thread, 28 // audio operations like play, pause, stop, etc. on a separate thread,
27 // namely the audio manager thread. 29 // namely the audio manager thread.
28 // 30 //
29 // All the public methods of AudioOutputController are non-blocking. 31 // All the public methods of AudioOutputController are non-blocking.
30 // The actual operations are performed on the audio manager thread. 32 // The actual operations are performed on the audio manager thread.
31 // 33 //
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // AudioDeviceListener implementation. When called AudioOutputController will 171 // AudioDeviceListener implementation. When called AudioOutputController will
170 // shutdown the existing |stream_|, transition to the kRecreating state, 172 // shutdown the existing |stream_|, transition to the kRecreating state,
171 // create a new stream, and then transition back to an equivalent state prior 173 // create a new stream, and then transition back to an equivalent state prior
172 // to being called. 174 // to being called.
173 void OnDeviceChange() override; 175 void OnDeviceChange() override;
174 176
175 // AudioSourceDiverter implementation. 177 // AudioSourceDiverter implementation.
176 const AudioParameters& GetAudioParameters() override; 178 const AudioParameters& GetAudioParameters() override;
177 void StartDiverting(AudioOutputStream* to_stream) override; 179 void StartDiverting(AudioOutputStream* to_stream) override;
178 void StopDiverting() override; 180 void StopDiverting() override;
181 void StartDuplicating(AudioPushSink* to_stream) override;
182 void StopDuplicating(AudioPushSink* to_stream) override;
179 183
180 // Accessor for AudioPowerMonitor::ReadCurrentPowerAndClip(). See comments in 184 // Accessor for AudioPowerMonitor::ReadCurrentPowerAndClip(). See comments in
181 // audio_power_monitor.h for usage. This may be called on any thread. 185 // audio_power_monitor.h for usage. This may be called on any thread.
182 std::pair<float, bool> ReadCurrentPowerAndClip(); 186 std::pair<float, bool> ReadCurrentPowerAndClip();
183 187
184 protected: 188 protected:
185 // Internal state of the source. 189 // Internal state of the source.
186 enum State { 190 enum State {
187 kEmpty, 191 kEmpty,
188 kCreated, 192 kCreated,
(...skipping 21 matching lines...) Expand all
210 void DoPlay(); 214 void DoPlay();
211 void DoPause(); 215 void DoPause();
212 void DoClose(); 216 void DoClose();
213 void DoSetVolume(double volume); 217 void DoSetVolume(double volume);
214 std::string DoGetOutputDeviceId() const; 218 std::string DoGetOutputDeviceId() const;
215 void DoSwitchOutputDevice(const std::string& output_device_id); 219 void DoSwitchOutputDevice(const std::string& output_device_id);
216 void DoReportError(); 220 void DoReportError();
217 void DoStartDiverting(AudioOutputStream* to_stream); 221 void DoStartDiverting(AudioOutputStream* to_stream);
218 void DoStopDiverting(); 222 void DoStopDiverting();
219 223
224 void DoStartDuplicating(AudioPushSink* to_stream);
225 void DoStopDuplicating(AudioPushSink* to_stream);
226
220 // Helper method that stops the physical stream. 227 // Helper method that stops the physical stream.
221 void StopStream(); 228 void StopStream();
222 229
223 // Helper method that stops, closes, and NULLs |*stream_|. 230 // Helper method that stops, closes, and NULLs |*stream_|.
224 void DoStopCloseAndClearStream(); 231 void DoStopCloseAndClearStream(bool isForDeviceChange);
225 232
226 // Checks if a stream was started successfully but never calls OnMoreData(). 233 // Checks if a stream was started successfully but never calls OnMoreData().
227 void WedgeCheck(); 234 void WedgeCheck();
228 235
229 AudioManager* const audio_manager_; 236 AudioManager* const audio_manager_;
230 const AudioParameters params_; 237 const AudioParameters params_;
231 EventHandler* const handler_; 238 EventHandler* const handler_;
232 239
233 // Specifies the device id of the output device to open or empty for the 240 // Specifies the device id of the output device to open or empty for the
234 // default output device. 241 // default output device.
235 std::string output_device_id_; 242 std::string output_device_id_;
236 243
237 AudioOutputStream* stream_; 244 AudioOutputStream* stream_;
238 245
239 // When non-NULL, audio is being diverted to this stream. 246 // When non-NULL, audio is being diverted to this stream.
240 AudioOutputStream* diverting_to_stream_; 247 AudioOutputStream* diverting_to_stream_;
241 248
249 std::set<AudioPushSink*> duplicator_;
250
242 // The current volume of the audio stream. 251 // The current volume of the audio stream.
243 double volume_; 252 double volume_;
244 253
245 // |state_| may only be used on the audio manager thread. 254 // |state_| may only be used on the audio manager thread.
246 State state_; 255 State state_;
247 256
248 // SyncReader is used only in low latency mode for synchronous reading. 257 // SyncReader is used only in low latency mode for synchronous reading.
249 SyncReader* const sync_reader_; 258 SyncReader* const sync_reader_;
250 259
251 // The message loop of audio manager thread that this object runs on. 260 // The message loop of audio manager thread that this object runs on.
(...skipping 15 matching lines...) Expand all
267 // be accessed while |error_lock_| is held. 276 // be accessed while |error_lock_| is held.
268 bool ignore_errors_during_stop_close_; 277 bool ignore_errors_during_stop_close_;
269 base::Lock error_lock_; 278 base::Lock error_lock_;
270 279
271 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); 280 DISALLOW_COPY_AND_ASSIGN(AudioOutputController);
272 }; 281 };
273 282
274 } // namespace media 283 } // namespace media
275 284
276 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ 285 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « content/browser/media/capture/web_contents_audio_muter.cc ('k') | media/audio/audio_output_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698