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

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

Issue 1897953003: Unmute Tab Audio For Desktop Share (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and Fix comments Created 4 years, 6 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 <stdint.h> 8 #include <stdint.h>
9
10 #include <memory> 9 #include <memory>
10 #include <set>
11 11
12 #include "base/atomic_ref_count.h" 12 #include "base/atomic_ref_count.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "media/audio/audio_io.h" 19 #include "media/audio/audio_io.h"
20 #include "media/audio/audio_manager.h" 20 #include "media/audio/audio_manager.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // AudioDeviceListener implementation. When called AudioOutputController will 171 // AudioDeviceListener implementation. When called AudioOutputController will
172 // shutdown the existing |stream_|, transition to the kRecreating state, 172 // shutdown the existing |stream_|, transition to the kRecreating state,
173 // 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
174 // to being called. 174 // to being called.
175 void OnDeviceChange() override; 175 void OnDeviceChange() override;
176 176
177 // AudioSourceDiverter implementation. 177 // AudioSourceDiverter implementation.
178 const AudioParameters& GetAudioParameters() override; 178 const AudioParameters& GetAudioParameters() override;
179 void StartDiverting(AudioOutputStream* to_stream) override; 179 void StartDiverting(AudioOutputStream* to_stream) override;
180 void StopDiverting() override; 180 void StopDiverting() override;
181 void StartDuplicating(AudioPushSink* sink) override;
182 void StopDuplicating(AudioPushSink* sink) override;
181 183
182 // Accessor for AudioPowerMonitor::ReadCurrentPowerAndClip(). See comments in 184 // Accessor for AudioPowerMonitor::ReadCurrentPowerAndClip(). See comments in
183 // 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.
184 std::pair<float, bool> ReadCurrentPowerAndClip(); 186 std::pair<float, bool> ReadCurrentPowerAndClip();
185 187
186 protected: 188 protected:
187 // Internal state of the source. 189 // Internal state of the source.
188 enum State { 190 enum State {
189 kEmpty, 191 kEmpty,
190 kCreated, 192 kCreated,
(...skipping 20 matching lines...) Expand all
211 void DoCreate(bool is_for_device_change); 213 void DoCreate(bool is_for_device_change);
212 void DoPlay(); 214 void DoPlay();
213 void DoPause(); 215 void DoPause();
214 void DoClose(); 216 void DoClose();
215 void DoSetVolume(double volume); 217 void DoSetVolume(double volume);
216 std::string DoGetOutputDeviceId() const; 218 std::string DoGetOutputDeviceId() const;
217 void DoSwitchOutputDevice(const std::string& output_device_id); 219 void DoSwitchOutputDevice(const std::string& output_device_id);
218 void DoReportError(); 220 void DoReportError();
219 void DoStartDiverting(AudioOutputStream* to_stream); 221 void DoStartDiverting(AudioOutputStream* to_stream);
220 void DoStopDiverting(); 222 void DoStopDiverting();
223 void DoStartDuplicating(AudioPushSink* sink);
224 void DoStopDuplicating(AudioPushSink* sink);
221 225
222 // Helper method that stops the physical stream. 226 // Helper method that stops the physical stream.
223 void StopStream(); 227 void StopStream();
224 228
225 // Helper method that stops, closes, and NULLs |*stream_|. 229 // Helper method that stops, closes, and NULLs |*stream_|.
226 void DoStopCloseAndClearStream(); 230 void DoStopCloseAndClearStream();
227 231
228 // Checks if a stream was started successfully but never calls OnMoreData(). 232 // Checks if a stream was started successfully but never calls OnMoreData().
229 void WedgeCheck(); 233 void WedgeCheck();
230 234
235 // Send audio data to each duplication targer.
miu 2016/06/01 00:29:42 typo: s/targer/target/
qiangchen 2016/06/01 17:51:12 Done.
236 void BroadcastDataToDuplicationTargets(std::unique_ptr<AudioBus> audio_bus,
237 base::TimeTicks reference_time);
238
231 AudioManager* const audio_manager_; 239 AudioManager* const audio_manager_;
232 const AudioParameters params_; 240 const AudioParameters params_;
233 EventHandler* const handler_; 241 EventHandler* const handler_;
234 242
235 // Specifies the device id of the output device to open or empty for the 243 // Specifies the device id of the output device to open or empty for the
236 // default output device. 244 // default output device.
237 std::string output_device_id_; 245 std::string output_device_id_;
238 246
239 AudioOutputStream* stream_; 247 AudioOutputStream* stream_;
240 248
241 // When non-NULL, audio is being diverted to this stream. 249 // When non-NULL, audio is being diverted to this stream.
242 AudioOutputStream* diverting_to_stream_; 250 AudioOutputStream* diverting_to_stream_;
243 251
252 // The targets for audio stream to be copied to.
253 std::set<AudioPushSink*> duplication_targets_;
254 base::Lock duplication_targets_lock_;
255
244 // The current volume of the audio stream. 256 // The current volume of the audio stream.
245 double volume_; 257 double volume_;
246 258
247 // |state_| may only be used on the audio manager thread. 259 // |state_| may only be used on the audio manager thread.
248 State state_; 260 State state_;
249 261
250 // SyncReader is used only in low latency mode for synchronous reading. 262 // SyncReader is used only in low latency mode for synchronous reading.
251 SyncReader* const sync_reader_; 263 SyncReader* const sync_reader_;
252 264
253 // The message loop of audio manager thread that this object runs on. 265 // The message loop of audio manager thread that this object runs on.
(...skipping 15 matching lines...) Expand all
269 // be accessed while |error_lock_| is held. 281 // be accessed while |error_lock_| is held.
270 bool ignore_errors_during_stop_close_; 282 bool ignore_errors_during_stop_close_;
271 base::Lock error_lock_; 283 base::Lock error_lock_;
272 284
273 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); 285 DISALLOW_COPY_AND_ASSIGN(AudioOutputController);
274 }; 286 };
275 287
276 } // namespace media 288 } // namespace media
277 289
278 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ 290 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698