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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 SetupDiSetDeviceInstallParams(device_info, device_data, | 106 SetupDiSetDeviceInstallParams(device_info, device_data, |
107 &old_device_install_params); | 107 &old_device_install_params); |
108 | 108 |
109 return device_and_driver_info; | 109 return device_and_driver_info; |
110 } | 110 } |
111 | 111 |
112 static int NumberOfWaveOutBuffers() { | 112 static int NumberOfWaveOutBuffers() { |
113 // Use the user provided buffer count if provided. | 113 // Use the user provided buffer count if provided. |
114 int buffers = 0; | 114 int buffers = 0; |
115 std::string buffers_str(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 115 std::string buffers_str( |
116 switches::kWaveOutBuffers)); | 116 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 117 switches::kWaveOutBuffers)); |
117 if (base::StringToInt(buffers_str, &buffers) && buffers > 0) { | 118 if (base::StringToInt(buffers_str, &buffers) && buffers > 0) { |
118 return buffers; | 119 return buffers; |
119 } | 120 } |
120 | 121 |
121 // Use 4 buffers for Vista, 3 for everyone else: | 122 // Use 4 buffers for Vista, 3 for everyone else: |
122 // - The entire Windows audio stack was rewritten for Windows Vista and wave | 123 // - The entire Windows audio stack was rewritten for Windows Vista and wave |
123 // out performance was degraded compared to XP. | 124 // out performance was degraded compared to XP. |
124 // - The regression was fixed in Windows 7 and most configurations will work | 125 // - The regression was fixed in Windows 7 and most configurations will work |
125 // with 2, but some (e.g., some Sound Blasters) still need 3. | 126 // with 2, but some (e.g., some Sound Blasters) still need 3. |
126 // - Some XP configurations (even multi-processor ones) also need 3. | 127 // - Some XP configurations (even multi-processor ones) also need 3. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 program = L"sndvol32.exe"; | 252 program = L"sndvol32.exe"; |
252 argument = "-R"; | 253 argument = "-R"; |
253 } else { | 254 } else { |
254 program = L"control.exe"; | 255 program = L"control.exe"; |
255 argument = "mmsys.cpl,,1"; | 256 argument = "mmsys.cpl,,1"; |
256 } | 257 } |
257 | 258 |
258 base::FilePath path; | 259 base::FilePath path; |
259 PathService::Get(base::DIR_SYSTEM, &path); | 260 PathService::Get(base::DIR_SYSTEM, &path); |
260 path = path.Append(program); | 261 path = path.Append(program); |
261 CommandLine command_line(path); | 262 base::CommandLine command_line(path); |
262 command_line.AppendArg(argument); | 263 command_line.AppendArg(argument); |
263 base::LaunchProcess(command_line, base::LaunchOptions()); | 264 base::LaunchProcess(command_line, base::LaunchOptions()); |
264 } | 265 } |
265 | 266 |
266 void AudioManagerWin::GetAudioDeviceNamesImpl( | 267 void AudioManagerWin::GetAudioDeviceNamesImpl( |
267 bool input, | 268 bool input, |
268 AudioDeviceNames* device_names) { | 269 AudioDeviceNames* device_names) { |
269 DCHECK(device_names->empty()); | 270 DCHECK(device_names->empty()); |
270 // Enumerate all active audio-endpoint capture devices. | 271 // Enumerate all active audio-endpoint capture devices. |
271 if (enumeration_type() == kWaveEnumeration) { | 272 if (enumeration_type() == kWaveEnumeration) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 return std::string(); | 412 return std::string(); |
412 return CoreAudioUtil::GetDefaultOutputDeviceID(); | 413 return CoreAudioUtil::GetDefaultOutputDeviceID(); |
413 } | 414 } |
414 | 415 |
415 AudioParameters AudioManagerWin::GetPreferredOutputStreamParameters( | 416 AudioParameters AudioManagerWin::GetPreferredOutputStreamParameters( |
416 const std::string& output_device_id, | 417 const std::string& output_device_id, |
417 const AudioParameters& input_params) { | 418 const AudioParameters& input_params) { |
418 DLOG_IF(ERROR, !core_audio_supported() && !output_device_id.empty()) | 419 DLOG_IF(ERROR, !core_audio_supported() && !output_device_id.empty()) |
419 << "CoreAudio is required to open non-default devices."; | 420 << "CoreAudio is required to open non-default devices."; |
420 | 421 |
421 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 422 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
422 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; | 423 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; |
423 int sample_rate = 48000; | 424 int sample_rate = 48000; |
424 int buffer_size = kFallbackBufferSize; | 425 int buffer_size = kFallbackBufferSize; |
425 int bits_per_sample = 16; | 426 int bits_per_sample = 16; |
426 int effects = AudioParameters::NO_EFFECTS; | 427 int effects = AudioParameters::NO_EFFECTS; |
427 bool use_input_params = !core_audio_supported(); | 428 bool use_input_params = !core_audio_supported(); |
428 if (core_audio_supported()) { | 429 if (core_audio_supported()) { |
429 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) { | 430 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) { |
430 // TODO(rtoy): tune these values for best possible WebAudio | 431 // TODO(rtoy): tune these values for best possible WebAudio |
431 // performance. WebRTC works well at 48kHz and a buffer size of 480 | 432 // performance. WebRTC works well at 48kHz and a buffer size of 480 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 529 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
529 xp_device_id); | 530 xp_device_id); |
530 } | 531 } |
531 | 532 |
532 /// static | 533 /// static |
533 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { | 534 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { |
534 return new AudioManagerWin(audio_log_factory); | 535 return new AudioManagerWin(audio_log_factory); |
535 } | 536 } |
536 | 537 |
537 } // namespace media | 538 } // namespace media |
OLD | NEW |