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

Unified Diff: media/audio/win/core_audio_util_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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/win/audio_manager_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/win/core_audio_util_win.cc
diff --git a/media/audio/win/core_audio_util_win.cc b/media/audio/win/core_audio_util_win.cc
index ec1e5bceeab62329fbab05572aaf4e8941dc42af..8442fc1bc11983fded607069a7401d18fd1c596d 100644
--- a/media/audio/win/core_audio_util_win.cc
+++ b/media/audio/win/core_audio_util_win.cc
@@ -423,7 +423,26 @@ std::string CoreAudioUtil::GetAudioControllerID(IMMDevice* device,
std::string CoreAudioUtil::GetMatchingOutputDeviceID(
const std::string& input_device_id) {
- ScopedComPtr<IMMDevice> input_device(CreateDevice(input_device_id));
+ // Special handling for the default communications device.
+ // We always treat the configured communications devices, as a pair.
+ // If we didn't do that and the user has e.g. configured a mic of a headset
+ // as the default comms input device and a different device (not the speakers
+ // of the headset) as the default comms output device, then we would otherwise
+ // here pick the headset as the matched output device. That's technically
+ // correct, but the user experience would be that any audio played out to
+ // the matched device, would get ducked since it's not the default comms
+ // device. So here, we go with the user's configuration.
+ if (input_device_id == AudioManagerBase::kCommunicationsDeviceId)
+ return AudioManagerBase::kCommunicationsDeviceId;
+
+ ScopedComPtr<IMMDevice> input_device;
+ if (input_device_id.empty() ||
+ input_device_id == AudioManagerBase::kDefaultDeviceId) {
+ input_device = CreateDefaultDevice(eCapture, eConsole);
+ } else {
+ input_device = CreateDevice(input_device_id);
+ }
+
if (!input_device.get())
return std::string();
@@ -723,6 +742,9 @@ HRESULT CoreAudioUtil::GetPreferredAudioParameters(const std::string& device_id,
} else if (device_id == AudioManagerBase::kLoopbackInputDeviceId) {
DCHECK(!is_output_device);
device = CoreAudioUtil::CreateDefaultDevice(eRender, eConsole);
+ } else if (device_id == AudioManagerBase::kCommunicationsDeviceId) {
+ device = CoreAudioUtil::CreateDefaultDevice(
+ is_output_device ? eRender : eCapture, eCommunications);
} else {
device = CreateDevice(device_id);
}
@@ -755,18 +777,6 @@ HRESULT CoreAudioUtil::GetPreferredAudioParameters(const std::string& device_id,
params->frames_per_buffer());
}
- ScopedComPtr<IMMDevice> communications_device(
- CreateDefaultDevice(eCapture, eCommunications));
- if (communications_device &&
- GetDeviceID(communications_device.get()) == GetDeviceID(device.get())) {
- // Raise the 'DUCKING' flag for default communication devices.
- *params =
- AudioParameters(params->format(), params->channel_layout(),
- params->channels(), params->sample_rate(),
- params->bits_per_sample(), params->frames_per_buffer(),
- params->effects() | AudioParameters::DUCKING);
- }
-
return hr;
}
« no previous file with comments | « media/audio/win/audio_manager_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698