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

Unified Diff: media/audio/win/audio_manager_win.cc

Issue 14244005: Resolves "Huge increase in audio latency on Windows following r192046" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/win/audio_manager_win.cc
diff --git a/media/audio/win/audio_manager_win.cc b/media/audio/win/audio_manager_win.cc
index 2fe74d97b038d616007cac509cbae100f3020037..38e1c60ee9fdbb9974ac6b17baba9c89bff1ee9a 100644
--- a/media/audio/win/audio_manager_win.cc
+++ b/media/audio/win/audio_manager_win.cc
@@ -367,6 +367,8 @@ AudioParameters AudioManagerWin::GetPreferredOutputStreamParameters(
// which corresponds to an output delay of ~5.33ms.
sample_rate = 48000;
buffer_size = 256;
+ if (input_params.IsValid())
+ channel_layout = input_params.channel_layout();
} else if (!use_input_params) {
// Hardware sample-rate on Windows can be configured, so we must query.
// TODO(henrika): improve possibility to specify an audio endpoint.
@@ -390,14 +392,21 @@ AudioParameters AudioManagerWin::GetPreferredOutputStreamParameters(
}
if (input_params.IsValid()) {
- if (CoreAudioUtil::IsSupported() &&
- CoreAudioUtil::IsChannelLayoutSupported(eRender, eConsole,
- input_params.channel_layout())) {
- // Open up using the same channel layout as the source if it is
- // supported by the hardware.
- channel_layout = input_params.channel_layout();
- VLOG(1) << "Hardware channel layout is not used; using same "
- << "layout as the source instead (" << channel_layout << ")";
+ if (CoreAudioUtil::IsSupported()) {
+ // Check if it is possible to open up at the specified input channel
+ // layout but avoid checking if the specified layout is the same as the
+ // hardware (preferred) layout. We do this extra check to avoid the
+ // CoreAudioUtil::IsChannelLayoutSupported() overhead in most cases.
+ if (input_params.channel_layout() != channel_layout) {
+ if (CoreAudioUtil::IsChannelLayoutSupported(
+ eRender, eConsole, input_params.channel_layout())) {
+ // Open up using the same channel layout as the source if it is
+ // supported by the hardware.
+ channel_layout = input_params.channel_layout();
+ VLOG(1) << "Hardware channel layout is not used; using same layout"
+ << " as the source instead (" << channel_layout << ")";
+ }
+ }
}
input_channels = input_params.input_channels();
if (use_input_params) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698