| 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_input_controller.h" | 5 #include "media/audio/audio_input_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "base/trace_event/trace_event.h" |
| 19 #include "media/audio/audio_input_writer.h" | 20 #include "media/audio/audio_input_writer.h" |
| 20 #include "media/base/user_input_monitor.h" | 21 #include "media/base/user_input_monitor.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 const int kMaxInputChannels = 3; | 25 const int kMaxInputChannels = 3; |
| 25 | 26 |
| 26 #if defined(AUDIO_POWER_MONITORING) | 27 #if defined(AUDIO_POWER_MONITORING) |
| 27 // Time in seconds between two successive measurements of audio power levels. | 28 // Time in seconds between two successive measurements of audio power levels. |
| 28 const int kPowerMonitorLogIntervalSeconds = 15; | 29 const int kPowerMonitorLogIntervalSeconds = 15; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 } | 413 } |
| 413 | 414 |
| 414 // Set the stream volume and scale to a range matched to the platform. | 415 // Set the stream volume and scale to a range matched to the platform. |
| 415 stream_->SetVolume(max_volume_ * volume); | 416 stream_->SetVolume(max_volume_ * volume); |
| 416 } | 417 } |
| 417 | 418 |
| 418 void AudioInputController::OnData(AudioInputStream* stream, | 419 void AudioInputController::OnData(AudioInputStream* stream, |
| 419 const AudioBus* source, | 420 const AudioBus* source, |
| 420 uint32_t hardware_delay_bytes, | 421 uint32_t hardware_delay_bytes, |
| 421 double volume) { | 422 double volume) { |
| 423 TRACE_EVENT0("audio", "AudioInputController::OnData"); |
| 422 if (debug_writer_ && debug_writer_->WillWrite()) { | 424 if (debug_writer_ && debug_writer_->WillWrite()) { |
| 423 std::unique_ptr<AudioBus> source_copy = | 425 std::unique_ptr<AudioBus> source_copy = |
| 424 AudioBus::Create(source->channels(), source->frames()); | 426 AudioBus::Create(source->channels(), source->frames()); |
| 425 source->CopyTo(source_copy.get()); | 427 source->CopyTo(source_copy.get()); |
| 426 task_runner_->PostTask( | 428 task_runner_->PostTask( |
| 427 FROM_HERE, | 429 FROM_HERE, |
| 428 base::Bind( | 430 base::Bind( |
| 429 &AudioInputController::WriteInputDataForDebugging, | 431 &AudioInputController::WriteInputDataForDebugging, |
| 430 this, | 432 this, |
| 431 base::Passed(&source_copy))); | 433 base::Passed(&source_copy))); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 if (debug_writer_) | 639 if (debug_writer_) |
| 638 debug_writer_->Write(std::move(data)); | 640 debug_writer_->Write(std::move(data)); |
| 639 } | 641 } |
| 640 | 642 |
| 641 void AudioInputController::LogMessage(const std::string& message) { | 643 void AudioInputController::LogMessage(const std::string& message) { |
| 642 DCHECK(task_runner_->BelongsToCurrentThread()); | 644 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 643 handler_->OnLog(this, message); | 645 handler_->OnLog(this, message); |
| 644 } | 646 } |
| 645 | 647 |
| 646 } // namespace media | 648 } // namespace media |
| OLD | NEW |