From 817e8262ec4d725b532729986a4e21506d483211 Mon Sep 17 00:00:00 2001 From: Thomas Guilbert Date: Thu, 2 Sep 2021 02:01:14 +0000 Subject: [PATCH] Add DynamicAudioTimeout Feature This CL adds an off-by-default feature flag, used to experiment with audio rendering timeouts, on all platforms other than Mac and CrOS. When the feature is turned on, the audio timeout is set to half a buffer's duration, rather than the 20ms default. The 20ms default was historically needed to prevent issues on versions of WinXP and such. This feature will be gradually rolled out via finch, and we will measure its effects by observing audio glitch metrics. Bug: 1244531 Change-Id: Ie5fd1d26c783e3f32d4bcd8ef7d1c42c465f376e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3138468 Commit-Queue: Thomas Guilbert Auto-Submit: Thomas Guilbert Reviewed-by: Dale Curtis Cr-Commit-Position: refs/heads/main@{#917498} --- services/audio/sync_reader.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/services/audio/sync_reader.cc b/services/audio/sync_reader.cc index b692f8e58f7e43..8ea3ee35ae9a6b 100644 --- a/services/audio/sync_reader.cc +++ b/services/audio/sync_reader.cc @@ -41,6 +41,12 @@ void LogAudioGlitchResult(AudioGlitchResult result) { namespace audio { +#if !defined(OS_MAC) && !BUILDFLAG(IS_CHROMEOS_ASH) && \ + !BUILDFLAG(IS_CHROMEOS_LACROS) +const base::Feature kDynamicAudioTimeout{"DynamicAudioTimeout", + base::FEATURE_DISABLED_BY_DEFAULT}; +#endif + SyncReader::SyncReader( base::RepeatingCallback log_callback, const media::AudioParameters& params, @@ -55,14 +61,18 @@ SyncReader::SyncReader( renderer_callback_count_(0), renderer_missed_callback_count_(0), trailing_renderer_missed_callback_count_(0), + buffer_index_(0) { #if defined(OS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH) || \ BUILDFLAG(IS_CHROMEOS_LACROS) - maximum_wait_time_(params.GetBufferDuration() / 2), + maximum_wait_time_ = params.GetBufferDuration() / 2; #else - // TODO(dalecurtis): Investigate if we can reduce this on all platforms. - maximum_wait_time_(base::TimeDelta::FromMilliseconds(20)), + if (base::FeatureList::IsEnabled(kDynamicAudioTimeout)) { + maximum_wait_time_ = params.GetBufferDuration() / 2; + } else { + maximum_wait_time_ = base::TimeDelta::FromMilliseconds(20); + } #endif - buffer_index_(0) { + base::CheckedNumeric memory_size = media::ComputeAudioOutputBufferSizeChecked(params); if (!memory_size.IsValid())