| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 const std::string& device_id) { | 310 const std::string& device_id) { |
| 311 HRESULT hr = E_FAIL; | 311 HRESULT hr = E_FAIL; |
| 312 AudioParameters parameters; | 312 AudioParameters parameters; |
| 313 if (core_audio_supported()) { | 313 if (core_audio_supported()) { |
| 314 hr = CoreAudioUtil::GetPreferredAudioParameters(device_id, false, | 314 hr = CoreAudioUtil::GetPreferredAudioParameters(device_id, false, |
| 315 ¶meters); | 315 ¶meters); |
| 316 } | 316 } |
| 317 | 317 |
| 318 if (FAILED(hr) || !parameters.IsValid()) { | 318 if (FAILED(hr) || !parameters.IsValid()) { |
| 319 // Windows Wave implementation is being used. | 319 // Windows Wave implementation is being used. |
| 320 parameters = AudioParameters( | 320 parameters = |
| 321 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 48000, 16, | 321 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, |
| 322 kFallbackBufferSize, AudioParameters::NO_EFFECTS); | 322 CHANNEL_LAYOUT_STEREO, 48000, 16, kFallbackBufferSize); |
| 323 } | 323 } |
| 324 | 324 |
| 325 int user_buffer_size = GetUserBufferSize(); | 325 int user_buffer_size = GetUserBufferSize(); |
| 326 if (user_buffer_size) { | 326 if (user_buffer_size) |
| 327 parameters.Reset(parameters.format(), parameters.channel_layout(), | 327 parameters.set_frames_per_buffer(user_buffer_size); |
| 328 parameters.channels(), parameters.sample_rate(), | |
| 329 parameters.bits_per_sample(), user_buffer_size); | |
| 330 } | |
| 331 | 328 |
| 332 return parameters; | 329 return parameters; |
| 333 } | 330 } |
| 334 | 331 |
| 335 std::string AudioManagerWin::GetAssociatedOutputDeviceID( | 332 std::string AudioManagerWin::GetAssociatedOutputDeviceID( |
| 336 const std::string& input_device_id) { | 333 const std::string& input_device_id) { |
| 337 if (!core_audio_supported()) { | 334 if (!core_audio_supported()) { |
| 338 NOTIMPLEMENTED() | 335 NOTIMPLEMENTED() |
| 339 << "GetAssociatedOutputDeviceID is not supported on this OS"; | 336 << "GetAssociatedOutputDeviceID is not supported on this OS"; |
| 340 return std::string(); | 337 return std::string(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 buffer_size = input_params.frames_per_buffer(); | 507 buffer_size = input_params.frames_per_buffer(); |
| 511 channel_layout = input_params.channel_layout(); | 508 channel_layout = input_params.channel_layout(); |
| 512 sample_rate = input_params.sample_rate(); | 509 sample_rate = input_params.sample_rate(); |
| 513 } | 510 } |
| 514 } | 511 } |
| 515 | 512 |
| 516 int user_buffer_size = GetUserBufferSize(); | 513 int user_buffer_size = GetUserBufferSize(); |
| 517 if (user_buffer_size) | 514 if (user_buffer_size) |
| 518 buffer_size = user_buffer_size; | 515 buffer_size = user_buffer_size; |
| 519 | 516 |
| 520 return AudioParameters( | 517 AudioParameters params(AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, |
| 521 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, | 518 sample_rate, bits_per_sample, buffer_size); |
| 522 sample_rate, bits_per_sample, buffer_size, effects); | 519 params.set_effects(effects); |
| 520 return params; |
| 523 } | 521 } |
| 524 | 522 |
| 525 AudioInputStream* AudioManagerWin::CreatePCMWaveInAudioInputStream( | 523 AudioInputStream* AudioManagerWin::CreatePCMWaveInAudioInputStream( |
| 526 const AudioParameters& params, | 524 const AudioParameters& params, |
| 527 const std::string& device_id) { | 525 const std::string& device_id) { |
| 528 std::string xp_device_id = device_id; | 526 std::string xp_device_id = device_id; |
| 529 if (device_id != AudioManagerBase::kDefaultDeviceId && | 527 if (device_id != AudioManagerBase::kDefaultDeviceId && |
| 530 enumeration_type_ == kMMDeviceEnumeration) { | 528 enumeration_type_ == kMMDeviceEnumeration) { |
| 531 xp_device_id = ConvertToWinXPInputDeviceId(device_id); | 529 xp_device_id = ConvertToWinXPInputDeviceId(device_id); |
| 532 if (xp_device_id.empty()) { | 530 if (xp_device_id.empty()) { |
| 533 DLOG(ERROR) << "Cannot find a waveIn device which matches the device ID " | 531 DLOG(ERROR) << "Cannot find a waveIn device which matches the device ID " |
| 534 << device_id; | 532 << device_id; |
| 535 return NULL; | 533 return NULL; |
| 536 } | 534 } |
| 537 } | 535 } |
| 538 | 536 |
| 539 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 537 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| 540 xp_device_id); | 538 xp_device_id); |
| 541 } | 539 } |
| 542 | 540 |
| 543 /// static | 541 /// static |
| 544 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { | 542 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { |
| 545 return new AudioManagerWin(audio_log_factory); | 543 return new AudioManagerWin(audio_log_factory); |
| 546 } | 544 } |
| 547 | 545 |
| 548 } // namespace media | 546 } // namespace media |
| OLD | NEW |