| 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 #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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 dispatcher_->output_device_id == dispatcher_in->output_device_id); | 71 dispatcher_->output_device_id == dispatcher_in->output_device_id); |
| 72 } | 72 } |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 const DispatcherParams* dispatcher_; | 75 const DispatcherParams* dispatcher_; |
| 76 }; | 76 }; |
| 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 CreateAudioFileWriterCallback create_audio_file_writer_callback) |
| 82 : AudioManager(std::move(task_runner), std::move(worker_task_runner)), | 83 : AudioManager(std::move(task_runner), std::move(worker_task_runner)), |
| 83 max_num_output_streams_(kDefaultMaxOutputStreams), | 84 max_num_output_streams_(kDefaultMaxOutputStreams), |
| 84 max_num_input_streams_(kDefaultMaxInputStreams), | 85 max_num_input_streams_(kDefaultMaxInputStreams), |
| 85 num_output_streams_(0), | 86 num_output_streams_(0), |
| 86 // TODO(dalecurtis): Switch this to an base::ObserverListThreadSafe, so we | 87 // TODO(dalecurtis): Switch this to an base::ObserverListThreadSafe, so we |
| 87 // don't | 88 // don't block the UI thread when swapping devices. |
| 88 // block the UI thread when swapping devices. | |
| 89 output_listeners_( | 89 output_listeners_( |
| 90 base::ObserverList<AudioDeviceListener>::NOTIFY_EXISTING_ONLY), | 90 base::ObserverList<AudioDeviceListener>::NOTIFY_EXISTING_ONLY), |
| 91 audio_log_factory_(audio_log_factory) {} | 91 audio_log_factory_(audio_log_factory), |
| 92 output_debug_recording_manager_( |
| 93 std::move(create_audio_file_writer_callback), |
| 94 "output", |
| 95 GetTaskRunner()) {} |
| 92 | 96 |
| 93 AudioManagerBase::~AudioManagerBase() { | 97 AudioManagerBase::~AudioManagerBase() { |
| 94 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 98 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 95 | 99 |
| 96 // All the output streams should have been deleted. | 100 // All the output streams should have been deleted. |
| 97 CHECK_EQ(0, num_output_streams_); | 101 CHECK_EQ(0, num_output_streams_); |
| 98 // All the input streams should have been deleted. | 102 // All the input streams should have been deleted. |
| 99 CHECK(input_streams_.empty()); | 103 CHECK(input_streams_.empty()); |
| 100 } | 104 } |
| 101 | 105 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 if (it != output_dispatchers_.end()) { | 283 if (it != output_dispatchers_.end()) { |
| 280 delete dispatcher_params; | 284 delete dispatcher_params; |
| 281 return (*it)->dispatcher->CreateStreamProxy(); | 285 return (*it)->dispatcher->CreateStreamProxy(); |
| 282 } | 286 } |
| 283 | 287 |
| 284 const base::TimeDelta kCloseDelay = | 288 const base::TimeDelta kCloseDelay = |
| 285 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); | 289 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); |
| 286 std::unique_ptr<AudioOutputDispatcher> dispatcher; | 290 std::unique_ptr<AudioOutputDispatcher> dispatcher; |
| 287 if (output_params.format() != AudioParameters::AUDIO_FAKE) { | 291 if (output_params.format() != AudioParameters::AUDIO_FAKE) { |
| 288 dispatcher = base::MakeUnique<AudioOutputResampler>( | 292 dispatcher = base::MakeUnique<AudioOutputResampler>( |
| 289 this, params, output_params, output_device_id, kCloseDelay); | 293 this, params, output_params, output_device_id, kCloseDelay, |
| 294 base::Bind(&AudioDebugRecordingManager::RegisterDebugRecordingSource, |
| 295 base::Unretained(&output_debug_recording_manager_))); |
| 290 } else { | 296 } else { |
| 291 dispatcher = base::MakeUnique<AudioOutputDispatcherImpl>( | 297 dispatcher = base::MakeUnique<AudioOutputDispatcherImpl>( |
| 292 this, output_params, output_device_id, kCloseDelay); | 298 this, output_params, output_device_id, kCloseDelay); |
| 293 } | 299 } |
| 294 | 300 |
| 295 dispatcher_params->dispatcher = std::move(dispatcher); | 301 dispatcher_params->dispatcher = std::move(dispatcher); |
| 296 output_dispatchers_.push_back(dispatcher_params); | 302 output_dispatchers_.push_back(dispatcher_params); |
| 297 return dispatcher_params->dispatcher->CreateStreamProxy(); | 303 return dispatcher_params->dispatcher->CreateStreamProxy(); |
| 298 } | 304 } |
| 299 | 305 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 return buffer_size; | 432 return buffer_size; |
| 427 | 433 |
| 428 return 0; | 434 return 0; |
| 429 } | 435 } |
| 430 | 436 |
| 431 std::unique_ptr<AudioLog> AudioManagerBase::CreateAudioLog( | 437 std::unique_ptr<AudioLog> AudioManagerBase::CreateAudioLog( |
| 432 AudioLogFactory::AudioComponent component) { | 438 AudioLogFactory::AudioComponent component) { |
| 433 return audio_log_factory_->CreateAudioLog(component); | 439 return audio_log_factory_->CreateAudioLog(component); |
| 434 } | 440 } |
| 435 | 441 |
| 442 void AudioManagerBase::EnableOutputDebugRecording( |
| 443 const base::FilePath& base_file_name) { |
| 444 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 445 output_debug_recording_manager_.EnableDebugRecording(base_file_name); |
| 446 } |
| 447 |
| 448 void AudioManagerBase::DisableOutputDebugRecording() { |
| 449 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 450 output_debug_recording_manager_.DisableDebugRecording(); |
| 451 } |
| 452 |
| 436 void AudioManagerBase::SetMaxStreamCountForTesting(int max_input, | 453 void AudioManagerBase::SetMaxStreamCountForTesting(int max_input, |
| 437 int max_output) { | 454 int max_output) { |
| 438 max_num_output_streams_ = max_output; | 455 max_num_output_streams_ = max_output; |
| 439 max_num_input_streams_ = max_input; | 456 max_num_input_streams_ = max_input; |
| 440 } | 457 } |
| 441 | 458 |
| 442 } // namespace media | 459 } // namespace media |
| OLD | NEW |