Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1033)

Side by Side Diff: media/audio/win/audio_manager_win.cc

Issue 10575017: Adding experimental exclusive-mode streaming to WASAPIAudioOutputStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes based on review by Chris and Andrew Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 // Experiemental mode; use with care.
276 stream = new WASAPIAudioOutputStream(
277 this, params, eConsole, AUDCLNT_SHAREMODE_EXCLUSIVE);
278 } else {
279 // Shared mode streaming is the default mode.
280 stream = new WASAPIAudioOutputStream(
281 this, params, eConsole, AUDCLNT_SHAREMODE_SHARED);
282 }
273 } 283 }
274 284
275 return stream; 285 return stream;
276 } 286 }
277 287
278 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR 288 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR
279 // mode. 289 // mode.
280 AudioInputStream* AudioManagerWin::MakeLinearInputStream( 290 AudioInputStream* AudioManagerWin::MakeLinearInputStream(
281 const AudioParameters& params, const std::string& device_id) { 291 const AudioParameters& params, const std::string& device_id) {
282 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); 292 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, 327 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers,
318 xp_device_id); 328 xp_device_id);
319 } 329 }
320 330
321 /// static 331 /// static
322 AudioManager* CreateAudioManager() { 332 AudioManager* CreateAudioManager() {
323 return new AudioManagerWin(); 333 return new AudioManagerWin();
324 } 334 }
325 335
326 } // namespace media 336 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698