| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/renderer/media/audio_input_device.h" | 5 #include "content/renderer/media/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/time.h" | 9 #include "base/time.h" |
| 10 #include "content/common/child_process.h" | 10 #include "content/common/child_process.h" |
| 11 #include "content/common/media/audio_messages.h" | 11 #include "content/common/media/audio_messages.h" |
| 12 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
| 13 #include "content/renderer/render_thread_impl.h" | 13 #include "content/renderer/render_thread_impl.h" |
| 14 #include "media/audio/audio_manager_base.h" | 14 #include "media/audio/audio_manager_base.h" |
| 15 #include "media/audio/audio_util.h" | 15 #include "media/audio/audio_util.h" |
| 16 | 16 |
| 17 AudioInputDevice::AudioInputDevice(size_t buffer_size, | 17 AudioInputDevice::AudioInputDevice(size_t buffer_size, |
| 18 int channels, | 18 int channels, |
| 19 double sample_rate, | 19 double sample_rate, |
| 20 CaptureCallback* callback, | 20 CaptureCallback* callback, |
| 21 CaptureEventHandler* event_handler) | 21 CaptureEventHandler* event_handler) |
| 22 : callback_(callback), | 22 : callback_(callback), |
| 23 event_handler_(event_handler), | 23 event_handler_(event_handler), |
| 24 audio_delay_milliseconds_(0), | 24 audio_delay_milliseconds_(0), |
| 25 volume_(1.0), | 25 volume_(1.0), |
| 26 stream_id_(0), | 26 stream_id_(0), |
| 27 session_id_(0), | 27 session_id_(0), |
| 28 pending_device_ready_(false), | 28 pending_device_ready_(false), |
| 29 shared_memory_handle_(base::SharedMemory::NULLHandle()), |
| 30 socket_handle_(base::SyncSocket::kInvalidHandle), |
| 29 memory_length_(0) { | 31 memory_length_(0) { |
| 30 filter_ = RenderThreadImpl::current()->audio_input_message_filter(); | 32 filter_ = RenderThreadImpl::current()->audio_input_message_filter(); |
| 31 audio_data_.reserve(channels); | 33 audio_data_.reserve(channels); |
| 32 #if defined(OS_MACOSX) | 34 #if defined(OS_MACOSX) |
| 33 VLOG(1) << "Using AUDIO_PCM_LOW_LATENCY as input mode on Mac OS X."; | 35 VLOG(1) << "Using AUDIO_PCM_LOW_LATENCY as input mode on Mac OS X."; |
| 34 audio_parameters_.format = AudioParameters::AUDIO_PCM_LOW_LATENCY; | 36 audio_parameters_.format = AudioParameters::AUDIO_PCM_LOW_LATENCY; |
| 35 #elif defined(OS_WIN) | 37 #elif defined(OS_WIN) |
| 36 VLOG(1) << "Using AUDIO_PCM_LOW_LATENCY as input mode on Windows."; | 38 VLOG(1) << "Using AUDIO_PCM_LOW_LATENCY as input mode on Windows."; |
| 37 audio_parameters_.format = AudioParameters::AUDIO_PCM_LOW_LATENCY; | 39 audio_parameters_.format = AudioParameters::AUDIO_PCM_LOW_LATENCY; |
| 38 #else | 40 #else |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 bytes_per_sample, | 331 bytes_per_sample, |
| 330 number_of_frames); | 332 number_of_frames); |
| 331 } | 333 } |
| 332 | 334 |
| 333 // Deliver captured data to the client in floating point format | 335 // Deliver captured data to the client in floating point format |
| 334 // and update the audio-delay measurement. | 336 // and update the audio-delay measurement. |
| 335 callback_->Capture(audio_data_, | 337 callback_->Capture(audio_data_, |
| 336 number_of_frames, | 338 number_of_frames, |
| 337 audio_delay_milliseconds_); | 339 audio_delay_milliseconds_); |
| 338 } | 340 } |
| OLD | NEW |