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

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

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Code review. Created 3 years, 10 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 #include "media/audio/audio_manager_base.h" 5 #include "media/audio/audio_manager_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 AudioManagerBase::AudioManagerBase( 78 AudioManagerBase::AudioManagerBase(
79 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 79 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
80 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, 80 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
81 AudioLogFactory* audio_log_factory) 81 AudioLogFactory* audio_log_factory)
82 : AudioManager(std::move(task_runner), std::move(worker_task_runner)), 82 : AudioManager(std::move(task_runner), std::move(worker_task_runner)),
83 max_num_output_streams_(kDefaultMaxOutputStreams), 83 max_num_output_streams_(kDefaultMaxOutputStreams),
84 max_num_input_streams_(kDefaultMaxInputStreams), 84 max_num_input_streams_(kDefaultMaxInputStreams),
85 num_output_streams_(0), 85 num_output_streams_(0),
86 // TODO(dalecurtis): Switch this to an base::ObserverListThreadSafe, so we 86 // TODO(dalecurtis): Switch this to an base::ObserverListThreadSafe, so we
87 // don't 87 // don't block the UI thread when swapping devices.
88 // block the UI thread when swapping devices.
89 output_listeners_( 88 output_listeners_(
90 base::ObserverList<AudioDeviceListener>::NOTIFY_EXISTING_ONLY), 89 base::ObserverList<AudioDeviceListener>::NOTIFY_EXISTING_ONLY),
91 audio_log_factory_(audio_log_factory) {} 90 audio_log_factory_(audio_log_factory) {}
92 91
93 AudioManagerBase::~AudioManagerBase() { 92 AudioManagerBase::~AudioManagerBase() {
94 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 93 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
95 94
96 // All the output streams should have been deleted. 95 // All the output streams should have been deleted.
97 CHECK_EQ(0, num_output_streams_); 96 CHECK_EQ(0, num_output_streams_);
98 // All the input streams should have been deleted. 97 // All the input streams should have been deleted.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 CompareByParams(dispatcher_params)); 277 CompareByParams(dispatcher_params));
279 if (it != output_dispatchers_.end()) { 278 if (it != output_dispatchers_.end()) {
280 delete dispatcher_params; 279 delete dispatcher_params;
281 return (*it)->dispatcher->CreateStreamProxy(); 280 return (*it)->dispatcher->CreateStreamProxy();
282 } 281 }
283 282
284 const base::TimeDelta kCloseDelay = 283 const base::TimeDelta kCloseDelay =
285 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); 284 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds);
286 std::unique_ptr<AudioOutputDispatcher> dispatcher; 285 std::unique_ptr<AudioOutputDispatcher> dispatcher;
287 if (output_params.format() != AudioParameters::AUDIO_FAKE) { 286 if (output_params.format() != AudioParameters::AUDIO_FAKE) {
287 // Using unretained is safe since |output_debug_recording_manager_|
288 // outlives the dispatchers (cleared in Shutdown()).
288 dispatcher = base::MakeUnique<AudioOutputResampler>( 289 dispatcher = base::MakeUnique<AudioOutputResampler>(
289 this, params, output_params, output_device_id, kCloseDelay); 290 this, params, output_params, output_device_id, kCloseDelay,
291 base::Bind(&AudioDebugRecordingManager::RegisterDebugRecordingSource,
292 base::Unretained(output_debug_recording_manager_.get())));
o1ka 2017/01/31 11:00:11 Check if |output_debug_recording_manager_| is init
Henrik Grunell 2017/02/08 11:29:37 Yes, done.
290 } else { 293 } else {
291 dispatcher = base::MakeUnique<AudioOutputDispatcherImpl>( 294 dispatcher = base::MakeUnique<AudioOutputDispatcherImpl>(
292 this, output_params, output_device_id, kCloseDelay); 295 this, output_params, output_device_id, kCloseDelay);
293 } 296 }
294 297
295 dispatcher_params->dispatcher = std::move(dispatcher); 298 dispatcher_params->dispatcher = std::move(dispatcher);
296 output_dispatchers_.push_back(dispatcher_params); 299 output_dispatchers_.push_back(dispatcher_params);
297 return dispatcher_params->dispatcher->CreateStreamProxy(); 300 return dispatcher_params->dispatcher->CreateStreamProxy();
298 } 301 }
299 302
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 return buffer_size; 429 return buffer_size;
427 430
428 return 0; 431 return 0;
429 } 432 }
430 433
431 std::unique_ptr<AudioLog> AudioManagerBase::CreateAudioLog( 434 std::unique_ptr<AudioLog> AudioManagerBase::CreateAudioLog(
432 AudioLogFactory::AudioComponent component) { 435 AudioLogFactory::AudioComponent component) {
433 return audio_log_factory_->CreateAudioLog(component); 436 return audio_log_factory_->CreateAudioLog(component);
434 } 437 }
435 438
439 void AudioManagerBase::InitializeOutputDebugRecording(
440 CreateAudioFileWriterCallback create_audio_file_writer_callback) {
441 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
442 DCHECK(!output_debug_recording_manager_);
443 output_debug_recording_manager_ =
444 base::MakeUnique<AudioDebugRecordingManager>(
445 create_audio_file_writer_callback, "output", GetTaskRunner());
446 }
447
448 void AudioManagerBase::EnableOutputDebugRecording(
449 const base::FilePath& base_file_name) {
450 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
451 output_debug_recording_manager_->EnableDebugRecording(base_file_name);
o1ka 2017/01/31 11:00:11 Check if |output_debug_recording_manager_| is init
Henrik Grunell 2017/02/08 11:29:37 Enable() should not be called if Initialize() hasn
452 }
453
454 void AudioManagerBase::DisableOutputDebugRecording() {
455 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
456 if (output_debug_recording_manager_)
457 output_debug_recording_manager_->DisableDebugRecording();
458 }
459
436 void AudioManagerBase::SetMaxStreamCountForTesting(int max_input, 460 void AudioManagerBase::SetMaxStreamCountForTesting(int max_input,
437 int max_output) { 461 int max_output) {
438 max_num_output_streams_ = max_output; 462 max_num_output_streams_ = max_output;
439 max_num_input_streams_ = max_input; 463 max_num_input_streams_ = max_input;
440 } 464 }
441 465
442 } // namespace media 466 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698