| Index: media/audio/audio_input_controller.cc
|
| diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc
|
| index 2127415b665a4103dcfcf0035c7b04a3fe2c5437..54eda2f06169f01b965d2db4f90f27480612c6dc 100644
|
| --- a/media/audio/audio_input_controller.cc
|
| +++ b/media/audio/audio_input_controller.cc
|
| @@ -12,6 +12,7 @@
|
| #include "base/thread_task_runner_handle.h"
|
| #include "base/threading/thread_restrictions.h"
|
| #include "base/time/time.h"
|
| +#include "media/audio/audio_input_writer.h"
|
| #include "media/base/user_input_monitor.h"
|
|
|
| using base::TimeDelta;
|
| @@ -134,7 +135,8 @@ AudioInputController::AudioInputController(EventHandler* handler,
|
| log_silence_state_(false),
|
| silence_state_(SILENCE_STATE_NO_MEASUREMENT),
|
| #endif
|
| - prev_key_down_count_(0) {
|
| + prev_key_down_count_(0),
|
| + input_writer_(nullptr) {
|
| DCHECK(creator_task_runner_.get());
|
| }
|
|
|
| @@ -432,6 +434,8 @@ void AudioInputController::DoClose() {
|
| log_silence_state_ = false;
|
| #endif
|
|
|
| + input_writer_ = nullptr;
|
| +
|
| state_ = CLOSED;
|
| }
|
|
|
| @@ -505,6 +509,21 @@ void AudioInputController::OnData(AudioInputStream* stream,
|
| const AudioBus* source,
|
| uint32 hardware_delay_bytes,
|
| double volume) {
|
| + // |input_writer_| should only be accessed on the audio thread, but as a means
|
| + // to avoid copying data and posting on the audio thread, we just check for
|
| + // non-null here.
|
| + if (input_writer_) {
|
| + scoped_ptr<AudioBus> source_copy =
|
| + AudioBus::Create(source->channels(), source->frames());
|
| + source->CopyTo(source_copy.get());
|
| + task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(
|
| + &AudioInputController::WriteInputDataForDebugging,
|
| + this,
|
| + base::Passed(&source_copy)));
|
| + }
|
| +
|
| // Mark data as active to ensure that the periodic calls to
|
| // DoCheckForNoData() does not report an error to the event handler.
|
| SetDataIsActive(true);
|
| @@ -623,6 +642,26 @@ void AudioInputController::OnError(AudioInputStream* stream) {
|
| &AudioInputController::DoReportError, this));
|
| }
|
|
|
| +void AudioInputController::EnableDebugRecording(
|
| + AudioInputWriter* input_writer) {
|
| + task_runner_->PostTask(FROM_HERE, base::Bind(
|
| + &AudioInputController::DoEnableDebugRecording,
|
| + this,
|
| + input_writer));
|
| +}
|
| +
|
| +void AudioInputController::DisableDebugRecording(
|
| + const base::Closure& callback) {
|
| + DCHECK(creator_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(!callback.is_null());
|
| +
|
| + task_runner_->PostTaskAndReply(
|
| + FROM_HERE,
|
| + base::Bind(&AudioInputController::DoDisableDebugRecording,
|
| + this),
|
| + callback);
|
| +}
|
| +
|
| void AudioInputController::DoStopCloseAndClearStream() {
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
|
|
| @@ -675,4 +714,23 @@ void AudioInputController::LogSilenceState(SilenceState value) {
|
| }
|
| #endif
|
|
|
| +void AudioInputController::DoEnableDebugRecording(
|
| + AudioInputWriter* input_writer) {
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
| + DCHECK(!input_writer_);
|
| + input_writer_ = input_writer;
|
| +}
|
| +
|
| +void AudioInputController::DoDisableDebugRecording() {
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
| + input_writer_ = nullptr;
|
| +}
|
| +
|
| +void AudioInputController::WriteInputDataForDebugging(
|
| + scoped_ptr<AudioBus> data) {
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
| + if (input_writer_)
|
| + input_writer_->Write(data.Pass());
|
| +}
|
| +
|
| } // namespace media
|
|
|