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

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

Issue 1314803003: Include default communication devices in audio device enumerations. This removes heuristic that pic… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment Created 5 years, 3 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
« no previous file with comments | « media/audio/win/audio_low_latency_output_win.cc ('k') | media/audio/win/core_audio_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 else 276 else
277 GetOutputDeviceNamesWinXP(device_names); 277 GetOutputDeviceNamesWinXP(device_names);
278 } else { 278 } else {
279 // Utilize the MMDevice API (part of Core Audio) for Vista and higher. 279 // Utilize the MMDevice API (part of Core Audio) for Vista and higher.
280 if (input) 280 if (input)
281 GetInputDeviceNamesWin(device_names); 281 GetInputDeviceNamesWin(device_names);
282 else 282 else
283 GetOutputDeviceNamesWin(device_names); 283 GetOutputDeviceNamesWin(device_names);
284 } 284 }
285 285
286 // Always add default device parameters as first element.
287 if (!device_names->empty()) { 286 if (!device_names->empty()) {
288 AudioDeviceName name; 287 AudioDeviceName name;
288 if (enumeration_type() == kMMDeviceEnumeration) {
289 name.device_name = AudioManagerBase::kCommunicationsDeviceName;
290 name.unique_id = AudioManagerBase::kCommunicationsDeviceId;
291 device_names->push_front(name);
292 }
293 // Always add default device parameters as first element.
289 name.device_name = AudioManagerBase::kDefaultDeviceName; 294 name.device_name = AudioManagerBase::kDefaultDeviceName;
290 name.unique_id = AudioManagerBase::kDefaultDeviceId; 295 name.unique_id = AudioManagerBase::kDefaultDeviceId;
291 device_names->push_front(name); 296 device_names->push_front(name);
292 } 297 }
293 } 298 }
294 299
295 void AudioManagerWin::GetAudioInputDeviceNames(AudioDeviceNames* device_names) { 300 void AudioManagerWin::GetAudioInputDeviceNames(AudioDeviceNames* device_names) {
296 GetAudioDeviceNamesImpl(true, device_names); 301 GetAudioDeviceNamesImpl(true, device_names);
297 } 302 }
298 303
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 device_id != AudioManagerBase::kDefaultDeviceId) 375 device_id != AudioManagerBase::kDefaultDeviceId)
371 << "Opening by device id not supported by PCMWaveOutAudioOutputStream"; 376 << "Opening by device id not supported by PCMWaveOutAudioOutputStream";
372 DVLOG(1) << "Using WaveOut since WASAPI requires at least Vista."; 377 DVLOG(1) << "Using WaveOut since WASAPI requires at least Vista.";
373 return new PCMWaveOutAudioOutputStream( 378 return new PCMWaveOutAudioOutputStream(
374 this, params, NumberOfWaveOutBuffers(), WAVE_MAPPER); 379 this, params, NumberOfWaveOutBuffers(), WAVE_MAPPER);
375 } 380 }
376 381
377 // Pass an empty string to indicate that we want the default device 382 // Pass an empty string to indicate that we want the default device
378 // since we consistently only check for an empty string in 383 // since we consistently only check for an empty string in
379 // WASAPIAudioOutputStream. 384 // WASAPIAudioOutputStream.
385 bool communications = device_id == AudioManagerBase::kCommunicationsDeviceId;
380 return new WASAPIAudioOutputStream(this, 386 return new WASAPIAudioOutputStream(this,
381 device_id == AudioManagerBase::kDefaultDeviceId ? 387 communications || device_id == AudioManagerBase::kDefaultDeviceId ?
382 std::string() : device_id, 388 std::string() : device_id,
383 params, 389 params,
384 params.effects() & AudioParameters::DUCKING ? eCommunications : eConsole); 390 communications ? eCommunications : eConsole);
385 } 391 }
386 392
387 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR 393 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR
388 // mode. 394 // mode.
389 AudioInputStream* AudioManagerWin::MakeLinearInputStream( 395 AudioInputStream* AudioManagerWin::MakeLinearInputStream(
390 const AudioParameters& params, const std::string& device_id) { 396 const AudioParameters& params, const std::string& device_id) {
391 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); 397 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format());
392 return CreatePCMWaveInAudioInputStream(params, device_id); 398 return CreatePCMWaveInAudioInputStream(params, device_id);
393 } 399 }
394 400
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, 539 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers,
534 xp_device_id); 540 xp_device_id);
535 } 541 }
536 542
537 /// static 543 /// static
538 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { 544 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) {
539 return new AudioManagerWin(audio_log_factory); 545 return new AudioManagerWin(audio_log_factory);
540 } 546 }
541 547
542 } // namespace media 548 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/win/audio_low_latency_output_win.cc ('k') | media/audio/win/core_audio_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698