Enforcing a stream delay of 0 to be assumed in the AEC on Chrome OS

This CL forces the AEC2 to assume a stream delay of 0, thereby
avoiding that the incorrect stream delays reported on Chrome OS
causes echo issues.

Bug: chromium:797274, chromium:797272
Change-Id: I10f295c9f1d735622c55fc56be99a14c6cdd88a2
Reviewed-on: https://webrtc-review.googlesource.com/36081
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21432}
This commit is contained in:
Per Åhgren
2017-12-22 16:13:57 +01:00
committed by Commit Bot
parent 6e55c38c21
commit 11556464a6
3 changed files with 23 additions and 5 deletions

View File

@ -245,6 +245,7 @@ rtc_static_library("audio_processing") {
"../../rtc_base:protobuf_utils",
"../../rtc_base:sanitizer",
"../../system_wrappers:cpu_features_api",
"../../system_wrappers:field_trial_api",
"../../system_wrappers:metrics_api",
"../audio_coding:isac",
]

View File

@ -16,6 +16,7 @@
#include "modules/audio_processing/aec/echo_cancellation.h"
#include "modules/audio_processing/audio_buffer.h"
#include "rtc_base/checks.h"
#include "system_wrappers/include/field_trial.h"
namespace webrtc {
@ -49,6 +50,14 @@ AudioProcessing::Error MapError(int err) {
}
}
bool EnforceZeroStreamDelay() {
#if defined(CHROMEOS)
return !field_trial::IsEnabled("WebRTC-Aec2ZeroStreamDelayKillSwitch");
#else
return false;
#endif
}
} // namespace
struct EchoCancellationImpl::StreamProperties {
@ -106,7 +115,8 @@ EchoCancellationImpl::EchoCancellationImpl(rtc::CriticalSection* crit_render,
stream_has_echo_(false),
delay_logging_enabled_(false),
extended_filter_enabled_(false),
delay_agnostic_enabled_(false) {
delay_agnostic_enabled_(false),
enforce_zero_stream_delay_(EnforceZeroStreamDelay()) {
RTC_DCHECK(crit_render);
RTC_DCHECK(crit_capture);
}
@ -145,6 +155,9 @@ int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio,
return AudioProcessing::kNoError;
}
const int stream_delay_ms_use =
enforce_zero_stream_delay_ ? 0 : stream_delay_ms;
if (drift_compensation_enabled_ && !was_stream_drift_set_) {
return AudioProcessing::kStreamParameterNotSetError;
}
@ -160,10 +173,11 @@ int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio,
stream_has_echo_ = false;
for (size_t i = 0; i < audio->num_channels(); i++) {
for (size_t j = 0; j < stream_properties_->num_reverse_channels; j++) {
err = WebRtcAec_Process(
cancellers_[handle_index]->state(), audio->split_bands_const_f(i),
audio->num_bands(), audio->split_bands_f(i),
audio->num_frames_per_band(), stream_delay_ms, stream_drift_samples_);
err = WebRtcAec_Process(cancellers_[handle_index]->state(),
audio->split_bands_const_f(i), audio->num_bands(),
audio->split_bands_f(i),
audio->num_frames_per_band(), stream_delay_ms_use,
stream_drift_samples_);
if (err != AudioProcessing::kNoError) {
err = MapError(err);

View File

@ -105,6 +105,9 @@ class EchoCancellationImpl : public EchoCancellation {
bool delay_agnostic_enabled_ RTC_GUARDED_BY(crit_capture_);
bool refined_adaptive_filter_enabled_ RTC_GUARDED_BY(crit_capture_) = false;
// Only active on Chrome OS devices.
const bool enforce_zero_stream_delay_ RTC_GUARDED_BY(crit_capture_);
std::vector<std::unique_ptr<Canceller>> cancellers_;
std::unique_ptr<StreamProperties> stream_properties_;