| 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_device.h" | 5 #include "media/audio/audio_input_device.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "media/audio/audio_manager_base.h" | 11 #include "media/audio/audio_manager_base.h" |
| 12 #include "media/audio/audio_util.h" | |
| 13 #include "media/base/audio_bus.h" | 12 #include "media/base/audio_bus.h" |
| 14 | 13 |
| 15 namespace media { | 14 namespace media { |
| 16 | 15 |
| 17 AudioInputDevice::CaptureCallback::~CaptureCallback() {} | 16 AudioInputDevice::CaptureCallback::~CaptureCallback() {} |
| 18 AudioInputDevice::CaptureEventHandler::~CaptureEventHandler() {} | 17 AudioInputDevice::CaptureEventHandler::~CaptureEventHandler() {} |
| 19 | 18 |
| 20 // Takes care of invoking the capture callback on the audio thread. | 19 // Takes care of invoking the capture callback on the audio thread. |
| 21 // An instance of this class is created for each capture stream in | 20 // An instance of this class is created for each capture stream in |
| 22 // OnLowLatencyCreated(). | 21 // OnLowLatencyCreated(). |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 DCHECK_EQ(buffer->params.size, | 325 DCHECK_EQ(buffer->params.size, |
| 327 memory_length_ - sizeof(AudioInputBufferParameters)); | 326 memory_length_ - sizeof(AudioInputBufferParameters)); |
| 328 double volume = buffer->params.volume; | 327 double volume = buffer->params.volume; |
| 329 | 328 |
| 330 int audio_delay_milliseconds = pending_data / bytes_per_ms_; | 329 int audio_delay_milliseconds = pending_data / bytes_per_ms_; |
| 331 int16* memory = reinterpret_cast<int16*>(&buffer->audio[0]); | 330 int16* memory = reinterpret_cast<int16*>(&buffer->audio[0]); |
| 332 const int bytes_per_sample = sizeof(memory[0]); | 331 const int bytes_per_sample = sizeof(memory[0]); |
| 333 | 332 |
| 334 // Deinterleave each channel and convert to 32-bit floating-point | 333 // Deinterleave each channel and convert to 32-bit floating-point |
| 335 // with nominal range -1.0 -> +1.0. | 334 // with nominal range -1.0 -> +1.0. |
| 336 for (int channel_index = 0; channel_index < audio_bus_->channels(); | 335 audio_bus_->FromInterleaved(memory, audio_bus_->frames(), bytes_per_sample); |
| 337 ++channel_index) { | |
| 338 DeinterleaveAudioChannel(memory, | |
| 339 audio_bus_->channel(channel_index), | |
| 340 audio_bus_->channels(), | |
| 341 channel_index, | |
| 342 bytes_per_sample, | |
| 343 audio_bus_->frames()); | |
| 344 } | |
| 345 | 336 |
| 346 // Deliver captured data to the client in floating point format | 337 // Deliver captured data to the client in floating point format |
| 347 // and update the audio-delay measurement. | 338 // and update the audio-delay measurement. |
| 348 capture_callback_->Capture(audio_bus_.get(), | 339 capture_callback_->Capture(audio_bus_.get(), |
| 349 audio_delay_milliseconds, volume); | 340 audio_delay_milliseconds, volume); |
| 350 } | 341 } |
| 351 | 342 |
| 352 } // namespace media | 343 } // namespace media |
| OLD | NEW |