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

Side by Side Diff: media/audio/win/audio_manager_win.cc

Issue 23440020: Call GetDefaultOutputDeviceID() from GetDefaultOutputStreamParameters() instead of specifying an em… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 3 months 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
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_io.h" 5 #include "media/audio/audio_io.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <objbase.h> // This has to be before initguid.h 8 #include <objbase.h> // This has to be before initguid.h
9 #include <initguid.h> 9 #include <initguid.h>
10 #include <mmsystem.h> 10 #include <mmsystem.h>
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 358
359 std::string AudioManagerWin::GetDefaultOutputDeviceID() { 359 std::string AudioManagerWin::GetDefaultOutputDeviceID() {
360 if (!CoreAudioUtil::IsSupported()) 360 if (!CoreAudioUtil::IsSupported())
361 return std::string(); 361 return std::string();
362 return CoreAudioUtil::GetDefaultOutputDeviceID(); 362 return CoreAudioUtil::GetDefaultOutputDeviceID();
363 } 363 }
364 364
365 AudioParameters AudioManagerWin::GetPreferredOutputStreamParameters( 365 AudioParameters AudioManagerWin::GetPreferredOutputStreamParameters(
366 const std::string& output_device_id, 366 const std::string& output_device_id,
367 const AudioParameters& input_params) { 367 const AudioParameters& input_params) {
368 // TODO(tommi): Support |output_device_id|.
369 DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!";
370
371 const bool core_audio_supported = CoreAudioUtil::IsSupported(); 368 const bool core_audio_supported = CoreAudioUtil::IsSupported();
372 DLOG_IF(ERROR, !core_audio_supported && !output_device_id.empty()) 369 DLOG_IF(ERROR, !core_audio_supported && !output_device_id.empty())
373 << "CoreAudio is required to open non-default devices."; 370 << "CoreAudio is required to open non-default devices.";
374 371
375 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 372 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
376 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; 373 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
377 int sample_rate = 48000; 374 int sample_rate = 48000;
378 int buffer_size = kFallbackBufferSize; 375 int buffer_size = kFallbackBufferSize;
379 int bits_per_sample = 16; 376 int bits_per_sample = 16;
380 int input_channels = 0; 377 int input_channels = 0;
381 bool use_input_params = !core_audio_supported; 378 bool use_input_params = !core_audio_supported;
382 if (core_audio_supported) { 379 if (core_audio_supported) {
383 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) { 380 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) {
384 // TODO(rtoy): tune these values for best possible WebAudio 381 // TODO(rtoy): tune these values for best possible WebAudio
385 // performance. WebRTC works well at 48kHz and a buffer size of 480 382 // performance. WebRTC works well at 48kHz and a buffer size of 480
386 // samples will be used for this case. Note that exclusive mode is 383 // samples will be used for this case. Note that exclusive mode is
387 // experimental. This sample rate will be combined with a buffer size of 384 // experimental. This sample rate will be combined with a buffer size of
388 // 256 samples, which corresponds to an output delay of ~5.33ms. 385 // 256 samples, which corresponds to an output delay of ~5.33ms.
389 sample_rate = 48000; 386 sample_rate = 48000;
390 buffer_size = 256; 387 buffer_size = 256;
391 if (input_params.IsValid()) 388 if (input_params.IsValid())
392 channel_layout = input_params.channel_layout(); 389 channel_layout = input_params.channel_layout();
393 } else { 390 } else {
394 AudioParameters params; 391 AudioParameters params;
395 HRESULT hr = CoreAudioUtil::GetPreferredAudioParameters(output_device_id, 392 HRESULT hr = CoreAudioUtil::GetPreferredAudioParameters(
396 &params); 393 output_device_id.empty() ?
394 GetDefaultOutputDeviceID() : output_device_id,
395 &params);
397 if (SUCCEEDED(hr)) { 396 if (SUCCEEDED(hr)) {
398 bits_per_sample = params.bits_per_sample(); 397 bits_per_sample = params.bits_per_sample();
399 buffer_size = params.frames_per_buffer(); 398 buffer_size = params.frames_per_buffer();
400 channel_layout = params.channel_layout(); 399 channel_layout = params.channel_layout();
401 sample_rate = params.sample_rate(); 400 sample_rate = params.sample_rate();
402 } else { 401 } else {
403 use_input_params = true; 402 use_input_params = true;
404 } 403 }
405 } 404 }
406 } 405 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, 468 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers,
470 xp_device_id); 469 xp_device_id);
471 } 470 }
472 471
473 /// static 472 /// static
474 AudioManager* CreateAudioManager() { 473 AudioManager* CreateAudioManager() {
475 return new AudioManagerWin(); 474 return new AudioManagerWin();
476 } 475 }
477 476
478 } // namespace media 477 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698