Skip to content

Commit

Permalink
Add DynamicAudioTimeout Feature
Browse files Browse the repository at this point in the history
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 <tguilbert@chromium.org>
Auto-Submit: Thomas Guilbert <tguilbert@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#917498}
  • Loading branch information
tguilbert-google authored and Chromium LUCI CQ committed Sep 2, 2021
1 parent 3e99d81 commit 817e826
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions services/audio/sync_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(const std::string&)> log_callback,
const media::AudioParameters& params,
Expand All @@ -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<size_t> memory_size =
media::ComputeAudioOutputBufferSizeChecked(params);
if (!memory_size.IsValid())
Expand Down

0 comments on commit 817e826

Please sign in to comment.