Skip to content

Commit

Permalink
Add feature for decreasing ProcessingAudioFifo size
Browse files Browse the repository at this point in the history
If ChromeWideEchoCancellation is enabled, we now use the
DecreaseProcessingAudioFifoSize experiment to set the size of the
ProcessingAudioFifo. If the experiment is disabled, the size defaults
to 110.

This simultaneously removes the
kChromeWideEchoCancellationProcessingFifoSize parameter from the
ChromeWideEchoCancellation feature. This parameter is always set to
110 today, so this CL does not change existing behaviour.

Bug: 1420568
Change-Id: Ic344cf30b04a5ca3ee011b387999fb5572185afe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4356940
Reviewed-by: Olga Sharonova <olka@chromium.org>
Reviewed-by: Thomas Guilbert <tguilbert@chromium.org>
Commit-Queue: Fredrik Hernqvist <fhernqvist@google.com>
Cr-Commit-Position: refs/heads/main@{#1120815}
  • Loading branch information
Fredrik Hernqvist authored and Chromium LUCI CQ committed Mar 22, 2023
1 parent 5345075 commit dd77168
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 90 deletions.
13 changes: 9 additions & 4 deletions chrome/browser/media/webrtc/webrtc_text_log_handler.cc
Expand Up @@ -527,10 +527,7 @@ void WebRtcTextLogHandler::OnGetNetworkInterfaceListFinish(
#if BUILDFLAG(CHROME_WIDE_ECHO_CANCELLATION)
if (media::IsChromeWideEchoCancellationEnabled()) {
LogToCircularBuffer(base::StrCat(
{"ChromeWideEchoCancellation : Enabled", ", processing_fifo_size = ",
NumberToString(
media::kChromeWideEchoCancellationProcessingFifoSize.Get()),
", minimize_resampling = ",
{"ChromeWideEchoCancellation : Enabled", ", minimize_resampling = ",
media::kChromeWideEchoCancellationMinimizeResampling.Get() ? "true"
: "false",
", allow_all_sample_rates = ",
Expand All @@ -540,6 +537,14 @@ void WebRtcTextLogHandler::OnGetNetworkInterfaceListFinish(
} else {
LogToCircularBuffer("ChromeWideEchoCancellation : Disabled");
}

if (base::FeatureList::IsEnabled(media::kDecreaseProcessingAudioFifoSize)) {
LogToCircularBuffer(base::StrCat(
{"DecreaseProcessingAudioFifoSize : Enabled", ", fifo_size = ",
base::NumberToString(media::GetProcessingAudioFifoSize())}));
} else {
LogToCircularBuffer("DecreaseProcessingAudioFifoSize : Disabled");
}
#endif

// Audio manager
Expand Down
16 changes: 11 additions & 5 deletions content/browser/media/media_internals.cc
Expand Up @@ -499,11 +499,7 @@ void MediaInternals::SendGeneralAudioInformation() {
std::string chrome_wide_echo_cancellation_value_string =
media::IsChromeWideEchoCancellationEnabled()
? base::StrCat(
{"Enabled, processing_fifo_size = ",
base::NumberToString(
media::kChromeWideEchoCancellationProcessingFifoSize
.Get()),
", minimize_resampling = ",
{"Enabled, minimize_resampling = ",
media::kChromeWideEchoCancellationMinimizeResampling.Get()
? "true"
: "false",
Expand All @@ -514,6 +510,16 @@ void MediaInternals::SendGeneralAudioInformation() {
: "Disabled";
audio_info_data.Set(media::kChromeWideEchoCancellation.name,
base::Value(chrome_wide_echo_cancellation_value_string));

std::string decrease_processing_audio_fifo_size_value_string =
base::FeatureList::IsEnabled(media::kDecreaseProcessingAudioFifoSize)
? base::StrCat(
{"Enabled, fifo_size = ",
base::NumberToString(media::GetProcessingAudioFifoSize())})
: "Disabled";
audio_info_data.Set(
media::kDecreaseProcessingAudioFifoSize.name,
base::Value(decrease_processing_audio_fifo_size_value_string));
#endif
std::u16string audio_info_update =
SerializeUpdate("media.updateGeneralAudioInformation", audio_info_data);
Expand Down
44 changes: 35 additions & 9 deletions media/base/media_switches.cc
Expand Up @@ -425,15 +425,6 @@ BASE_FEATURE(kChromeWideEchoCancellation,
#endif
);

// If non-zero, audio processing is done on a dedicated processing thread which
// receives audio from the audio capture thread via a fifo of a specified size.
// Zero fifo size means the usage of such processing thread is disabled and
// processing is done on the audio capture thread itself.
const base::FeatureParam<int> kChromeWideEchoCancellationProcessingFifoSize{
&kChromeWideEchoCancellation, "processing_fifo_size",
110 // Default value for the enabled feature.
};

// When audio processing is done in the audio process, at the renderer side IPC
// is set up to receive audio at the processing sample rate. This is a
// kill-switch to fallback to receiving audio at the default sample rate of the
Expand All @@ -457,6 +448,27 @@ const base::FeatureParam<double>
// https://crbug.com/1332484.
const base::FeatureParam<bool> kChromeWideEchoCancellationAllowAllSampleRates{
&kChromeWideEchoCancellation, "allow_all_sample_rates", true};

// https://crbug.com/1420568
// Applicable only if kChromeWideEchoCancellation is enabled.
// If disabled, the ProcessingAudioFifo size defaults to 110.
// If enabled, the ProcessingAudioFifo size is set to the value of the fifo_size
// parameter.
//
// If the ProcessingAudioFifo size is non-zero, audio processing is done on a
// dedicated processing thread which receives audio from the audio capture
// thread via a fifo of a specified size.
// If the ProcessingAudioFifo size is zero, the usage of this processing thread
// is disabled and processing is done on the audio capture thread itself.
BASE_FEATURE(kDecreaseProcessingAudioFifoSize,
"DecreaseProcessingAudioFifoSize",
base::FEATURE_DISABLED_BY_DEFAULT);

const base::FeatureParam<int> kDecreaseProcessingAudioFifoSizeValue{
&kDecreaseProcessingAudioFifoSize, "fifo_size",
110 // Default value for the enabled feature.
};

#endif

#if BUILDFLAG(IS_CHROMEOS)
Expand Down Expand Up @@ -1424,6 +1436,20 @@ bool IsChromeWideEchoCancellationEnabled() {
#endif
}

int GetProcessingAudioFifoSize() {
#if BUILDFLAG(CHROME_WIDE_ECHO_CANCELLATION)
if (!IsChromeWideEchoCancellationEnabled()) {
return 0;
}
if (base::FeatureList::IsEnabled(media::kDecreaseProcessingAudioFifoSize)) {
return media::kDecreaseProcessingAudioFifoSizeValue.Get();
}
return 110;
#else
return 0;
#endif
}

bool IsHardwareSecureDecryptionEnabled() {
return base::FeatureList::IsEnabled(kHardwareSecureDecryption) ||
base::FeatureList::IsEnabled(kHardwareSecureDecryptionExperiment);
Expand Down
6 changes: 4 additions & 2 deletions media/base/media_switches.h
Expand Up @@ -164,14 +164,15 @@ MEDIA_EXPORT BASE_DECLARE_FEATURE(kCdmHostVerification);
MEDIA_EXPORT BASE_DECLARE_FEATURE(kCdmProcessSiteIsolation);
#if BUILDFLAG(CHROME_WIDE_ECHO_CANCELLATION)
MEDIA_EXPORT BASE_DECLARE_FEATURE(kChromeWideEchoCancellation);
MEDIA_EXPORT extern const base::FeatureParam<int>
kChromeWideEchoCancellationProcessingFifoSize;
MEDIA_EXPORT extern const base::FeatureParam<bool>
kChromeWideEchoCancellationMinimizeResampling;
MEDIA_EXPORT extern const base::FeatureParam<double>
kChromeWideEchoCancellationDynamicMixingTimeout;
MEDIA_EXPORT extern const base::FeatureParam<bool>
kChromeWideEchoCancellationAllowAllSampleRates;
MEDIA_EXPORT BASE_DECLARE_FEATURE(kDecreaseProcessingAudioFifoSize);
MEDIA_EXPORT extern const base::FeatureParam<int>
kDecreaseProcessingAudioFifoSizeValue;
#endif
#if BUILDFLAG(IS_CHROMEOS)
MEDIA_EXPORT BASE_DECLARE_FEATURE(kCrOSSystemAEC);
Expand Down Expand Up @@ -421,6 +422,7 @@ MEDIA_EXPORT std::string GetEffectiveAutoplayPolicy(
const base::CommandLine& command_line);

MEDIA_EXPORT bool IsChromeWideEchoCancellationEnabled();
MEDIA_EXPORT int GetProcessingAudioFifoSize();
MEDIA_EXPORT bool IsHardwareSecureDecryptionEnabled();
MEDIA_EXPORT bool IsVideoCaptureAcceleratedJpegDecodingEnabled();

Expand Down
5 changes: 1 addition & 4 deletions services/audio/input_controller.cc
Expand Up @@ -264,10 +264,7 @@ void InputController::MaybeSetUpAudioProcessing(
return;
}

int fifo_size =
media::IsChromeWideEchoCancellationEnabled()
? media::kChromeWideEchoCancellationProcessingFifoSize.Get()
: 0;
int fifo_size = media::GetProcessingAudioFifoSize();

// Only use the FIFO/new thread if its size is explicitly set.
if (fifo_size) {
Expand Down

0 comments on commit dd77168

Please sign in to comment.