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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 292 |
293 void AudioManagerWin::GetAudioInputDeviceNames(AudioDeviceNames* device_names) { | 293 void AudioManagerWin::GetAudioInputDeviceNames(AudioDeviceNames* device_names) { |
294 GetAudioDeviceNamesImpl(true, device_names); | 294 GetAudioDeviceNamesImpl(true, device_names); |
295 } | 295 } |
296 | 296 |
297 void AudioManagerWin::GetAudioOutputDeviceNames( | 297 void AudioManagerWin::GetAudioOutputDeviceNames( |
298 AudioDeviceNames* device_names) { | 298 AudioDeviceNames* device_names) { |
299 GetAudioDeviceNamesImpl(false, device_names); | 299 GetAudioDeviceNamesImpl(false, device_names); |
300 } | 300 } |
301 | 301 |
302 AudioParameters AudioManagerWin::GetInputStreamParameters( | 302 AudioParameters AudioManagerWin::GetPreferredInputStreamParameters( |
303 const std::string& device_id) { | 303 const std::string& input_device_id, |
304 AudioParameters parameters; | 304 const AudioParameters& input_params) { |
305 if (!core_audio_supported()) { | 305 // Default format used by the wave implementation. |
306 // Windows Wave implementation is being used. | 306 AudioParameters::Format format = AUDIO_PCM_LINEAR; |
307 parameters = AudioParameters( | 307 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; |
308 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 0, 48000, | 308 int buffer_size = kFallbackBufferSize; |
309 16, kFallbackBufferSize, AudioParameters::NO_EFFECTS); | 309 int bits_per_sample = 16; |
310 } else { | 310 int input_channels = 0; |
311 parameters = WASAPIAudioInputStream::GetInputStreamParameters(device_id); | 311 int sample_rate = 48000; |
| 312 int effects = AudioParameters::NO_EFFECTS; |
| 313 |
| 314 if (core_audio_supported()) { |
| 315 // When core audio is being used, we need to respect the native format |
| 316 // of the device. |
| 317 AudioParameters parameters = |
| 318 WASAPIAudioInputStream::GetInputStreamParameters(device_id); |
| 319 format = parameters.format(); |
| 320 channel_layout = parameters.channel_layout(); |
| 321 bits_per_sample = parameters.bits_per_sample(); |
| 322 input_channels = parameters.input_channels(); |
| 323 sample_rate = parameters.sample_rate(); |
| 324 effects |= parameters.effects(); |
| 325 } |
| 326 |
| 327 if (input_params.IsValid()) { |
| 328 input_channels = input_params.input_channels(); |
| 329 effects |= input_params.effects(); |
| 330 bits_per_sample = input_params.bits_per_sample(); |
| 331 buffer_size = input_params.frames_per_buffer(); |
| 332 channel_layout = input_params.channel_layout(); |
| 333 |
| 334 // When core audio is being used, we must use the device's native sample |
| 335 // rate. |
| 336 if (!core_audio_supported()) |
| 337 sample_rate = input_params.sample_rate(); |
312 } | 338 } |
313 | 339 |
314 int user_buffer_size = GetUserBufferSize(); | 340 int user_buffer_size = GetUserBufferSize(); |
315 if (user_buffer_size) { | 341 if (user_buffer_size) |
316 parameters.Reset(parameters.format(), parameters.channel_layout(), | 342 buffer_size = user_buffer_size; |
317 parameters.channels(), parameters.input_channels(), | |
318 parameters.sample_rate(), parameters.bits_per_sample(), | |
319 user_buffer_size); | |
320 } | |
321 | 343 |
322 return parameters; | 344 return AudioParameters(format, channel_layout, input_channels, |
| 345 sample_rate, bits_per_sample, buffer_size, effects); |
323 } | 346 } |
324 | 347 |
325 std::string AudioManagerWin::GetAssociatedOutputDeviceID( | 348 std::string AudioManagerWin::GetAssociatedOutputDeviceID( |
326 const std::string& input_device_id) { | 349 const std::string& input_device_id) { |
327 if (!core_audio_supported()) { | 350 if (!core_audio_supported()) { |
328 NOTIMPLEMENTED() | 351 NOTIMPLEMENTED() |
329 << "GetAssociatedOutputDeviceID is not supported on this OS"; | 352 << "GetAssociatedOutputDeviceID is not supported on this OS"; |
330 return std::string(); | 353 return std::string(); |
331 } | 354 } |
332 return CoreAudioUtil::GetMatchingOutputDeviceID(input_device_id); | 355 return CoreAudioUtil::GetMatchingOutputDeviceID(input_device_id); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 551 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
529 xp_device_id); | 552 xp_device_id); |
530 } | 553 } |
531 | 554 |
532 /// static | 555 /// static |
533 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { | 556 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { |
534 return new AudioManagerWin(audio_log_factory); | 557 return new AudioManagerWin(audio_log_factory); |
535 } | 558 } |
536 | 559 |
537 } // namespace media | 560 } // namespace media |
OLD | NEW |