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> |
| 11 #include <setupapi.h> | 11 #include <setupapi.h> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/process_util.h" | 18 #include "base/process_util.h" |
| 19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "media/audio/audio_util.h" | 21 #include "media/audio/audio_util.h" |
| 22 #include "media/audio/win/audio_low_latency_input_win.h" | 22 #include "media/audio/win/audio_low_latency_input_win.h" |
| 23 #include "media/audio/win/audio_low_latency_output_win.h" | 23 #include "media/audio/win/audio_low_latency_output_win.h" |
| 24 #include "media/audio/win/audio_manager_win.h" | 24 #include "media/audio/win/audio_manager_win.h" |
| 25 #include "media/audio/win/device_enumeration_win.h" | 25 #include "media/audio/win/device_enumeration_win.h" |
| 26 #include "media/audio/win/wavein_input_win.h" | 26 #include "media/audio/win/wavein_input_win.h" |
| 27 #include "media/audio/win/waveout_output_win.h" | 27 #include "media/audio/win/waveout_output_win.h" |
| 28 #include "media/base/limits.h" | 28 #include "media/base/limits.h" |
| 29 #include "media/base/media_switches.h" | |
| 29 | 30 |
| 30 // Libraries required for the SetupAPI and Wbem APIs used here. | 31 // Libraries required for the SetupAPI and Wbem APIs used here. |
| 31 #pragma comment(lib, "setupapi.lib") | 32 #pragma comment(lib, "setupapi.lib") |
| 32 | 33 |
| 33 // The following are defined in various DDK headers, and we (re)define them | 34 // The following are defined in various DDK headers, and we (re)define them |
| 34 // here to avoid adding the DDK as a chrome dependency. | 35 // here to avoid adding the DDK as a chrome dependency. |
| 35 #define DRV_QUERYDEVICEINTERFACE 0x80c | 36 #define DRV_QUERYDEVICEINTERFACE 0x80c |
| 36 #define DRVM_MAPPER_PREFERRED_GET 0x2015 | 37 #define DRVM_MAPPER_PREFERRED_GET 0x2015 |
| 37 #define DRV_QUERYDEVICEINTERFACESIZE 0x80d | 38 #define DRV_QUERYDEVICEINTERFACESIZE 0x80d |
| 38 DEFINE_GUID(AM_KSCATEGORY_AUDIO, 0x6994ad04, 0x93ef, 0x11d0, | 39 DEFINE_GUID(AM_KSCATEGORY_AUDIO, 0x6994ad04, 0x93ef, 0x11d0, |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 return NULL; | 263 return NULL; |
| 263 | 264 |
| 264 AudioOutputStream* stream = NULL; | 265 AudioOutputStream* stream = NULL; |
| 265 if (!media::IsWASAPISupported()) { | 266 if (!media::IsWASAPISupported()) { |
| 266 // Fall back to Windows Wave implementation on Windows XP or lower. | 267 // Fall back to Windows Wave implementation on Windows XP or lower. |
| 267 DVLOG(1) << "Using WaveOut since WASAPI requires at least Vista."; | 268 DVLOG(1) << "Using WaveOut since WASAPI requires at least Vista."; |
| 268 stream = new PCMWaveOutAudioOutputStream(this, params, 2, WAVE_MAPPER); | 269 stream = new PCMWaveOutAudioOutputStream(this, params, 2, WAVE_MAPPER); |
| 269 } else { | 270 } else { |
| 270 // TODO(henrika): improve possibility to specify audio endpoint. | 271 // TODO(henrika): improve possibility to specify audio endpoint. |
| 271 // Use the default device (same as for Wave) for now to be compatible. | 272 // Use the default device (same as for Wave) for now to be compatible. |
| 272 stream = new WASAPIAudioOutputStream(this, params, eConsole); | 273 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 274 if (cmd_line->HasSwitch(switches::kEnableExclusiveMode)) { | |
| 275 stream = new WASAPIAudioOutputStream( | |
| 276 this, params, eConsole, AUDCLNT_SHAREMODE_EXCLUSIVE); | |
| 277 } else { | |
| 278 stream = new WASAPIAudioOutputStream( | |
| 279 this, params, eConsole, AUDCLNT_SHAREMODE_SHARED); | |
|
scherkus (not reviewing)
2012/06/27 04:20:30
fix indent
henrika (OOO until Aug 14)
2012/06/27 11:26:07
Done.
| |
| 280 } | |
| 273 } | 281 } |
| 274 | 282 |
| 275 return stream; | 283 return stream; |
| 276 } | 284 } |
| 277 | 285 |
| 278 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR | 286 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR |
| 279 // mode. | 287 // mode. |
| 280 AudioInputStream* AudioManagerWin::MakeLinearInputStream( | 288 AudioInputStream* AudioManagerWin::MakeLinearInputStream( |
| 281 const AudioParameters& params, const std::string& device_id) { | 289 const AudioParameters& params, const std::string& device_id) { |
| 282 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); | 290 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 325 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
| 318 xp_device_id); | 326 xp_device_id); |
| 319 } | 327 } |
| 320 | 328 |
| 321 /// static | 329 /// static |
| 322 AudioManager* CreateAudioManager() { | 330 AudioManager* CreateAudioManager() { |
| 323 return new AudioManagerWin(); | 331 return new AudioManagerWin(); |
| 324 } | 332 } |
| 325 | 333 |
| 326 } // namespace media | 334 } // namespace media |
| OLD | NEW |