Chromium Code Reviews| 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_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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 // Fall back to Windows Wave implementation on Windows XP or lower. | 343 // Fall back to Windows Wave implementation on Windows XP or lower. |
| 344 DVLOG(1) << "Using WaveIn since WASAPI requires at least Vista."; | 344 DVLOG(1) << "Using WaveIn since WASAPI requires at least Vista."; |
| 345 stream = CreatePCMWaveInAudioInputStream(params, device_id); | 345 stream = CreatePCMWaveInAudioInputStream(params, device_id); |
| 346 } else { | 346 } else { |
| 347 stream = new WASAPIAudioInputStream(this, params, device_id); | 347 stream = new WASAPIAudioInputStream(this, params, device_id); |
| 348 } | 348 } |
| 349 | 349 |
| 350 return stream; | 350 return stream; |
| 351 } | 351 } |
| 352 | 352 |
| 353 AudioParameters AudioManagerWin::GetPreferredOutputStreamParameters( | 353 AudioParameters AudioManagerWin::GetPreferredOutputStreamParameters( |
|
DaleCurtis
2013/04/15 18:08:57
Ugh, not your fault, but this whole function is re
henrika (OOO until Aug 14)
2013/04/15 20:28:28
I agree, it sucks. Wonder who has written most par
DaleCurtis
2013/04/15 20:31:07
I don't know what you're talking about!! :p I'll
| |
| 354 const AudioParameters& input_params) { | 354 const AudioParameters& input_params) { |
| 355 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 355 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 356 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; | 356 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; |
| 357 int sample_rate = 48000; | 357 int sample_rate = 48000; |
| 358 int buffer_size = kFallbackBufferSize; | 358 int buffer_size = kFallbackBufferSize; |
| 359 int bits_per_sample = 16; | 359 int bits_per_sample = 16; |
| 360 int input_channels = 0; | 360 int input_channels = 0; |
| 361 bool use_input_params = !CoreAudioUtil::IsSupported(); | 361 bool use_input_params = !CoreAudioUtil::IsSupported(); |
| 362 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) { | 362 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) { |
| 363 // TODO(crogers): tune these values for best possible WebAudio performance. | 363 // TODO(crogers): tune these values for best possible WebAudio performance. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 383 // TODO(henrika): Figure out the right thing to do here. | 383 // TODO(henrika): Figure out the right thing to do here. |
| 384 if (hw_sample_rate && hw_buffer_size) { | 384 if (hw_sample_rate && hw_buffer_size) { |
| 385 sample_rate = hw_sample_rate; | 385 sample_rate = hw_sample_rate; |
| 386 buffer_size = hw_buffer_size; | 386 buffer_size = hw_buffer_size; |
| 387 } else { | 387 } else { |
| 388 use_input_params = true; | 388 use_input_params = true; |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 | 391 |
| 392 if (input_params.IsValid()) { | 392 if (input_params.IsValid()) { |
| 393 if (CoreAudioUtil::IsSupported() && | 393 if (CoreAudioUtil::IsSupported()) { |
| 394 CoreAudioUtil::IsChannelLayoutSupported(eRender, eConsole, | 394 // Check if it is possible to open up at the specified input channel |
|
DaleCurtis
2013/04/15 18:08:57
Indent is wrong; should be 2 spaces.
henrika (OOO until Aug 14)
2013/04/15 20:28:28
Will fix.
henrika (OOO until Aug 14)
2013/04/16 09:04:35
Done.
| |
| 395 input_params.channel_layout())) { | 395 // layout but avoid checking if the specified layout is the same as the |
| 396 // Open up using the same channel layout as the source if it is | 396 // hardware (preferred) layout. We do this extra check to avoid the |
| 397 // supported by the hardware. | 397 // CoreAudioUtil::IsChannelLayoutSupported() overhead in most cases. |
| 398 channel_layout = input_params.channel_layout(); | 398 if (input_params.channel_layout() != channel_layout) { |
|
DaleCurtis
2013/04/15 18:08:57
In the Exclusive mode case, channel_layout won't b
henrika (OOO until Aug 14)
2013/04/15 20:28:28
Can you elaborate. Do you want me to add a flag-ch
DaleCurtis
2013/04/15 20:31:07
In the HasSwitch() block above, I'd just add a:
i
henrika (OOO until Aug 14)
2013/04/16 09:04:35
Done.
| |
| 399 VLOG(1) << "Hardware channel layout is not used; using same " | 399 if (CoreAudioUtil::IsChannelLayoutSupported(eRender, eConsole, |
| 400 << "layout as the source instead (" << channel_layout << ")"; | 400 input_params.channel_layout())) { |
|
DaleCurtis
2013/04/15 18:08:57
Wrong indent; you can't partially wrap some of the
henrika (OOO until Aug 14)
2013/04/15 20:28:28
Will fix.
henrika (OOO until Aug 14)
2013/04/16 09:04:35
Done.
| |
| 401 // Open up using the same channel layout as the source if it is | |
| 402 // supported by the hardware. | |
| 403 channel_layout = input_params.channel_layout(); | |
| 404 VLOG(1) << "Hardware channel layout is not used; using same layout" | |
| 405 << " as the source instead (" << channel_layout << ")"; | |
| 406 } | |
| 407 } | |
| 401 } | 408 } |
| 402 input_channels = input_params.input_channels(); | 409 input_channels = input_params.input_channels(); |
| 403 if (use_input_params) { | 410 if (use_input_params) { |
| 404 // If WASAPI isn't supported we'll fallback to WaveOut, which will take | 411 // If WASAPI isn't supported we'll fallback to WaveOut, which will take |
| 405 // care of resampling and bits per sample changes. By setting these | 412 // care of resampling and bits per sample changes. By setting these |
| 406 // equal to the input values, AudioOutputResampler will skip resampling | 413 // equal to the input values, AudioOutputResampler will skip resampling |
| 407 // and bit per sample differences (since the input parameters will match | 414 // and bit per sample differences (since the input parameters will match |
| 408 // the output parameters). | 415 // the output parameters). |
| 409 sample_rate = input_params.sample_rate(); | 416 sample_rate = input_params.sample_rate(); |
| 410 bits_per_sample = input_params.bits_per_sample(); | 417 bits_per_sample = input_params.bits_per_sample(); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 439 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 446 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| 440 xp_device_id); | 447 xp_device_id); |
| 441 } | 448 } |
| 442 | 449 |
| 443 /// static | 450 /// static |
| 444 AudioManager* CreateAudioManager() { | 451 AudioManager* CreateAudioManager() { |
| 445 return new AudioManagerWin(); | 452 return new AudioManagerWin(); |
| 446 } | 453 } |
| 447 | 454 |
| 448 } // namespace media | 455 } // namespace media |
| OLD | NEW |