Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: content/renderer/media/webrtc_audio_device_impl.cc

Issue 8440002: Low-latency AudioOutputStream implementation based on WASAPI for Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Modified buffer handling and improved unit test Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/audio/audio_util.cc » ('j') | media/audio/audio_util.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/webrtc_audio_device_impl.h" 5 #include "content/renderer/media/webrtc_audio_device_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/win/windows_version.h"
9 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
10 #include "content/renderer/render_thread_impl.h" 11 #include "content/renderer/render_thread_impl.h"
11 #include "media/audio/audio_util.h" 12 #include "media/audio/audio_util.h"
12 13
13 static const int64 kMillisecondsBetweenProcessCalls = 5000; 14 static const int64 kMillisecondsBetweenProcessCalls = 5000;
14 static const char kVersion[] = "WebRTC AudioDevice 1.0.0.Chrome"; 15 static const char kVersion[] = "WebRTC AudioDevice 1.0.0.Chrome";
15 16
16 static int GetAudioInputHardwareSampleRate() { 17 static int GetAudioInputHardwareSampleRate() {
17 static double input_sample_rate = 0; 18 static double input_sample_rate = 0;
18 if (!input_sample_rate) { 19 if (!input_sample_rate) {
(...skipping 14 matching lines...) Expand all
33 input_sample_rate_(0), 34 input_sample_rate_(0),
34 output_sample_rate_(0), 35 output_sample_rate_(0),
35 input_delay_ms_(0), 36 input_delay_ms_(0),
36 output_delay_ms_(0), 37 output_delay_ms_(0),
37 last_error_(AudioDeviceModule::kAdmErrNone), 38 last_error_(AudioDeviceModule::kAdmErrNone),
38 last_process_time_(base::TimeTicks::Now()), 39 last_process_time_(base::TimeTicks::Now()),
39 session_id_(0), 40 session_id_(0),
40 initialized_(false), 41 initialized_(false),
41 playing_(false), 42 playing_(false),
42 recording_(false) { 43 recording_(false) {
43 VLOG(1) << "WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()"; 44 DVLOG(1) << "WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()";
44 DCHECK(RenderThreadImpl::current()) << 45 DCHECK(RenderThreadImpl::current()) <<
45 "WebRtcAudioDeviceImpl must be constructed on the render thread"; 46 "WebRtcAudioDeviceImpl must be constructed on the render thread";
46 } 47 }
47 48
48 WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl() { 49 WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl() {
49 VLOG(1) << "WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl()"; 50 DVLOG(1) << "WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl()";
50 if (playing_) 51 if (playing_)
51 StopPlayout(); 52 StopPlayout();
52 if (recording_) 53 if (recording_)
53 StopRecording(); 54 StopRecording();
54 if (initialized_) 55 if (initialized_)
55 Terminate(); 56 Terminate();
56 } 57 }
57 58
58 int32_t WebRtcAudioDeviceImpl::AddRef() { 59 int32_t WebRtcAudioDeviceImpl::AddRef() {
59 return base::subtle::Barrier_AtomicIncrement(&ref_count_, 1); 60 return base::subtle::Barrier_AtomicIncrement(&ref_count_, 1);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 input_delay_ms_ + output_delay_ms_, 168 input_delay_ms_ + output_delay_ms_,
168 0, // clock_drift 169 0, // clock_drift
169 0, // current_mic_level 170 0, // current_mic_level
170 new_mic_level); // not used 171 new_mic_level); // not used
171 accumulated_audio_samples += samples_per_10_msec; 172 accumulated_audio_samples += samples_per_10_msec;
172 audio_byte_buffer += bytes_per_10_msec; 173 audio_byte_buffer += bytes_per_10_msec;
173 } 174 }
174 } 175 }
175 176
176 void WebRtcAudioDeviceImpl::OnDeviceStarted(int device_index) { 177 void WebRtcAudioDeviceImpl::OnDeviceStarted(int device_index) {
177 VLOG(1) << "OnDeviceStarted (device_index=" << device_index << ")"; 178 DVLOG(1) << "OnDeviceStarted (device_index=" << device_index << ")";
178 // -1 is an invalid device index. Do nothing if a valid device has 179 // -1 is an invalid device index. Do nothing if a valid device has
179 // been started. Otherwise update the |recording_| state to false. 180 // been started. Otherwise update the |recording_| state to false.
180 if (device_index != -1) 181 if (device_index != -1)
181 return; 182 return;
182 183
183 base::AutoLock auto_lock(lock_); 184 base::AutoLock auto_lock(lock_);
184 if (recording_) 185 if (recording_)
185 recording_ = false; 186 recording_ = false;
186 } 187 }
187 188
188 void WebRtcAudioDeviceImpl::OnDeviceStopped() { 189 void WebRtcAudioDeviceImpl::OnDeviceStopped() {
189 VLOG(1) << "OnDeviceStopped"; 190 DVLOG(1) << "OnDeviceStopped";
190 base::AutoLock auto_lock(lock_); 191 base::AutoLock auto_lock(lock_);
191 if (recording_) 192 if (recording_)
192 recording_ = false; 193 recording_ = false;
193 } 194 }
194 195
195 int32_t WebRtcAudioDeviceImpl::Version(char* version, 196 int32_t WebRtcAudioDeviceImpl::Version(char* version,
196 uint32_t& remaining_buffer_in_bytes, 197 uint32_t& remaining_buffer_in_bytes,
197 uint32_t& position) const { 198 uint32_t& position) const {
198 VLOG(1) << "Version()"; 199 DVLOG(1) << "Version()";
199 DCHECK(version); 200 DCHECK(version);
200 if (version == NULL) 201 if (version == NULL)
201 return -1; 202 return -1;
202 size_t arr_size = arraysize(kVersion); 203 size_t arr_size = arraysize(kVersion);
203 if (remaining_buffer_in_bytes < arr_size) { 204 if (remaining_buffer_in_bytes < arr_size) {
204 DLOG(WARNING) << "version string requires " << arr_size << " bytes"; 205 DLOG(WARNING) << "version string requires " << arr_size << " bytes";
205 return -1; 206 return -1;
206 } 207 }
207 base::strlcpy(&version[position], kVersion, arr_size - 1); 208 base::strlcpy(&version[position], kVersion, arr_size - 1);
208 remaining_buffer_in_bytes -= arr_size; 209 remaining_buffer_in_bytes -= arr_size;
209 position += arr_size; 210 position += arr_size;
210 VLOG(1) << "version: " << version; 211 DVLOG(1) << "version: " << version;
211 return 0; 212 return 0;
212 } 213 }
213 214
214 int32_t WebRtcAudioDeviceImpl::ChangeUniqueId(const int32_t id) { 215 int32_t WebRtcAudioDeviceImpl::ChangeUniqueId(const int32_t id) {
215 NOTIMPLEMENTED(); 216 NOTIMPLEMENTED();
216 return -1; 217 return -1;
217 } 218 }
218 219
219 int32_t WebRtcAudioDeviceImpl::TimeUntilNextProcess() { 220 int32_t WebRtcAudioDeviceImpl::TimeUntilNextProcess() {
220 // Calculate the number of milliseconds until this module wants its 221 // Calculate the number of milliseconds until this module wants its
(...skipping 17 matching lines...) Expand all
238 NOTIMPLEMENTED(); 239 NOTIMPLEMENTED();
239 return -1; 240 return -1;
240 } 241 }
241 242
242 webrtc::AudioDeviceModule::ErrorCode WebRtcAudioDeviceImpl::LastError() const { 243 webrtc::AudioDeviceModule::ErrorCode WebRtcAudioDeviceImpl::LastError() const {
243 return last_error_; 244 return last_error_;
244 } 245 }
245 246
246 int32_t WebRtcAudioDeviceImpl::RegisterEventObserver( 247 int32_t WebRtcAudioDeviceImpl::RegisterEventObserver(
247 webrtc::AudioDeviceObserver* event_callback) { 248 webrtc::AudioDeviceObserver* event_callback) {
248 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::RegisterEventObserver() " 249 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::RegisterEventObserver() "
249 << "NOT IMPLEMENTED"; 250 << "NOT IMPLEMENTED";
250 return -1; 251 return -1;
251 } 252 }
252 253
253 int32_t WebRtcAudioDeviceImpl::RegisterAudioCallback( 254 int32_t WebRtcAudioDeviceImpl::RegisterAudioCallback(
254 webrtc::AudioTransport* audio_callback) { 255 webrtc::AudioTransport* audio_callback) {
255 VLOG(1) << "RegisterAudioCallback()"; 256 DVLOG(1) << "RegisterAudioCallback()";
256 if (playing_ || recording_) { 257 if (playing_ || recording_) {
257 LOG(ERROR) << "Unable to (de)register transport during active media"; 258 LOG(ERROR) << "Unable to (de)register transport during active media";
258 return -1; 259 return -1;
259 } 260 }
260 audio_transport_callback_ = audio_callback; 261 audio_transport_callback_ = audio_callback;
261 return 0; 262 return 0;
262 } 263 }
263 264
264 int32_t WebRtcAudioDeviceImpl::Init() { 265 int32_t WebRtcAudioDeviceImpl::Init() {
265 VLOG(1) << "Init()"; 266 DVLOG(1) << "Init()";
266 267
267 if (!render_loop_->BelongsToCurrentThread()) { 268 if (!render_loop_->BelongsToCurrentThread()) {
268 int32_t error = 0; 269 int32_t error = 0;
269 base::WaitableEvent event(false, false); 270 base::WaitableEvent event(false, false);
270 // Ensure that we call Init() from the main render thread since 271 // Ensure that we call Init() from the main render thread since
271 // the audio clients can only be created on this thread. 272 // the audio clients can only be created on this thread.
272 render_loop_->PostTask( 273 render_loop_->PostTask(
273 FROM_HERE, 274 FROM_HERE,
274 base::Bind(&WebRtcAudioDeviceImpl::InitOnRenderThread, 275 base::Bind(&WebRtcAudioDeviceImpl::InitOnRenderThread,
275 this, &error, &event)); 276 this, &error, &event));
276 event.Wait(); 277 event.Wait();
277 return error; 278 return error;
278 } 279 }
279 280
280 // Calling Init() multiple times in a row is OK. 281 // Calling Init() multiple times in a row is OK.
281 if (initialized_) 282 if (initialized_)
282 return 0; 283 return 0;
283 284
284 DCHECK(!audio_input_device_); 285 DCHECK(!audio_input_device_);
285 DCHECK(!audio_output_device_); 286 DCHECK(!audio_output_device_);
286 DCHECK(!input_buffer_.get()); 287 DCHECK(!input_buffer_.get());
287 DCHECK(!output_buffer_.get()); 288 DCHECK(!output_buffer_.get());
288 289
289 // Ask the browser for the default audio output hardware sample-rate. 290 // Ask the browser for the default audio output hardware sample-rate.
290 // This request is based on a synchronous IPC message. 291 // This request is based on a synchronous IPC message.
291 int output_sample_rate = 292 int output_sample_rate =
292 static_cast<int>(AudioDevice::GetAudioHardwareSampleRate()); 293 static_cast<int>(AudioDevice::GetAudioHardwareSampleRate());
293 VLOG(1) << "Audio output hardware sample rate: " << output_sample_rate; 294 DVLOG(1) << "Audio output hardware sample rate: " << output_sample_rate;
294 295
295 // Ask the browser for the default audio input hardware sample-rate. 296 // Ask the browser for the default audio input hardware sample-rate.
296 // This request is based on a synchronous IPC message. 297 // This request is based on a synchronous IPC message.
297 int input_sample_rate = GetAudioInputHardwareSampleRate(); 298 int input_sample_rate = GetAudioInputHardwareSampleRate();
298 VLOG(1) << "Audio input hardware sample rate: " << input_sample_rate; 299 DVLOG(1) << "Audio input hardware sample rate: " << input_sample_rate;
299 300
300 int input_channels = 0; 301 int input_channels = 0;
301 int output_channels = 0; 302 int output_channels = 0;
302 303
303 size_t input_buffer_size = 0; 304 size_t input_buffer_size = 0;
304 size_t output_buffer_size = 0; 305 size_t output_buffer_size = 0;
305 306
306 // For real-time audio (in combination with the webrtc::VoiceEngine) it 307 // Windows
307 // is convenient to use audio buffers of size N*10ms.
308
309 #if defined(OS_WIN) 308 #if defined(OS_WIN)
310 if (output_sample_rate != 48000) { 309 if (input_sample_rate != 48000 && input_sample_rate != 44100) {
311 DLOG(ERROR) << "Only 48kHz sample rate is supported on Windows."; 310 DLOG(ERROR) << "Only 48 and 44.1kHz input rates are supported on Windows.";
311 return -1;
312 }
313 if (output_sample_rate != 48000 && output_sample_rate != 44100) {
314 DLOG(ERROR) << "Only 48 and 44.1kHz output rates are supported on Windows.";
312 return -1; 315 return -1;
313 } 316 }
314 317
315 // Use stereo recording on Windows since low-latency Core Audio (WASAPI) 318 // Use stereo recording on Windows since low-latency Core Audio (WASAPI)
316 // does not support mono. 319 // does not support mono.
317 input_channels = 2; 320 input_channels = 2;
318 output_channels = 1; 321
322 // Use stereo rendering on Windows to make input and output sides
323 // symmetric. WASAPI supports both stereo and mono.
324 output_channels = 2;
319 325
320 // Capture side: AUDIO_PCM_LOW_LATENCY is based on the Core Audio (WASAPI) 326 // Capture side: AUDIO_PCM_LOW_LATENCY is based on the Core Audio (WASAPI)
321 // API which was introduced in Windows Vista. For lower Windows versions, 327 // API which was introduced in Windows Vista. For lower Windows versions,
322 // a callback-driven Wave implementation is used instead. An input buffer 328 // a callback-driven Wave implementation is used instead. An input buffer
323 // size of 10ms works well for both these implementations. 329 // size of 10ms works well for both these implementations.
324 330
325 // Use different buffer sizes depending on the current hardware sample rate. 331 // Use different buffer sizes depending on the current hardware sample rate.
326 if (input_sample_rate == 48000) { 332 if (input_sample_rate == 48000) {
327 input_buffer_size = 480; 333 input_buffer_size = 480;
328 } else { 334 } else {
329 // We do run at 44.1kHz at the actual audio layer, but ask for frames 335 // We do run at 44.1kHz at the actual audio layer, but ask for frames
330 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine. 336 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine.
331 input_buffer_size = 440; 337 input_buffer_size = 440;
332 } 338 }
333 339
334 // Rendering side: AUDIO_PCM_LOW_LATENCY on Windows is based on a callback- 340 // Render side: AUDIO_PCM_LOW_LATENCY is based on the Core Audio (WASAPI)
335 // driven Wave implementation where 2 buffers are fed to the audio driver 341 // API which was introduced in Windows Vista. For lower Windows versions,
336 // before actual rendering starts. Initial real-time tests have shown that 342 // a callback-driven Wave implementation is used instead. An output buffer
337 // 20ms buffer size (corresponds to ~40ms total delay) is not enough but 343 // size of 10ms works well for WASAPI but 30ms is needed for Wave.
338 // can lead to buffer underruns. The next even multiple of 10ms is 30ms
339 // (<=> ~60ms total delay) and it works fine also under high load.
340 output_buffer_size = 3 * 480;
341 #elif defined(OS_MACOSX)
342 if (output_sample_rate != 48000 && output_sample_rate != 44100) {
343 DLOG(ERROR) << "Only 48 and 44.1kHz sample rates are supported on Mac OSX.";
344 return -1;
345 }
346 input_channels = 1;
347 output_channels = 1;
348
349 // Rendering side: AUDIO_PCM_LOW_LATENCY on Mac OS X is based on a callback-
350 // driven Core Audio implementation. Tests have shown that 10ms is a suitable
351 // frame size to use, both for 48kHz and 44.1kHz.
352 // Capturing side: AUDIO_PCM_LINEAR on Mac OS X uses the Audio Queue Services
353 // API which is not well suited for real-time applications since the delay
354 // is very high. We set buffer sizes to 10ms for the input side here as well
355 // but none of them will work.
356 // TODO(henrika): add support for AUDIO_PCM_LOW_LATENCY on the capture side
357 // based on the Mac OS X Core Audio API.
358 344
359 // Use different buffer sizes depending on the current hardware sample rate. 345 // Use different buffer sizes depending on the current hardware sample rate.
360 if (output_sample_rate == 48000) { 346 if (output_sample_rate == 48000) {
361 input_buffer_size = 480;
362 output_buffer_size = 480; 347 output_buffer_size = 480;
363 } else { 348 } else {
364 // We do run at 44.1kHz at the actual audio layer, but ask for frames 349 // We do run at 44.1kHz at the actual audio layer, but ask for frames
365 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine. 350 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine.
351 // TODO(henrika): figure out why we seem to need 20ms here for glitch-
352 // free audio.
353 output_buffer_size = 2 * 440;
354 }
355
356 // Windows XP and lower can't cope with 10 ms output buffer size.
357 // It must be extended to 30 ms (60 ms will be used internally by WaveOut).
358 if (base::win::GetVersion() <= base::win::VERSION_XP) {
359 output_buffer_size = 3 * output_buffer_size;
360 DLOG(WARNING) << "Extending the output buffer size by a factor of three "
361 << "since Windows XP has been detected.";
362 }
363
364 // Mac OS X
365 #elif defined(OS_MACOSX)
366 if (input_sample_rate != 48000 && input_sample_rate != 44100) {
367 DLOG(ERROR) << "Only 48 and 44.1kHz input rates are supported on Mac OSX.";
368 return -1;
369 }
370 if (output_sample_rate != 48000 && output_sample_rate != 44100) {
371 DLOG(ERROR) << "Only 48 and 44.1kHz output rates are supported on Mac OSX.";
372 return -1;
373 }
374
375 input_channels = 1;
376 output_channels = 1;
377
378 // Capture side: AUDIO_PCM_LOW_LATENCY on Mac OS X is based on a callback-
379 // driven Core Audio implementation. Tests have shown that 10ms is a suitable
380 // frame size to use, both for 48kHz and 44.1kHz.
381
382 // Use different buffer sizes depending on the current hardware sample rate.
383 if (input_sample_rate == 48000) {
384 input_buffer_size = 480;
385 } else {
386 // We do run at 44.1kHz at the actual audio layer, but ask for frames
387 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine.
366 input_buffer_size = 440; 388 input_buffer_size = 440;
389 }
390
391 // Render side: AUDIO_PCM_LOW_LATENCY on Mac OS X is based on a callback-
392 // driven Core Audio implementation. Tests have shown that 10ms is a suitable
393 // frame size to use, both for 48kHz and 44.1kHz.
394
395 // Use different buffer sizes depending on the current hardware sample rate.
396 if (output_sample_rate == 48000) {
397 output_buffer_size = 480;
398 } else {
399 // We do run at 44.1kHz at the actual audio layer, but ask for frames
400 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine.
367 output_buffer_size = 440; 401 output_buffer_size = 440;
368 } 402 }
403
404 // Linux
369 #elif defined(OS_LINUX) 405 #elif defined(OS_LINUX)
370 if (output_sample_rate != 48000) { 406 if (output_sample_rate != 48000) {
371 DLOG(ERROR) << "Only 48kHz sample rate is supported on Linux."; 407 DLOG(ERROR) << "Only 48kHz sample rate is supported on Linux.";
372 return -1; 408 return -1;
373 } 409 }
374 input_channels = 1; 410 input_channels = 1;
375 output_channels = 1; 411 output_channels = 1;
376 412
377 // Based on tests using the current ALSA implementation in Chrome, we have 413 // Based on tests using the current ALSA implementation in Chrome, we have
378 // found that the best combination is 20ms on the input side and 10ms on the 414 // found that the best combination is 20ms on the input side and 10ms on the
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 input_buffer_.reset(new int16[input_buffer_size * input_channels]); 450 input_buffer_.reset(new int16[input_buffer_size * input_channels]);
415 output_buffer_.reset(new int16[output_buffer_size * output_channels]); 451 output_buffer_.reset(new int16[output_buffer_size * output_channels]);
416 452
417 DCHECK(input_buffer_.get()); 453 DCHECK(input_buffer_.get());
418 DCHECK(output_buffer_.get()); 454 DCHECK(output_buffer_.get());
419 455
420 bytes_per_sample_ = sizeof(*input_buffer_.get()); 456 bytes_per_sample_ = sizeof(*input_buffer_.get());
421 457
422 initialized_ = true; 458 initialized_ = true;
423 459
424 VLOG(1) << "Capture parameters (size/channels/rate): (" 460 DVLOG(1) << "Capture parameters (size/channels/rate): ("
425 << input_buffer_size_ << "/" << input_channels_ << "/" 461 << input_buffer_size_ << "/" << input_channels_ << "/"
426 << input_sample_rate_ << ")"; 462 << input_sample_rate_ << ")";
427 VLOG(1) << "Render parameters (size/channels/rate): (" 463 DVLOG(1) << "Render parameters (size/channels/rate): ("
428 << output_buffer_size_ << "/" << output_channels_ << "/" 464 << output_buffer_size_ << "/" << output_channels_ << "/"
429 << output_sample_rate_ << ")"; 465 << output_sample_rate_ << ")";
430 return 0; 466 return 0;
431 } 467 }
432 468
433 void WebRtcAudioDeviceImpl::InitOnRenderThread(int32_t* error, 469 void WebRtcAudioDeviceImpl::InitOnRenderThread(int32_t* error,
434 base::WaitableEvent* event) { 470 base::WaitableEvent* event) {
435 DCHECK(render_loop_->BelongsToCurrentThread()); 471 DCHECK(render_loop_->BelongsToCurrentThread());
436 *error = Init(); 472 *error = Init();
437 event->Signal(); 473 event->Signal();
438 } 474 }
439 475
440 int32_t WebRtcAudioDeviceImpl::Terminate() { 476 int32_t WebRtcAudioDeviceImpl::Terminate() {
441 VLOG(1) << "Terminate()"; 477 DVLOG(1) << "Terminate()";
442 478
443 // Calling Terminate() multiple times in a row is OK. 479 // Calling Terminate() multiple times in a row is OK.
444 if (!initialized_) 480 if (!initialized_)
445 return 0; 481 return 0;
446 482
447 DCHECK(audio_input_device_); 483 DCHECK(audio_input_device_);
448 DCHECK(audio_output_device_); 484 DCHECK(audio_output_device_);
449 DCHECK(input_buffer_.get()); 485 DCHECK(input_buffer_.get());
450 DCHECK(output_buffer_.get()); 486 DCHECK(output_buffer_.get());
451 487
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 519
484 int32_t WebRtcAudioDeviceImpl::RecordingDeviceName( 520 int32_t WebRtcAudioDeviceImpl::RecordingDeviceName(
485 uint16_t index, 521 uint16_t index,
486 char name[webrtc::kAdmMaxDeviceNameSize], 522 char name[webrtc::kAdmMaxDeviceNameSize],
487 char guid[webrtc::kAdmMaxGuidSize]) { 523 char guid[webrtc::kAdmMaxGuidSize]) {
488 NOTIMPLEMENTED(); 524 NOTIMPLEMENTED();
489 return -1; 525 return -1;
490 } 526 }
491 527
492 int32_t WebRtcAudioDeviceImpl::SetPlayoutDevice(uint16_t index) { 528 int32_t WebRtcAudioDeviceImpl::SetPlayoutDevice(uint16_t index) {
493 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetPlayoutDevice() " 529 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetPlayoutDevice() "
494 << "NOT IMPLEMENTED"; 530 << "NOT IMPLEMENTED";
495 return 0; 531 return 0;
496 } 532 }
497 533
498 int32_t WebRtcAudioDeviceImpl::SetPlayoutDevice(WindowsDeviceType device) { 534 int32_t WebRtcAudioDeviceImpl::SetPlayoutDevice(WindowsDeviceType device) {
499 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetPlayoutDevice() " 535 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetPlayoutDevice() "
500 << "NOT IMPLEMENTED"; 536 << "NOT IMPLEMENTED";
501 return 0; 537 return 0;
502 } 538 }
503 539
504 int32_t WebRtcAudioDeviceImpl::SetRecordingDevice(uint16_t index) { 540 int32_t WebRtcAudioDeviceImpl::SetRecordingDevice(uint16_t index) {
505 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetRecordingDevice() " 541 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetRecordingDevice() "
506 << "NOT IMPLEMENTED"; 542 << "NOT IMPLEMENTED";
507 return 0; 543 return 0;
508 } 544 }
509 545
510 int32_t WebRtcAudioDeviceImpl::SetRecordingDevice(WindowsDeviceType device) { 546 int32_t WebRtcAudioDeviceImpl::SetRecordingDevice(WindowsDeviceType device) {
511 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetRecordingDevice() " 547 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetRecordingDevice() "
512 << "NOT IMPLEMENTED"; 548 << "NOT IMPLEMENTED";
513 return 0; 549 return 0;
514 } 550 }
515 551
516 int32_t WebRtcAudioDeviceImpl::PlayoutIsAvailable(bool* available) { 552 int32_t WebRtcAudioDeviceImpl::PlayoutIsAvailable(bool* available) {
517 VLOG(1) << "PlayoutIsAvailable()"; 553 DVLOG(1) << "PlayoutIsAvailable()";
518 *available = (audio_output_device_ != NULL); 554 *available = (audio_output_device_ != NULL);
519 return 0; 555 return 0;
520 } 556 }
521 557
522 int32_t WebRtcAudioDeviceImpl::InitPlayout() { 558 int32_t WebRtcAudioDeviceImpl::InitPlayout() {
523 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::InitPlayout() " 559 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::InitPlayout() "
524 << "NOT IMPLEMENTED"; 560 << "NOT IMPLEMENTED";
525 return 0; 561 return 0;
526 } 562 }
527 563
528 bool WebRtcAudioDeviceImpl::PlayoutIsInitialized() const { 564 bool WebRtcAudioDeviceImpl::PlayoutIsInitialized() const {
529 VLOG(1) << "PlayoutIsInitialized()"; 565 DVLOG(1) << "PlayoutIsInitialized()";
530 return (audio_output_device_ != NULL); 566 return (audio_output_device_ != NULL);
531 } 567 }
532 568
533 int32_t WebRtcAudioDeviceImpl::RecordingIsAvailable(bool* available) { 569 int32_t WebRtcAudioDeviceImpl::RecordingIsAvailable(bool* available) {
534 VLOG(1) << "RecordingIsAvailable()"; 570 DVLOG(1) << "RecordingIsAvailable()";
535 *available = (audio_input_device_ != NULL); 571 *available = (audio_input_device_ != NULL);
536 return 0; 572 return 0;
537 } 573 }
538 574
539 int32_t WebRtcAudioDeviceImpl::InitRecording() { 575 int32_t WebRtcAudioDeviceImpl::InitRecording() {
540 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::InitRecording() " 576 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::InitRecording() "
541 << "NOT IMPLEMENTED"; 577 << "NOT IMPLEMENTED";
542 return 0; 578 return 0;
543 } 579 }
544 580
545 bool WebRtcAudioDeviceImpl::RecordingIsInitialized() const { 581 bool WebRtcAudioDeviceImpl::RecordingIsInitialized() const {
546 VLOG(1) << "RecordingIsInitialized()"; 582 DVLOG(1) << "RecordingIsInitialized()";
547 return (audio_input_device_ != NULL); 583 return (audio_input_device_ != NULL);
548 } 584 }
549 585
550 int32_t WebRtcAudioDeviceImpl::StartPlayout() { 586 int32_t WebRtcAudioDeviceImpl::StartPlayout() {
551 VLOG(1) << "StartPlayout()"; 587 DVLOG(1) << "StartPlayout()";
552 if (!audio_transport_callback_) { 588 if (!audio_transport_callback_) {
553 LOG(ERROR) << "Audio transport is missing"; 589 LOG(ERROR) << "Audio transport is missing";
554 return -1; 590 return -1;
555 } 591 }
556 if (playing_) { 592 if (playing_) {
557 // webrtc::VoiceEngine assumes that it is OK to call Start() twice and 593 // webrtc::VoiceEngine assumes that it is OK to call Start() twice and
558 // that the call is ignored the second time. 594 // that the call is ignored the second time.
559 LOG(WARNING) << "Playout is already active"; 595 LOG(WARNING) << "Playout is already active";
560 return 0; 596 return 0;
561 } 597 }
562 audio_output_device_->Start(); 598 audio_output_device_->Start();
563 playing_ = true; 599 playing_ = true;
564 return 0; 600 return 0;
565 } 601 }
566 602
567 int32_t WebRtcAudioDeviceImpl::StopPlayout() { 603 int32_t WebRtcAudioDeviceImpl::StopPlayout() {
568 VLOG(1) << "StopPlayout()"; 604 DVLOG(1) << "StopPlayout()";
569 DCHECK(audio_output_device_); 605 DCHECK(audio_output_device_);
570 if (!playing_) { 606 if (!playing_) {
571 // webrtc::VoiceEngine assumes that it is OK to call Stop() just in case. 607 // webrtc::VoiceEngine assumes that it is OK to call Stop() just in case.
572 LOG(WARNING) << "Playout was already stopped"; 608 LOG(WARNING) << "Playout was already stopped";
573 return 0; 609 return 0;
574 } 610 }
575 playing_ = !audio_output_device_->Stop(); 611 playing_ = !audio_output_device_->Stop();
576 return (!playing_ ? 0 : -1); 612 return (!playing_ ? 0 : -1);
577 } 613 }
578 614
579 bool WebRtcAudioDeviceImpl::Playing() const { 615 bool WebRtcAudioDeviceImpl::Playing() const {
580 return playing_; 616 return playing_;
581 } 617 }
582 618
583 int32_t WebRtcAudioDeviceImpl::StartRecording() { 619 int32_t WebRtcAudioDeviceImpl::StartRecording() {
584 VLOG(1) << "StartRecording()"; 620 DVLOG(1) << "StartRecording()";
585 #if defined(OS_MACOSX) 621 #if defined(OS_MACOSX)
586 DLOG(WARNING) << "Real-time recording is not yet fully supported on Mac OS X"; 622 DLOG(WARNING) << "Real-time recording is not yet fully supported on Mac OS X";
587 #endif 623 #endif
588 LOG_IF(ERROR, !audio_transport_callback_) << "Audio transport is missing"; 624 LOG_IF(ERROR, !audio_transport_callback_) << "Audio transport is missing";
589 if (!audio_transport_callback_) { 625 if (!audio_transport_callback_) {
590 LOG(ERROR) << "Audio transport is missing"; 626 LOG(ERROR) << "Audio transport is missing";
591 return -1; 627 return -1;
592 } 628 }
593 629
594 if (session_id_ <= 0) { 630 if (session_id_ <= 0) {
(...skipping 12 matching lines...) Expand all
607 } 643 }
608 644
609 // Specify the session_id which is mapped to a certain device. 645 // Specify the session_id which is mapped to a certain device.
610 audio_input_device_->SetDevice(session_id_); 646 audio_input_device_->SetDevice(session_id_);
611 audio_input_device_->Start(); 647 audio_input_device_->Start();
612 recording_ = true; 648 recording_ = true;
613 return 0; 649 return 0;
614 } 650 }
615 651
616 int32_t WebRtcAudioDeviceImpl::StopRecording() { 652 int32_t WebRtcAudioDeviceImpl::StopRecording() {
617 VLOG(1) << "StopRecording()"; 653 DVLOG(1) << "StopRecording()";
618 DCHECK(audio_input_device_); 654 DCHECK(audio_input_device_);
619 655
620 base::AutoLock auto_lock(lock_); 656 base::AutoLock auto_lock(lock_);
621 if (!recording_) { 657 if (!recording_) {
622 // webrtc::VoiceEngine assumes that it is OK to call Stop() just in case. 658 // webrtc::VoiceEngine assumes that it is OK to call Stop() just in case.
623 LOG(WARNING) << "Recording was already stopped"; 659 LOG(WARNING) << "Recording was already stopped";
624 return 0; 660 return 0;
625 } 661 }
626 recording_ = !audio_input_device_->Stop(); 662 recording_ = !audio_input_device_->Stop();
627 return (!recording_ ? 0 : -1); 663 return (!recording_ ? 0 : -1);
628 } 664 }
629 665
630 bool WebRtcAudioDeviceImpl::Recording() const { 666 bool WebRtcAudioDeviceImpl::Recording() const {
631 return recording_; 667 return recording_;
632 } 668 }
633 669
634 int32_t WebRtcAudioDeviceImpl::SetAGC(bool enable) { 670 int32_t WebRtcAudioDeviceImpl::SetAGC(bool enable) {
635 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetAGC() " 671 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetAGC() " << "NOT IMPLEMENTED";
636 << "NOT IMPLEMENTED";
637 return -1; 672 return -1;
638 } 673 }
639 674
640 bool WebRtcAudioDeviceImpl::AGC() const { 675 bool WebRtcAudioDeviceImpl::AGC() const {
641 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::AGC() " 676 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::AGC() " << "NOT IMPLEMENTED";
642 << "NOT IMPLEMENTED";
643 return false; 677 return false;
644 } 678 }
645 679
646 int32_t WebRtcAudioDeviceImpl::SetWaveOutVolume(uint16_t volume_left, 680 int32_t WebRtcAudioDeviceImpl::SetWaveOutVolume(uint16_t volume_left,
647 uint16_t volume_right) { 681 uint16_t volume_right) {
648 NOTIMPLEMENTED(); 682 NOTIMPLEMENTED();
649 return -1; 683 return -1;
650 } 684 }
651 int32_t WebRtcAudioDeviceImpl::WaveOutVolume( 685 int32_t WebRtcAudioDeviceImpl::WaveOutVolume(
652 uint16_t* volume_left, 686 uint16_t* volume_left,
653 uint16_t* volume_right) const { 687 uint16_t* volume_right) const {
654 NOTIMPLEMENTED(); 688 NOTIMPLEMENTED();
655 return -1; 689 return -1;
656 } 690 }
657 691
658 int32_t WebRtcAudioDeviceImpl::SpeakerIsAvailable(bool* available) { 692 int32_t WebRtcAudioDeviceImpl::SpeakerIsAvailable(bool* available) {
659 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SpeakerIsAvailable() " 693 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SpeakerIsAvailable() "
660 << "NOT IMPLEMENTED"; 694 << "NOT IMPLEMENTED";
661 *available = true; 695 *available = true;
662 return 0; 696 return 0;
663 } 697 }
664 698
665 int32_t WebRtcAudioDeviceImpl::InitSpeaker() { 699 int32_t WebRtcAudioDeviceImpl::InitSpeaker() {
666 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::InitSpeaker() " 700 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::InitSpeaker() "
667 << "NOT IMPLEMENTED"; 701 << "NOT IMPLEMENTED";
668 return 0; 702 return 0;
669 } 703 }
670 704
671 bool WebRtcAudioDeviceImpl::SpeakerIsInitialized() const { 705 bool WebRtcAudioDeviceImpl::SpeakerIsInitialized() const {
672 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SpeakerIsInitialized() " 706 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SpeakerIsInitialized() "
673 << "NOT IMPLEMENTED"; 707 << "NOT IMPLEMENTED";
674 return true; 708 return true;
675 } 709 }
676 710
677 int32_t WebRtcAudioDeviceImpl::MicrophoneIsAvailable(bool* available) { 711 int32_t WebRtcAudioDeviceImpl::MicrophoneIsAvailable(bool* available) {
678 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::MicrophoneIsAvailable() " 712 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::MicrophoneIsAvailable() "
679 << "NOT IMPLEMENTED"; 713 << "NOT IMPLEMENTED";
680 *available = true; 714 *available = true;
681 return 0; 715 return 0;
682 } 716 }
683 717
684 int32_t WebRtcAudioDeviceImpl::InitMicrophone() { 718 int32_t WebRtcAudioDeviceImpl::InitMicrophone() {
685 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::InitMicrophone() " 719 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::InitMicrophone() "
686 << "NOT IMPLEMENTED"; 720 << "NOT IMPLEMENTED";
687 return 0; 721 return 0;
688 } 722 }
689 723
690 bool WebRtcAudioDeviceImpl::MicrophoneIsInitialized() const { 724 bool WebRtcAudioDeviceImpl::MicrophoneIsInitialized() const {
691 NOTIMPLEMENTED(); 725 NOTIMPLEMENTED();
692 return true; 726 return true;
693 } 727 }
694 728
695 int32_t WebRtcAudioDeviceImpl::SpeakerVolumeIsAvailable( 729 int32_t WebRtcAudioDeviceImpl::SpeakerVolumeIsAvailable(
696 bool* available) { 730 bool* available) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 return -1; 769 return -1;
736 } 770 }
737 771
738 int32_t WebRtcAudioDeviceImpl::MicrophoneVolume(uint32_t* volume) const { 772 int32_t WebRtcAudioDeviceImpl::MicrophoneVolume(uint32_t* volume) const {
739 NOTIMPLEMENTED(); 773 NOTIMPLEMENTED();
740 return -1; 774 return -1;
741 } 775 }
742 776
743 int32_t WebRtcAudioDeviceImpl::MaxMicrophoneVolume( 777 int32_t WebRtcAudioDeviceImpl::MaxMicrophoneVolume(
744 uint32_t* max_volume) const { 778 uint32_t* max_volume) const {
745 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::MaxMicrophoneVolume() " 779 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::MaxMicrophoneVolume() "
746 << "NOT IMPLEMENTED"; 780 << "NOT IMPLEMENTED";
747 return -1; 781 return -1;
748 } 782 }
749 783
750 int32_t WebRtcAudioDeviceImpl::MinMicrophoneVolume( 784 int32_t WebRtcAudioDeviceImpl::MinMicrophoneVolume(
751 uint32_t* min_volume) const { 785 uint32_t* min_volume) const {
752 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::MinMicrophoneVolume() " 786 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::MinMicrophoneVolume() "
753 << "NOT IMPLEMENTED"; 787 << "NOT IMPLEMENTED";
754 return -1; 788 return -1;
755 } 789 }
756 790
757 int32_t WebRtcAudioDeviceImpl::MicrophoneVolumeStepSize( 791 int32_t WebRtcAudioDeviceImpl::MicrophoneVolumeStepSize(
758 uint16_t* step_size) const { 792 uint16_t* step_size) const {
759 NOTIMPLEMENTED(); 793 NOTIMPLEMENTED();
760 return -1; 794 return -1;
761 } 795 }
762 796
763 int32_t WebRtcAudioDeviceImpl::SpeakerMuteIsAvailable(bool* available) { 797 int32_t WebRtcAudioDeviceImpl::SpeakerMuteIsAvailable(bool* available) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 NOTIMPLEMENTED(); 834 NOTIMPLEMENTED();
801 return -1; 835 return -1;
802 } 836 }
803 837
804 int32_t WebRtcAudioDeviceImpl::MicrophoneBoost(bool* enabled) const { 838 int32_t WebRtcAudioDeviceImpl::MicrophoneBoost(bool* enabled) const {
805 NOTIMPLEMENTED(); 839 NOTIMPLEMENTED();
806 return -1; 840 return -1;
807 } 841 }
808 842
809 int32_t WebRtcAudioDeviceImpl::StereoPlayoutIsAvailable(bool* available) const { 843 int32_t WebRtcAudioDeviceImpl::StereoPlayoutIsAvailable(bool* available) const {
810 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::StereoPlayoutIsAvailable() " 844 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::StereoPlayoutIsAvailable() "
811 << "NOT IMPLEMENTED"; 845 << "NOT IMPLEMENTED";
812 *available = false; 846 *available = false;
813 return 0; 847 return 0;
814 } 848 }
815 849
816 int32_t WebRtcAudioDeviceImpl::SetStereoPlayout(bool enable) { 850 int32_t WebRtcAudioDeviceImpl::SetStereoPlayout(bool enable) {
817 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetStereoPlayout() " 851 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetStereoPlayout() "
818 << "NOT IMPLEMENTED"; 852 << "NOT IMPLEMENTED";
819 return 0; 853 return 0;
820 } 854 }
821 855
822 int32_t WebRtcAudioDeviceImpl::StereoPlayout(bool* enabled) const { 856 int32_t WebRtcAudioDeviceImpl::StereoPlayout(bool* enabled) const {
823 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::StereoPlayout() " 857 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::StereoPlayout() "
824 << "NOT IMPLEMENTED"; 858 << "NOT IMPLEMENTED";
825 return 0; 859 return 0;
826 } 860 }
827 861
828 int32_t WebRtcAudioDeviceImpl::StereoRecordingIsAvailable( 862 int32_t WebRtcAudioDeviceImpl::StereoRecordingIsAvailable(
829 bool* available) const { 863 bool* available) const {
830 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::StereoRecordingIsAvailable() " 864 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::StereoRecordingIsAvailable() "
831 << "NOT IMPLEMENTED"; 865 << "NOT IMPLEMENTED";
832 return 0; 866 return 0;
833 } 867 }
834 868
835 int32_t WebRtcAudioDeviceImpl::SetStereoRecording(bool enable) { 869 int32_t WebRtcAudioDeviceImpl::SetStereoRecording(bool enable) {
836 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetStereoRecording() " 870 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::SetStereoRecording() "
837 << "NOT IMPLEMENTED"; 871 << "NOT IMPLEMENTED";
838 return -1; 872 return -1;
839 } 873 }
840 874
841 int32_t WebRtcAudioDeviceImpl::StereoRecording(bool* enabled) const { 875 int32_t WebRtcAudioDeviceImpl::StereoRecording(bool* enabled) const {
842 VLOG(2) << "WARNING: WebRtcAudioDeviceImpl::StereoRecording() " 876 DVLOG(2) << "WARNING: WebRtcAudioDeviceImpl::StereoRecording() "
843 << "NOT IMPLEMENTED"; 877 << "NOT IMPLEMENTED";
844 return -1; 878 return -1;
845 } 879 }
846 880
847 int32_t WebRtcAudioDeviceImpl::SetRecordingChannel(const ChannelType channel) { 881 int32_t WebRtcAudioDeviceImpl::SetRecordingChannel(const ChannelType channel) {
848 NOTIMPLEMENTED(); 882 NOTIMPLEMENTED();
849 return -1; 883 return -1;
850 } 884 }
851 885
852 int32_t WebRtcAudioDeviceImpl::RecordingChannel(ChannelType* channel) const { 886 int32_t WebRtcAudioDeviceImpl::RecordingChannel(ChannelType* channel) const {
853 NOTIMPLEMENTED(); 887 NOTIMPLEMENTED();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 } 978 }
945 979
946 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { 980 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const {
947 NOTIMPLEMENTED(); 981 NOTIMPLEMENTED();
948 return -1; 982 return -1;
949 } 983 }
950 984
951 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { 985 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) {
952 session_id_ = session_id; 986 session_id_ = session_id;
953 } 987 }
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_util.cc » ('j') | media/audio/audio_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698