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/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "content/common/child_process.h" | 9 #include "content/common/child_process.h" |
10 #include "content/common/media/audio_messages.h" | 10 #include "content/common/media/audio_messages.h" |
11 #include "content/common/view_messages.h" | 11 #include "content/common/view_messages.h" |
12 #include "content/renderer/render_thread.h" | 12 #include "content/renderer/render_thread_impl.h" |
13 #include "media/audio/audio_util.h" | 13 #include "media/audio/audio_util.h" |
14 | 14 |
15 AudioInputDevice::AudioInputDevice(size_t buffer_size, | 15 AudioInputDevice::AudioInputDevice(size_t buffer_size, |
16 int channels, | 16 int channels, |
17 double sample_rate, | 17 double sample_rate, |
18 CaptureCallback* callback, | 18 CaptureCallback* callback, |
19 CaptureEventHandler* event_handler) | 19 CaptureEventHandler* event_handler) |
20 : callback_(callback), | 20 : callback_(callback), |
21 event_handler_(event_handler), | 21 event_handler_(event_handler), |
22 audio_delay_milliseconds_(0), | 22 audio_delay_milliseconds_(0), |
23 volume_(1.0), | 23 volume_(1.0), |
24 stream_id_(0), | 24 stream_id_(0), |
25 session_id_(0), | 25 session_id_(0), |
26 pending_device_ready_(false) { | 26 pending_device_ready_(false) { |
27 filter_ = RenderThread::current()->audio_input_message_filter(); | 27 filter_ = RenderThreadImpl::current()->audio_input_message_filter(); |
28 audio_data_.reserve(channels); | 28 audio_data_.reserve(channels); |
29 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
30 VLOG(1) << "Using AUDIO_PCM_LOW_LATENCY as input mode on Mac OS X."; | 30 VLOG(1) << "Using AUDIO_PCM_LOW_LATENCY as input mode on Mac OS X."; |
31 audio_parameters_.format = AudioParameters::AUDIO_PCM_LOW_LATENCY; | 31 audio_parameters_.format = AudioParameters::AUDIO_PCM_LOW_LATENCY; |
32 #else | 32 #else |
33 audio_parameters_.format = AudioParameters::AUDIO_PCM_LINEAR; | 33 audio_parameters_.format = AudioParameters::AUDIO_PCM_LINEAR; |
34 #endif | 34 #endif |
35 audio_parameters_.channels = channels; | 35 audio_parameters_.channels = channels; |
36 audio_parameters_.sample_rate = static_cast<int>(sample_rate); | 36 audio_parameters_.sample_rate = static_cast<int>(sample_rate); |
37 audio_parameters_.bits_per_sample = 16; | 37 audio_parameters_.bits_per_sample = 16; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 bytes_per_sample, | 314 bytes_per_sample, |
315 number_of_frames); | 315 number_of_frames); |
316 } | 316 } |
317 | 317 |
318 // Deliver captured data to the client in floating point format | 318 // Deliver captured data to the client in floating point format |
319 // and update the audio-delay measurement. | 319 // and update the audio-delay measurement. |
320 callback_->Capture(audio_data_, | 320 callback_->Capture(audio_data_, |
321 number_of_frames, | 321 number_of_frames, |
322 audio_delay_milliseconds_); | 322 audio_delay_milliseconds_); |
323 } | 323 } |
OLD | NEW |