2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-30 20:51:15 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_processing/audio_processing_impl.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-07-23 11:41:39 -07:00
|
|
|
#include <algorithm>
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <cstdint>
|
2022-11-17 11:26:58 +01:00
|
|
|
#include <cstring>
|
2019-09-17 17:06:18 +02:00
|
|
|
#include <memory>
|
2017-05-22 06:57:06 -07:00
|
|
|
#include <string>
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <type_traits>
|
|
|
|
|
#include <utility>
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2022-03-18 12:39:00 +01:00
|
|
|
#include "absl/strings/match.h"
|
2022-07-25 22:07:08 +02:00
|
|
|
#include "absl/strings/string_view.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "absl/types/optional.h"
|
|
|
|
|
#include "api/array_view.h"
|
2020-03-16 12:06:02 +01:00
|
|
|
#include "api/audio/audio_frame.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "common_audio/audio_converter.h"
|
|
|
|
|
#include "common_audio/include/audio_util.h"
|
2020-05-11 11:03:47 +02:00
|
|
|
#include "modules/audio_processing/aec_dump/aec_dump_factory.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_processing/audio_buffer.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "modules/audio_processing/include/audio_frame_view.h"
|
2018-02-12 21:42:56 +01:00
|
|
|
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
2020-04-27 08:39:33 +02:00
|
|
|
#include "modules/audio_processing/optionally_built_submodule_creators.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/checks.h"
|
2022-11-30 16:59:05 +01:00
|
|
|
#include "rtc_base/experiments/field_trial_parser.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/logging.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/time_utils.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/trace_event.h"
|
2021-08-10 15:23:23 +02:00
|
|
|
#include "system_wrappers/include/denormal_disabler.h"
|
2019-09-20 07:50:35 +02:00
|
|
|
#include "system_wrappers/include/field_trial.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "system_wrappers/include/metrics.h"
|
2011-12-03 00:03:31 +00:00
|
|
|
|
2015-07-23 11:41:39 -07:00
|
|
|
#define RETURN_ON_ERR(expr) \
|
|
|
|
|
do { \
|
|
|
|
|
int err = (expr); \
|
|
|
|
|
if (err != kNoError) { \
|
|
|
|
|
return err; \
|
|
|
|
|
} \
|
2014-01-07 17:45:09 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
namespace webrtc {
|
2016-03-16 18:26:35 -07:00
|
|
|
|
2015-07-23 11:41:39 -07:00
|
|
|
namespace {
|
|
|
|
|
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
bool SampleRateSupportsMultiBand(int sample_rate_hz) {
|
2016-03-16 18:26:35 -07:00
|
|
|
return sample_rate_hz == AudioProcessing::kSampleRate32kHz ||
|
|
|
|
|
sample_rate_hz == AudioProcessing::kSampleRate48kHz;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 13:04:15 +01:00
|
|
|
// Checks whether the high-pass filter should be done in the full-band.
|
|
|
|
|
bool EnforceSplitBandHpf() {
|
|
|
|
|
return field_trial::IsEnabled("WebRTC-FullBandHpfKillSwitch");
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-02 14:59:40 +01:00
|
|
|
// Checks whether AEC3 should be allowed to decide what the default
|
|
|
|
|
// configuration should be based on the render and capture channel configuration
|
|
|
|
|
// at hand.
|
|
|
|
|
bool UseSetupSpecificDefaultAec3Congfig() {
|
|
|
|
|
return !field_trial::IsEnabled(
|
|
|
|
|
"WebRTC-Aec3SetupSpecificDefaultConfigDefaultsKillSwitch");
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-23 15:49:51 +02:00
|
|
|
// Identify the native processing rate that best handles a sample rate.
|
2019-09-15 00:27:58 +02:00
|
|
|
int SuitableProcessRate(int minimum_rate,
|
|
|
|
|
int max_splitting_rate,
|
|
|
|
|
bool band_splitting_required) {
|
2019-08-23 15:49:51 +02:00
|
|
|
const int uppermost_native_rate =
|
2019-09-15 00:27:58 +02:00
|
|
|
band_splitting_required ? max_splitting_rate : 48000;
|
2019-08-23 15:49:51 +02:00
|
|
|
for (auto rate : {16000, 32000, 48000}) {
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
if (rate >= uppermost_native_rate) {
|
|
|
|
|
return uppermost_native_rate;
|
|
|
|
|
}
|
|
|
|
|
if (rate >= minimum_rate) {
|
2016-03-16 18:26:35 -07:00
|
|
|
return rate;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
return uppermost_native_rate;
|
2016-03-16 18:26:35 -07:00
|
|
|
}
|
|
|
|
|
|
2019-03-27 13:28:08 +01:00
|
|
|
GainControl::Mode Agc1ConfigModeToInterfaceMode(
|
|
|
|
|
AudioProcessing::Config::GainController1::Mode mode) {
|
|
|
|
|
using Agc1Config = AudioProcessing::Config::GainController1;
|
|
|
|
|
switch (mode) {
|
|
|
|
|
case Agc1Config::kAdaptiveAnalog:
|
|
|
|
|
return GainControl::kAdaptiveAnalog;
|
|
|
|
|
case Agc1Config::kAdaptiveDigital:
|
|
|
|
|
return GainControl::kAdaptiveDigital;
|
|
|
|
|
case Agc1Config::kFixedDigital:
|
|
|
|
|
return GainControl::kFixedDigital;
|
|
|
|
|
}
|
2020-11-08 00:49:37 +01:00
|
|
|
RTC_CHECK_NOTREACHED();
|
2019-03-27 13:28:08 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-12 23:08:09 +00:00
|
|
|
bool MinimizeProcessingForUnusedOutput() {
|
|
|
|
|
return !field_trial::IsEnabled("WebRTC-MutedStateKillSwitch");
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 07:19:21 -07:00
|
|
|
// Maximum lengths that frame of samples being passed from the render side to
|
|
|
|
|
// the capture side can have (does not apply to AEC3).
|
|
|
|
|
static const size_t kMaxAllowedValuesOfSamplesPerBand = 160;
|
|
|
|
|
static const size_t kMaxAllowedValuesOfSamplesPerFrame = 480;
|
|
|
|
|
|
2016-10-22 05:04:30 -07:00
|
|
|
// Maximum number of frames to buffer in the render queue.
|
|
|
|
|
// TODO(peah): Decrease this once we properly handle hugely unbalanced
|
|
|
|
|
// reverse and forward call numbers.
|
|
|
|
|
static const size_t kMaxNumFramesToBuffer = 100;
|
2020-10-14 12:47:50 +02:00
|
|
|
|
2021-12-06 15:40:04 +01:00
|
|
|
void PackRenderAudioBufferForEchoDetector(const AudioBuffer& audio,
|
|
|
|
|
std::vector<float>& packed_buffer) {
|
|
|
|
|
packed_buffer.clear();
|
|
|
|
|
packed_buffer.insert(packed_buffer.end(), audio.channels_const()[0],
|
|
|
|
|
audio.channels_const()[0] + audio.num_frames());
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 11:26:58 +01:00
|
|
|
// Options for gracefully handling processing errors.
|
|
|
|
|
enum class FormatErrorOutputOption {
|
|
|
|
|
kOutputExactCopyOfInput,
|
|
|
|
|
kOutputBroadcastCopyOfFirstInputChannel,
|
|
|
|
|
kOutputSilence,
|
|
|
|
|
kDoNothing
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class AudioFormatValidity {
|
|
|
|
|
// Format is supported by APM.
|
|
|
|
|
kValidAndSupported,
|
|
|
|
|
// Format has a reasonable interpretation but is not supported.
|
|
|
|
|
kValidButUnsupportedSampleRate,
|
|
|
|
|
// The remaining enums values signal that the audio does not have a reasonable
|
|
|
|
|
// interpretation and cannot be used.
|
|
|
|
|
kInvalidSampleRate,
|
|
|
|
|
kInvalidChannelCount
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AudioFormatValidity ValidateAudioFormat(const StreamConfig& config) {
|
|
|
|
|
if (config.sample_rate_hz() < 0)
|
|
|
|
|
return AudioFormatValidity::kInvalidSampleRate;
|
|
|
|
|
if (config.num_channels() == 0)
|
|
|
|
|
return AudioFormatValidity::kInvalidChannelCount;
|
|
|
|
|
|
|
|
|
|
// Format has a reasonable interpretation, but may still be unsupported.
|
|
|
|
|
if (config.sample_rate_hz() < 8000 ||
|
|
|
|
|
config.sample_rate_hz() > AudioBuffer::kMaxSampleRate)
|
|
|
|
|
return AudioFormatValidity::kValidButUnsupportedSampleRate;
|
|
|
|
|
|
|
|
|
|
// Format is fully supported.
|
|
|
|
|
return AudioFormatValidity::kValidAndSupported;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AudioFormatValidityToErrorCode(AudioFormatValidity validity) {
|
|
|
|
|
switch (validity) {
|
|
|
|
|
case AudioFormatValidity::kValidAndSupported:
|
|
|
|
|
return AudioProcessing::kNoError;
|
|
|
|
|
case AudioFormatValidity::kValidButUnsupportedSampleRate: // fall-through
|
|
|
|
|
case AudioFormatValidity::kInvalidSampleRate:
|
|
|
|
|
return AudioProcessing::kBadSampleRateError;
|
|
|
|
|
case AudioFormatValidity::kInvalidChannelCount:
|
|
|
|
|
return AudioProcessing::kBadNumberChannelsError;
|
|
|
|
|
}
|
|
|
|
|
RTC_DCHECK(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns an AudioProcessing::Error together with the best possible option for
|
|
|
|
|
// output audio content.
|
|
|
|
|
std::pair<int, FormatErrorOutputOption> ChooseErrorOutputOption(
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config) {
|
|
|
|
|
AudioFormatValidity input_validity = ValidateAudioFormat(input_config);
|
|
|
|
|
AudioFormatValidity output_validity = ValidateAudioFormat(output_config);
|
|
|
|
|
|
2022-11-21 16:32:42 +01:00
|
|
|
if (input_validity == AudioFormatValidity::kValidAndSupported &&
|
|
|
|
|
output_validity == AudioFormatValidity::kValidAndSupported &&
|
|
|
|
|
(output_config.num_channels() == 1 ||
|
|
|
|
|
output_config.num_channels() == input_config.num_channels())) {
|
|
|
|
|
return {AudioProcessing::kNoError, FormatErrorOutputOption::kDoNothing};
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 11:26:58 +01:00
|
|
|
int error_code = AudioFormatValidityToErrorCode(input_validity);
|
|
|
|
|
if (error_code == AudioProcessing::kNoError) {
|
|
|
|
|
error_code = AudioFormatValidityToErrorCode(output_validity);
|
|
|
|
|
}
|
2022-11-21 16:32:42 +01:00
|
|
|
if (error_code == AudioProcessing::kNoError) {
|
|
|
|
|
// The individual formats are valid but there is some error - must be
|
|
|
|
|
// channel mismatch.
|
|
|
|
|
error_code = AudioProcessing::kBadNumberChannelsError;
|
|
|
|
|
}
|
2022-11-17 11:26:58 +01:00
|
|
|
|
|
|
|
|
FormatErrorOutputOption output_option;
|
|
|
|
|
if (output_validity != AudioFormatValidity::kValidAndSupported &&
|
|
|
|
|
output_validity != AudioFormatValidity::kValidButUnsupportedSampleRate) {
|
|
|
|
|
// The output format is uninterpretable: cannot do anything.
|
|
|
|
|
output_option = FormatErrorOutputOption::kDoNothing;
|
|
|
|
|
} else if (input_validity != AudioFormatValidity::kValidAndSupported &&
|
|
|
|
|
input_validity !=
|
|
|
|
|
AudioFormatValidity::kValidButUnsupportedSampleRate) {
|
|
|
|
|
// The input format is uninterpretable: cannot use it, must output silence.
|
|
|
|
|
output_option = FormatErrorOutputOption::kOutputSilence;
|
|
|
|
|
} else if (input_config.sample_rate_hz() != output_config.sample_rate_hz()) {
|
|
|
|
|
// Sample rates do not match: Cannot copy input into output, output silence.
|
|
|
|
|
// Note: If the sample rates are in a supported range, we could resample.
|
|
|
|
|
// However, that would significantly increase complexity of this error
|
|
|
|
|
// handling code.
|
|
|
|
|
output_option = FormatErrorOutputOption::kOutputSilence;
|
|
|
|
|
} else if (input_config.num_channels() != output_config.num_channels()) {
|
|
|
|
|
// Channel counts do not match: We cannot easily map input channels to
|
|
|
|
|
// output channels.
|
|
|
|
|
output_option =
|
|
|
|
|
FormatErrorOutputOption::kOutputBroadcastCopyOfFirstInputChannel;
|
|
|
|
|
} else {
|
|
|
|
|
// The formats match exactly.
|
|
|
|
|
RTC_DCHECK(input_config == output_config);
|
|
|
|
|
output_option = FormatErrorOutputOption::kOutputExactCopyOfInput;
|
|
|
|
|
}
|
|
|
|
|
return std::make_pair(error_code, output_option);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Checks if the audio format is supported. If not, the output is populated in a
|
|
|
|
|
// best-effort manner and an APM error code is returned.
|
|
|
|
|
int HandleUnsupportedAudioFormats(const int16_t* const src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
|
|
|
|
int16_t* const dest) {
|
|
|
|
|
RTC_DCHECK(src);
|
|
|
|
|
RTC_DCHECK(dest);
|
|
|
|
|
|
|
|
|
|
auto [error_code, output_option] =
|
|
|
|
|
ChooseErrorOutputOption(input_config, output_config);
|
|
|
|
|
if (error_code == AudioProcessing::kNoError)
|
|
|
|
|
return AudioProcessing::kNoError;
|
|
|
|
|
|
|
|
|
|
const size_t num_output_channels = output_config.num_channels();
|
|
|
|
|
switch (output_option) {
|
|
|
|
|
case FormatErrorOutputOption::kOutputSilence:
|
|
|
|
|
memset(dest, 0, output_config.num_samples() * sizeof(int16_t));
|
|
|
|
|
break;
|
|
|
|
|
case FormatErrorOutputOption::kOutputBroadcastCopyOfFirstInputChannel:
|
|
|
|
|
for (size_t i = 0; i < output_config.num_frames(); ++i) {
|
|
|
|
|
int16_t sample = src[input_config.num_channels() * i];
|
|
|
|
|
for (size_t ch = 0; ch < num_output_channels; ++ch) {
|
|
|
|
|
dest[ch + num_output_channels * i] = sample;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case FormatErrorOutputOption::kOutputExactCopyOfInput:
|
|
|
|
|
memcpy(dest, src, output_config.num_samples() * sizeof(int16_t));
|
|
|
|
|
break;
|
|
|
|
|
case FormatErrorOutputOption::kDoNothing:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return error_code;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Checks if the audio format is supported. If not, the output is populated in a
|
|
|
|
|
// best-effort manner and an APM error code is returned.
|
|
|
|
|
int HandleUnsupportedAudioFormats(const float* const* src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
|
|
|
|
float* const* dest) {
|
|
|
|
|
RTC_DCHECK(src);
|
|
|
|
|
RTC_DCHECK(dest);
|
|
|
|
|
for (size_t i = 0; i < input_config.num_channels(); ++i) {
|
|
|
|
|
RTC_DCHECK(src[i]);
|
|
|
|
|
}
|
|
|
|
|
for (size_t i = 0; i < output_config.num_channels(); ++i) {
|
|
|
|
|
RTC_DCHECK(dest[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto [error_code, output_option] =
|
|
|
|
|
ChooseErrorOutputOption(input_config, output_config);
|
|
|
|
|
if (error_code == AudioProcessing::kNoError)
|
|
|
|
|
return AudioProcessing::kNoError;
|
|
|
|
|
|
|
|
|
|
const size_t num_output_channels = output_config.num_channels();
|
|
|
|
|
switch (output_option) {
|
|
|
|
|
case FormatErrorOutputOption::kOutputSilence:
|
|
|
|
|
for (size_t ch = 0; ch < num_output_channels; ++ch) {
|
|
|
|
|
memset(dest[ch], 0, output_config.num_frames() * sizeof(float));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case FormatErrorOutputOption::kOutputBroadcastCopyOfFirstInputChannel:
|
|
|
|
|
for (size_t ch = 0; ch < num_output_channels; ++ch) {
|
|
|
|
|
memcpy(dest[ch], src[0], output_config.num_frames() * sizeof(float));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case FormatErrorOutputOption::kOutputExactCopyOfInput:
|
|
|
|
|
for (size_t ch = 0; ch < num_output_channels; ++ch) {
|
|
|
|
|
memcpy(dest[ch], src[ch], output_config.num_frames() * sizeof(float));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case FormatErrorOutputOption::kDoNothing:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return error_code;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-14 16:36:10 +01:00
|
|
|
using DownmixMethod = AudioProcessing::Config::Pipeline::DownmixMethod;
|
|
|
|
|
|
|
|
|
|
void SetDownmixMethod(AudioBuffer& buffer, DownmixMethod method) {
|
|
|
|
|
switch (method) {
|
|
|
|
|
case DownmixMethod::kAverageChannels:
|
|
|
|
|
buffer.set_downmixing_by_averaging();
|
|
|
|
|
break;
|
|
|
|
|
case DownmixMethod::kUseFirstChannel:
|
|
|
|
|
buffer.set_downmixing_to_specific_channel(/*channel=*/0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constexpr int kUnspecifiedDataDumpInputVolume = -100;
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
// Throughout webrtc, it's assumed that success is represented by zero.
|
|
|
|
|
static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero");
|
|
|
|
|
|
|
|
|
|
absl::optional<AudioProcessingImpl::GainController2ExperimentParams>
|
|
|
|
|
AudioProcessingImpl::GetGainController2ExperimentParams() {
|
2022-12-08 17:40:01 +01:00
|
|
|
constexpr char kFieldTrialName[] = "WebRTC-Audio-GainController2";
|
2022-11-30 16:59:05 +01:00
|
|
|
|
2022-12-08 17:40:01 +01:00
|
|
|
if (!field_trial::IsEnabled(kFieldTrialName)) {
|
2022-11-30 16:59:05 +01:00
|
|
|
return absl::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FieldTrialFlag enabled("Enabled", false);
|
2022-12-14 16:36:10 +01:00
|
|
|
|
|
|
|
|
// Whether the gain control should switch to AGC2. Enabled by default.
|
|
|
|
|
FieldTrialParameter<bool> switch_to_agc2("switch_to_agc2", true);
|
|
|
|
|
|
|
|
|
|
// AGC2 input volume controller configuration.
|
|
|
|
|
constexpr InputVolumeController::Config kDefaultInputVolumeControllerConfig;
|
|
|
|
|
FieldTrialConstrained<int> min_input_volume(
|
|
|
|
|
"min_input_volume", kDefaultInputVolumeControllerConfig.min_input_volume,
|
|
|
|
|
0, 255);
|
2022-11-30 16:59:05 +01:00
|
|
|
FieldTrialConstrained<int> clipped_level_min(
|
2022-12-08 17:40:01 +01:00
|
|
|
"clipped_level_min",
|
|
|
|
|
kDefaultInputVolumeControllerConfig.clipped_level_min, 0, 255);
|
2022-11-30 16:59:05 +01:00
|
|
|
FieldTrialConstrained<int> clipped_level_step(
|
2022-12-08 17:40:01 +01:00
|
|
|
"clipped_level_step",
|
|
|
|
|
kDefaultInputVolumeControllerConfig.clipped_level_step, 0, 255);
|
2022-11-30 16:59:05 +01:00
|
|
|
FieldTrialConstrained<double> clipped_ratio_threshold(
|
2022-12-08 17:40:01 +01:00
|
|
|
"clipped_ratio_threshold",
|
|
|
|
|
kDefaultInputVolumeControllerConfig.clipped_ratio_threshold, 0, 1);
|
2022-11-30 16:59:05 +01:00
|
|
|
FieldTrialConstrained<int> clipped_wait_frames(
|
2022-12-08 17:40:01 +01:00
|
|
|
"clipped_wait_frames",
|
|
|
|
|
kDefaultInputVolumeControllerConfig.clipped_wait_frames, 0,
|
2022-11-30 16:59:05 +01:00
|
|
|
absl::nullopt);
|
|
|
|
|
FieldTrialParameter<bool> enable_clipping_predictor(
|
2022-12-08 17:40:01 +01:00
|
|
|
"enable_clipping_predictor",
|
|
|
|
|
kDefaultInputVolumeControllerConfig.enable_clipping_predictor);
|
2022-11-30 16:59:05 +01:00
|
|
|
FieldTrialConstrained<int> target_range_max_dbfs(
|
2022-12-08 17:40:01 +01:00
|
|
|
"target_range_max_dbfs",
|
|
|
|
|
kDefaultInputVolumeControllerConfig.target_range_max_dbfs, -90, 30);
|
2022-11-30 16:59:05 +01:00
|
|
|
FieldTrialConstrained<int> target_range_min_dbfs(
|
2022-12-08 17:40:01 +01:00
|
|
|
"target_range_min_dbfs",
|
|
|
|
|
kDefaultInputVolumeControllerConfig.target_range_min_dbfs, -90, 30);
|
2022-11-30 16:59:05 +01:00
|
|
|
FieldTrialConstrained<int> update_input_volume_wait_frames(
|
|
|
|
|
"update_input_volume_wait_frames",
|
2022-12-08 17:40:01 +01:00
|
|
|
kDefaultInputVolumeControllerConfig.update_input_volume_wait_frames, 0,
|
|
|
|
|
absl::nullopt);
|
2022-11-30 16:59:05 +01:00
|
|
|
FieldTrialConstrained<double> speech_probability_threshold(
|
|
|
|
|
"speech_probability_threshold",
|
2022-12-08 17:40:01 +01:00
|
|
|
kDefaultInputVolumeControllerConfig.speech_probability_threshold, 0, 1);
|
2022-11-30 16:59:05 +01:00
|
|
|
FieldTrialConstrained<double> speech_ratio_threshold(
|
2022-12-08 17:40:01 +01:00
|
|
|
"speech_ratio_threshold",
|
|
|
|
|
kDefaultInputVolumeControllerConfig.speech_ratio_threshold, 0, 1);
|
|
|
|
|
|
2022-12-14 16:36:10 +01:00
|
|
|
// AGC2 adaptive digital controller configuration.
|
2022-12-08 17:40:01 +01:00
|
|
|
constexpr AudioProcessing::Config::GainController2::AdaptiveDigital
|
|
|
|
|
kDefaultAdaptiveDigitalConfig;
|
|
|
|
|
FieldTrialConstrained<double> headroom_db(
|
|
|
|
|
"headroom_db", kDefaultAdaptiveDigitalConfig.headroom_db, 0,
|
|
|
|
|
absl::nullopt);
|
|
|
|
|
FieldTrialConstrained<double> max_gain_db(
|
|
|
|
|
"max_gain_db", kDefaultAdaptiveDigitalConfig.max_gain_db, 0,
|
|
|
|
|
absl::nullopt);
|
2022-12-09 10:02:41 +01:00
|
|
|
FieldTrialConstrained<double> initial_gain_db(
|
|
|
|
|
"initial_gain_db", kDefaultAdaptiveDigitalConfig.initial_gain_db, 0,
|
|
|
|
|
absl::nullopt);
|
2022-12-08 17:40:01 +01:00
|
|
|
FieldTrialConstrained<double> max_gain_change_db_per_second(
|
|
|
|
|
"max_gain_change_db_per_second",
|
|
|
|
|
kDefaultAdaptiveDigitalConfig.max_gain_change_db_per_second, 0,
|
|
|
|
|
absl::nullopt);
|
|
|
|
|
FieldTrialConstrained<double> max_output_noise_level_dbfs(
|
|
|
|
|
"max_output_noise_level_dbfs",
|
|
|
|
|
kDefaultAdaptiveDigitalConfig.max_output_noise_level_dbfs, absl::nullopt,
|
|
|
|
|
0);
|
2022-11-30 16:59:05 +01:00
|
|
|
|
2022-12-14 16:36:10 +01:00
|
|
|
// Transient suppressor.
|
|
|
|
|
FieldTrialParameter<bool> disallow_transient_suppressor_usage(
|
|
|
|
|
"disallow_transient_suppressor_usage", false);
|
|
|
|
|
|
2022-12-08 17:40:01 +01:00
|
|
|
// Field-trial based override for the input volume controller and adaptive
|
|
|
|
|
// digital configs.
|
2022-12-09 10:02:41 +01:00
|
|
|
ParseFieldTrial(
|
2022-12-14 16:36:10 +01:00
|
|
|
{&enabled, &switch_to_agc2, &min_input_volume, &clipped_level_min,
|
|
|
|
|
&clipped_level_step, &clipped_ratio_threshold, &clipped_wait_frames,
|
2022-12-09 10:02:41 +01:00
|
|
|
&enable_clipping_predictor, &target_range_max_dbfs,
|
|
|
|
|
&target_range_min_dbfs, &update_input_volume_wait_frames,
|
|
|
|
|
&speech_probability_threshold, &speech_ratio_threshold, &headroom_db,
|
|
|
|
|
&max_gain_db, &initial_gain_db, &max_gain_change_db_per_second,
|
2022-12-14 16:36:10 +01:00
|
|
|
&max_output_noise_level_dbfs, &disallow_transient_suppressor_usage},
|
|
|
|
|
field_trial::FindFullName(kFieldTrialName));
|
2022-11-30 16:59:05 +01:00
|
|
|
// Checked already by `IsEnabled()` before parsing, therefore always true.
|
|
|
|
|
RTC_DCHECK(enabled);
|
|
|
|
|
|
2022-12-14 16:36:10 +01:00
|
|
|
const bool do_not_change_agc_config = !switch_to_agc2.Get();
|
|
|
|
|
if (do_not_change_agc_config && !disallow_transient_suppressor_usage.Get()) {
|
|
|
|
|
// Return an unspecifed value since, in this case, both the AGC2 and TS
|
|
|
|
|
// configurations won't be adjusted.
|
|
|
|
|
return absl::nullopt;
|
|
|
|
|
}
|
|
|
|
|
using Params = AudioProcessingImpl::GainController2ExperimentParams;
|
|
|
|
|
if (do_not_change_agc_config) {
|
|
|
|
|
// Return a value that leaves the AGC2 config unchanged and that always
|
|
|
|
|
// disables TS.
|
|
|
|
|
return Params{.agc2_config = absl::nullopt,
|
|
|
|
|
.disallow_transient_suppressor_usage = true};
|
|
|
|
|
}
|
|
|
|
|
// Return a value that switches all the gain control to AGC2.
|
|
|
|
|
return Params{
|
|
|
|
|
.agc2_config =
|
|
|
|
|
Params::Agc2Config{
|
|
|
|
|
.input_volume_controller =
|
|
|
|
|
{
|
|
|
|
|
.min_input_volume = min_input_volume.Get(),
|
|
|
|
|
.clipped_level_min = clipped_level_min.Get(),
|
|
|
|
|
.clipped_level_step = clipped_level_step.Get(),
|
|
|
|
|
.clipped_ratio_threshold =
|
|
|
|
|
static_cast<float>(clipped_ratio_threshold.Get()),
|
|
|
|
|
.clipped_wait_frames = clipped_wait_frames.Get(),
|
|
|
|
|
.enable_clipping_predictor =
|
|
|
|
|
enable_clipping_predictor.Get(),
|
|
|
|
|
.target_range_max_dbfs = target_range_max_dbfs.Get(),
|
|
|
|
|
.target_range_min_dbfs = target_range_min_dbfs.Get(),
|
|
|
|
|
.update_input_volume_wait_frames =
|
|
|
|
|
update_input_volume_wait_frames.Get(),
|
|
|
|
|
.speech_probability_threshold = static_cast<float>(
|
|
|
|
|
speech_probability_threshold.Get()),
|
|
|
|
|
.speech_ratio_threshold =
|
|
|
|
|
static_cast<float>(speech_ratio_threshold.Get()),
|
|
|
|
|
},
|
|
|
|
|
.adaptive_digital_controller =
|
|
|
|
|
{
|
|
|
|
|
.headroom_db = static_cast<float>(headroom_db.Get()),
|
|
|
|
|
.max_gain_db = static_cast<float>(max_gain_db.Get()),
|
|
|
|
|
.initial_gain_db =
|
|
|
|
|
static_cast<float>(initial_gain_db.Get()),
|
|
|
|
|
.max_gain_change_db_per_second = static_cast<float>(
|
|
|
|
|
max_gain_change_db_per_second.Get()),
|
|
|
|
|
.max_output_noise_level_dbfs =
|
|
|
|
|
static_cast<float>(max_output_noise_level_dbfs.Get()),
|
|
|
|
|
}},
|
|
|
|
|
.disallow_transient_suppressor_usage =
|
|
|
|
|
disallow_transient_suppressor_usage.Get()};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AudioProcessing::Config AudioProcessingImpl::AdjustConfig(
|
2022-11-30 16:59:05 +01:00
|
|
|
const AudioProcessing::Config& config,
|
2022-12-14 16:36:10 +01:00
|
|
|
const absl::optional<AudioProcessingImpl::GainController2ExperimentParams>&
|
|
|
|
|
experiment_params) {
|
|
|
|
|
if (!experiment_params.has_value() ||
|
|
|
|
|
(!experiment_params->agc2_config.has_value() &&
|
|
|
|
|
!experiment_params->disallow_transient_suppressor_usage)) {
|
|
|
|
|
// When the experiment parameters are unspecified or when the AGC and TS
|
|
|
|
|
// configuration are not overridden, return the unmodified configuration.
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 16:13:35 +01:00
|
|
|
AudioProcessing::Config adjusted_config = config;
|
2022-11-30 16:59:05 +01:00
|
|
|
|
2022-12-07 16:13:35 +01:00
|
|
|
// Override the transient suppressor configuration.
|
2022-12-14 16:36:10 +01:00
|
|
|
if (experiment_params->disallow_transient_suppressor_usage) {
|
2022-12-07 16:13:35 +01:00
|
|
|
adjusted_config.transient_suppression.enabled = false;
|
2022-11-30 16:59:05 +01:00
|
|
|
}
|
|
|
|
|
|
2022-12-07 16:13:35 +01:00
|
|
|
// Override the auto gain control configuration if the AGC1 analog gain
|
2022-12-14 16:36:10 +01:00
|
|
|
// controller is active and `experiment_params->agc2_config` is specified.
|
2022-12-07 16:13:35 +01:00
|
|
|
const bool agc1_analog_enabled =
|
2022-11-30 16:59:05 +01:00
|
|
|
config.gain_controller1.enabled &&
|
2022-12-07 16:13:35 +01:00
|
|
|
(config.gain_controller1.mode ==
|
|
|
|
|
AudioProcessing::Config::GainController1::kAdaptiveAnalog ||
|
|
|
|
|
config.gain_controller1.analog_gain_controller.enabled);
|
2022-12-14 16:36:10 +01:00
|
|
|
if (agc1_analog_enabled && experiment_params->agc2_config.has_value()) {
|
2022-12-07 16:13:35 +01:00
|
|
|
// Check that the unadjusted AGC config meets the preconditions.
|
|
|
|
|
const bool hybrid_agc_config_detected =
|
|
|
|
|
config.gain_controller1.enabled &&
|
|
|
|
|
config.gain_controller1.analog_gain_controller.enabled &&
|
|
|
|
|
!config.gain_controller1.analog_gain_controller
|
|
|
|
|
.enable_digital_adaptive &&
|
|
|
|
|
config.gain_controller2.enabled &&
|
|
|
|
|
config.gain_controller2.adaptive_digital.enabled;
|
|
|
|
|
const bool full_agc1_config_detected =
|
|
|
|
|
config.gain_controller1.enabled &&
|
|
|
|
|
config.gain_controller1.analog_gain_controller.enabled &&
|
|
|
|
|
config.gain_controller1.analog_gain_controller
|
|
|
|
|
.enable_digital_adaptive &&
|
|
|
|
|
!config.gain_controller2.enabled;
|
|
|
|
|
const bool one_and_only_one_input_volume_controller =
|
|
|
|
|
hybrid_agc_config_detected != full_agc1_config_detected;
|
2023-01-16 20:19:48 +01:00
|
|
|
const bool agc2_input_volume_controller_enabled =
|
|
|
|
|
config.gain_controller2.enabled &&
|
|
|
|
|
config.gain_controller2.input_volume_controller.enabled;
|
2022-12-07 16:13:35 +01:00
|
|
|
if (!one_and_only_one_input_volume_controller ||
|
2023-01-16 20:19:48 +01:00
|
|
|
agc2_input_volume_controller_enabled) {
|
2022-12-07 16:13:35 +01:00
|
|
|
RTC_LOG(LS_ERROR) << "Cannot adjust AGC config (precondition failed)";
|
|
|
|
|
if (!one_and_only_one_input_volume_controller)
|
|
|
|
|
RTC_LOG(LS_ERROR)
|
|
|
|
|
<< "One and only one input volume controller must be enabled.";
|
2023-01-16 20:19:48 +01:00
|
|
|
if (agc2_input_volume_controller_enabled)
|
2022-12-07 16:13:35 +01:00
|
|
|
RTC_LOG(LS_ERROR)
|
|
|
|
|
<< "The AGC2 input volume controller must be disabled.";
|
|
|
|
|
} else {
|
|
|
|
|
adjusted_config.gain_controller1.enabled = false;
|
|
|
|
|
adjusted_config.gain_controller1.analog_gain_controller.enabled = false;
|
2022-12-08 17:40:01 +01:00
|
|
|
|
2022-12-07 16:13:35 +01:00
|
|
|
adjusted_config.gain_controller2.enabled = true;
|
|
|
|
|
adjusted_config.gain_controller2.input_volume_controller.enabled = true;
|
2022-12-09 10:02:41 +01:00
|
|
|
adjusted_config.gain_controller2.adaptive_digital =
|
2022-12-14 16:36:10 +01:00
|
|
|
experiment_params->agc2_config->adaptive_digital_controller;
|
2022-12-09 10:02:41 +01:00
|
|
|
adjusted_config.gain_controller2.adaptive_digital.enabled = true;
|
2022-12-07 16:13:35 +01:00
|
|
|
}
|
2022-11-30 16:59:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return adjusted_config;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-16 20:19:48 +01:00
|
|
|
bool AudioProcessingImpl::UseApmVadSubModule(
|
|
|
|
|
const AudioProcessing::Config& config,
|
|
|
|
|
const absl::optional<GainController2ExperimentParams>& experiment_params) {
|
|
|
|
|
// The VAD as an APM sub-module is needed only in one case, that is when TS
|
|
|
|
|
// and AGC2 are both enabled and when the AGC2 experiment is running and its
|
|
|
|
|
// parameters require to fully switch the gain control to AGC2.
|
|
|
|
|
return config.transient_suppression.enabled &&
|
|
|
|
|
config.gain_controller2.enabled &&
|
|
|
|
|
(config.gain_controller2.input_volume_controller.enabled ||
|
|
|
|
|
config.gain_controller2.adaptive_digital.enabled) &&
|
|
|
|
|
experiment_params.has_value() &&
|
|
|
|
|
experiment_params->agc2_config.has_value();
|
2022-12-01 13:26:26 +01:00
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
AudioProcessingImpl::SubmoduleStates::SubmoduleStates(
|
2017-12-18 16:02:40 +01:00
|
|
|
bool capture_post_processor_enabled,
|
2018-08-29 10:37:09 +02:00
|
|
|
bool render_pre_processor_enabled,
|
|
|
|
|
bool capture_analyzer_enabled)
|
2017-12-18 16:02:40 +01:00
|
|
|
: capture_post_processor_enabled_(capture_post_processor_enabled),
|
2018-08-29 10:37:09 +02:00
|
|
|
render_pre_processor_enabled_(render_pre_processor_enabled),
|
|
|
|
|
capture_analyzer_enabled_(capture_analyzer_enabled) {}
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
bool AudioProcessingImpl::SubmoduleStates::Update(
|
2018-09-28 14:15:09 +02:00
|
|
|
bool high_pass_filter_enabled,
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
bool mobile_echo_controller_enabled,
|
|
|
|
|
bool noise_suppressor_enabled,
|
|
|
|
|
bool adaptive_gain_controller_enabled,
|
2017-05-22 06:57:06 -07:00
|
|
|
bool gain_controller2_enabled,
|
2022-06-16 16:35:45 +02:00
|
|
|
bool voice_activity_detector_enabled,
|
2021-03-15 16:31:04 +00:00
|
|
|
bool gain_adjustment_enabled,
|
2017-10-16 13:49:04 +02:00
|
|
|
bool echo_controller_enabled,
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
bool transient_suppressor_enabled) {
|
|
|
|
|
bool changed = false;
|
2018-09-28 14:15:09 +02:00
|
|
|
changed |= (high_pass_filter_enabled != high_pass_filter_enabled_);
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
changed |=
|
|
|
|
|
(mobile_echo_controller_enabled != mobile_echo_controller_enabled_);
|
|
|
|
|
changed |= (noise_suppressor_enabled != noise_suppressor_enabled_);
|
|
|
|
|
changed |=
|
|
|
|
|
(adaptive_gain_controller_enabled != adaptive_gain_controller_enabled_);
|
2019-04-26 11:33:37 +02:00
|
|
|
changed |= (gain_controller2_enabled != gain_controller2_enabled_);
|
2022-06-16 16:35:45 +02:00
|
|
|
changed |=
|
|
|
|
|
(voice_activity_detector_enabled != voice_activity_detector_enabled_);
|
2021-03-15 16:31:04 +00:00
|
|
|
changed |= (gain_adjustment_enabled != gain_adjustment_enabled_);
|
2017-10-16 13:49:04 +02:00
|
|
|
changed |= (echo_controller_enabled != echo_controller_enabled_);
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
changed |= (transient_suppressor_enabled != transient_suppressor_enabled_);
|
|
|
|
|
if (changed) {
|
2018-09-28 14:15:09 +02:00
|
|
|
high_pass_filter_enabled_ = high_pass_filter_enabled;
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
mobile_echo_controller_enabled_ = mobile_echo_controller_enabled;
|
|
|
|
|
noise_suppressor_enabled_ = noise_suppressor_enabled;
|
|
|
|
|
adaptive_gain_controller_enabled_ = adaptive_gain_controller_enabled;
|
2017-05-22 06:57:06 -07:00
|
|
|
gain_controller2_enabled_ = gain_controller2_enabled;
|
2022-06-16 16:35:45 +02:00
|
|
|
voice_activity_detector_enabled_ = voice_activity_detector_enabled;
|
2021-03-15 16:31:04 +00:00
|
|
|
gain_adjustment_enabled_ = gain_adjustment_enabled;
|
2017-10-16 13:49:04 +02:00
|
|
|
echo_controller_enabled_ = echo_controller_enabled;
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
transient_suppressor_enabled_ = transient_suppressor_enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
changed |= first_update_;
|
|
|
|
|
first_update_ = false;
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
bool AudioProcessingImpl::SubmoduleStates::CaptureMultiBandSubModulesActive()
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
const {
|
Reland "Reland "Remove unused APM voice activity detection sub-module""
This reverts commit 09aaf6f7bcfb4da644bd86c76896a04a41f776e1.
Reason for revert: downstream fixed (see https://chromium-review.googlesource.com/c/chromium/src/+/3461371)
Original change's description:
> Revert "Reland "Remove unused APM voice activity detection sub-module""
>
> This reverts commit 54d1344d985b00d4d1580dd18057d4618c11ad1f.
>
> Reason for revert: Breaks chromium roll, see
> https://ci.chromium.org/ui/p/chromium/builders/try/linux_chromium_tsan_rel_ng/1080583/overview
>
> https://chromium-review.googlesource.com/c/chromium/src/+/3461512
>
> Original change's description:
> > Reland "Remove unused APM voice activity detection sub-module"
> >
> > This reverts commit a751f167c68343f76528436defdbc61600a8d7b3.
> >
> > Reason for revert: dependency in a downstream project removed
> >
> > Original change's description:
> > > Revert "Remove unused APM voice activity detection sub-module"
> > >
> > > This reverts commit b4e06d032e6f82a65c52ed0c5364ae9e7c0a0215.
> > >
> > > Reason for revert: breaking downstream projects
> > >
> > > Original change's description:
> > > > Remove unused APM voice activity detection sub-module
> > > >
> > > > API changes:
> > > > - webrtc::AudioProcessing::Config::VoiceDetection removed
> > > > - webrtc::AudioProcessingStats::voice_detected deprecated
> > > > - cricket::AudioOptions::typing_detection deprecated
> > > > - webrtc::StatsReport::StatsValueName::
> > > > kStatsValueNameTypingNoiseState deprecated
> > > >
> > > > PSA: https://groups.google.com/g/discuss-webrtc/c/7X6uwmJarE0
> > > >
> > > > Bug: webrtc:11226,webrtc:11292
> > > > Change-Id: I8d008b56708cf62961b9857ec052b59fda3b41bf
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250666
> > > > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > > > Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
> > > > Reviewed-by: Sam Zackrisson <saza@webrtc.org>
> > > > Reviewed-by: Björn Terelius <terelius@webrtc.org>
> > > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > > > Cr-Commit-Position: refs/heads/main@{#35975}
> > >
> > > TBR=gustaf@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,terelius@webrtc.org,hta@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com
> > >
> > > Change-Id: Iee01fdb874b4e0331277f3ffe60dacaabc3859a2
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: webrtc:11226,webrtc:11292
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251600
> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > > Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
> > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > > Cr-Commit-Position: refs/heads/main@{#35977}
> >
> > # Not skipping CQ checks because this is a reland.
> >
> > Bug: webrtc:11226,webrtc:11292
> > Change-Id: I2fcbc5fdade16bfe6a0f0a02841a33a598d4f2ad
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251660
> > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#35984}
>
> TBR=mbonadei@webrtc.org,gustaf@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,terelius@webrtc.org,hta@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com
>
> Change-Id: Ib308a3af2dcce85a0074ef5a4680ccec3f82712f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:11226,webrtc:11292
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251688
> Reviewed-by: Henrik Boström <hbos@webrtc.org>
> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
> Auto-Submit: Henrik Boström <hbos@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#35990}
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11226,webrtc:11292
Change-Id: Idfda6a517027ad323caf44c526a88468e5b52b65
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251762
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36012}
2022-02-15 14:18:09 +00:00
|
|
|
return CaptureMultiBandProcessingPresent();
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
bool AudioProcessingImpl::SubmoduleStates::CaptureMultiBandProcessingPresent()
|
|
|
|
|
const {
|
2019-10-09 13:34:36 +02:00
|
|
|
// If echo controller is present, assume it performs active processing.
|
|
|
|
|
return CaptureMultiBandProcessingActive(/*ec_processing_active=*/true);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
bool AudioProcessingImpl::SubmoduleStates::CaptureMultiBandProcessingActive(
|
2019-10-09 13:34:36 +02:00
|
|
|
bool ec_processing_active) const {
|
2019-12-09 10:18:44 +01:00
|
|
|
return high_pass_filter_enabled_ || mobile_echo_controller_enabled_ ||
|
|
|
|
|
noise_suppressor_enabled_ || adaptive_gain_controller_enabled_ ||
|
2019-10-09 13:34:36 +02:00
|
|
|
(echo_controller_enabled_ && ec_processing_active);
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
bool AudioProcessingImpl::SubmoduleStates::CaptureFullBandProcessingActive()
|
2017-05-23 05:33:56 -07:00
|
|
|
const {
|
2018-04-16 16:31:22 +02:00
|
|
|
return gain_controller2_enabled_ || capture_post_processor_enabled_ ||
|
2021-03-15 16:31:04 +00:00
|
|
|
gain_adjustment_enabled_;
|
2017-05-23 05:33:56 -07:00
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
bool AudioProcessingImpl::SubmoduleStates::CaptureAnalyzerActive() const {
|
2018-08-29 10:37:09 +02:00
|
|
|
return capture_analyzer_enabled_;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
bool AudioProcessingImpl::SubmoduleStates::RenderMultiBandSubModulesActive()
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
const {
|
2019-12-09 10:18:44 +01:00
|
|
|
return RenderMultiBandProcessingActive() || mobile_echo_controller_enabled_ ||
|
|
|
|
|
adaptive_gain_controller_enabled_ || echo_controller_enabled_;
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
bool AudioProcessingImpl::SubmoduleStates::RenderFullBandProcessingActive()
|
2017-12-18 16:02:40 +01:00
|
|
|
const {
|
|
|
|
|
return render_pre_processor_enabled_;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
bool AudioProcessingImpl::SubmoduleStates::RenderMultiBandProcessingActive()
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
const {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
bool AudioProcessingImpl::SubmoduleStates::HighPassFilteringRequired() const {
|
2019-12-09 10:18:44 +01:00
|
|
|
return high_pass_filter_enabled_ || mobile_echo_controller_enabled_ ||
|
|
|
|
|
noise_suppressor_enabled_;
|
2018-09-28 14:15:09 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-17 08:26:10 +02:00
|
|
|
AudioProcessingImpl::AudioProcessingImpl()
|
2021-10-14 10:55:08 +02:00
|
|
|
: AudioProcessingImpl(/*config=*/{},
|
|
|
|
|
/*capture_post_processor=*/nullptr,
|
2019-09-20 07:50:35 +02:00
|
|
|
/*render_pre_processor=*/nullptr,
|
|
|
|
|
/*echo_control_factory=*/nullptr,
|
|
|
|
|
/*echo_detector=*/nullptr,
|
|
|
|
|
/*capture_analyzer=*/nullptr) {}
|
2015-01-15 18:07:21 +00:00
|
|
|
|
2022-06-27 09:47:02 +02:00
|
|
|
std::atomic<int> AudioProcessingImpl::instance_count_(0);
|
2018-02-12 21:42:56 +01:00
|
|
|
|
2017-09-25 12:04:02 +02:00
|
|
|
AudioProcessingImpl::AudioProcessingImpl(
|
2021-10-14 10:55:08 +02:00
|
|
|
const AudioProcessing::Config& config,
|
2017-12-18 16:02:40 +01:00
|
|
|
std::unique_ptr<CustomProcessing> capture_post_processor,
|
|
|
|
|
std::unique_ptr<CustomProcessing> render_pre_processor,
|
2017-10-12 15:13:17 +02:00
|
|
|
std::unique_ptr<EchoControlFactory> echo_control_factory,
|
2018-08-29 10:37:09 +02:00
|
|
|
rtc::scoped_refptr<EchoDetector> echo_detector,
|
|
|
|
|
std::unique_ptr<CustomAudioAnalyzer> capture_analyzer)
|
2022-06-27 09:47:02 +02:00
|
|
|
: data_dumper_(new ApmDataDumper(instance_count_.fetch_add(1) + 1)),
|
2019-12-02 14:59:40 +01:00
|
|
|
use_setup_specific_default_aec3_config_(
|
|
|
|
|
UseSetupSpecificDefaultAec3Congfig()),
|
2022-12-14 16:36:10 +01:00
|
|
|
gain_controller2_experiment_params_(GetGainController2ExperimentParams()),
|
2023-01-16 20:19:48 +01:00
|
|
|
transient_suppressor_vad_mode_(TransientSuppressor::VadMode::kDefault),
|
2021-03-03 10:52:44 +00:00
|
|
|
capture_runtime_settings_(RuntimeSettingQueueSize()),
|
|
|
|
|
render_runtime_settings_(RuntimeSettingQueueSize()),
|
2018-05-15 10:52:28 +02:00
|
|
|
capture_runtime_settings_enqueuer_(&capture_runtime_settings_),
|
|
|
|
|
render_runtime_settings_enqueuer_(&render_runtime_settings_),
|
2017-10-12 15:13:17 +02:00
|
|
|
echo_control_factory_(std::move(echo_control_factory)),
|
2022-12-14 16:36:10 +01:00
|
|
|
config_(AdjustConfig(config, gain_controller2_experiment_params_)),
|
2018-08-29 10:37:09 +02:00
|
|
|
submodule_states_(!!capture_post_processor,
|
|
|
|
|
!!render_pre_processor,
|
|
|
|
|
!!capture_analyzer),
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_(std::move(capture_post_processor),
|
|
|
|
|
std::move(render_pre_processor),
|
|
|
|
|
std::move(echo_detector),
|
2019-11-22 12:11:40 +01:00
|
|
|
std::move(capture_analyzer)),
|
2020-01-13 14:43:13 +01:00
|
|
|
constants_(!field_trial::IsEnabled(
|
2019-09-20 07:50:35 +02:00
|
|
|
"WebRTC-ApmExperimentalMultiChannelRenderKillSwitch"),
|
|
|
|
|
!field_trial::IsEnabled(
|
2019-12-10 13:04:15 +01:00
|
|
|
"WebRTC-ApmExperimentalMultiChannelCaptureKillSwitch"),
|
2021-03-12 23:08:09 +00:00
|
|
|
EnforceSplitBandHpf(),
|
2021-05-18 12:17:56 +02:00
|
|
|
MinimizeProcessingForUnusedOutput(),
|
|
|
|
|
field_trial::IsEnabled("WebRTC-TransientSuppressorForcedOff")),
|
2021-03-12 23:08:09 +00:00
|
|
|
capture_(),
|
2022-10-27 00:05:32 +02:00
|
|
|
capture_nonlocked_(),
|
|
|
|
|
applied_input_volume_stats_reporter_(
|
|
|
|
|
InputVolumeStatsReporter::InputVolumeType::kApplied),
|
|
|
|
|
recommended_input_volume_stats_reporter_(
|
|
|
|
|
InputVolumeStatsReporter::InputVolumeType::kRecommended) {
|
2019-10-21 12:54:02 +02:00
|
|
|
RTC_LOG(LS_INFO) << "Injected APM submodules:"
|
2020-01-14 12:11:31 +01:00
|
|
|
"\nEcho control factory: "
|
|
|
|
|
<< !!echo_control_factory_
|
2019-10-21 12:54:02 +02:00
|
|
|
<< "\nEcho detector: " << !!submodules_.echo_detector
|
|
|
|
|
<< "\nCapture analyzer: " << !!submodules_.capture_analyzer
|
|
|
|
|
<< "\nCapture post processor: "
|
|
|
|
|
<< !!submodules_.capture_post_processor
|
|
|
|
|
<< "\nRender pre processor: "
|
|
|
|
|
<< !!submodules_.render_pre_processor;
|
2022-11-17 11:26:58 +01:00
|
|
|
if (!DenormalDisabler::IsSupported()) {
|
|
|
|
|
RTC_LOG(LS_INFO) << "Denormal disabler unsupported";
|
|
|
|
|
}
|
2019-10-21 12:54:02 +02:00
|
|
|
|
2022-11-30 16:59:05 +01:00
|
|
|
RTC_LOG(LS_INFO) << "AudioProcessing: " << config_.ToString();
|
|
|
|
|
|
2019-02-11 13:39:46 +01:00
|
|
|
// Mark Echo Controller enabled if a factory is injected.
|
|
|
|
|
capture_nonlocked_.echo_controller_enabled =
|
|
|
|
|
static_cast<bool>(echo_control_factory_);
|
|
|
|
|
|
2020-09-01 23:57:20 +02:00
|
|
|
Initialize();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-18 08:52:22 +01:00
|
|
|
AudioProcessingImpl::~AudioProcessingImpl() = default;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
int AudioProcessingImpl::Initialize() {
|
2015-11-28 12:35:15 -08:00
|
|
|
// Run in a single-threaded manner during initialization.
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_render(&mutex_render_);
|
|
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2020-09-01 23:57:20 +02:00
|
|
|
InitializeLocked();
|
|
|
|
|
return kNoError;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-07-23 11:41:39 -07:00
|
|
|
int AudioProcessingImpl::Initialize(const ProcessingConfig& processing_config) {
|
2015-11-28 12:35:15 -08:00
|
|
|
// Run in a single-threaded manner during initialization.
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_render(&mutex_render_);
|
|
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2022-11-17 11:26:58 +01:00
|
|
|
InitializeLocked(processing_config);
|
|
|
|
|
return kNoError;
|
2014-03-10 22:26:12 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-17 11:26:58 +01:00
|
|
|
void AudioProcessingImpl::MaybeInitializeRender(
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config) {
|
|
|
|
|
ProcessingConfig processing_config = formats_.api_format;
|
|
|
|
|
processing_config.reverse_input_stream() = input_config;
|
|
|
|
|
processing_config.reverse_output_stream() = output_config;
|
|
|
|
|
|
2019-05-23 14:28:00 +02:00
|
|
|
if (processing_config == formats_.api_format) {
|
2022-11-17 11:26:58 +01:00
|
|
|
return;
|
2015-11-17 02:16:45 -08:00
|
|
|
}
|
2015-11-28 12:35:15 -08:00
|
|
|
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2022-11-17 11:26:58 +01:00
|
|
|
InitializeLocked(processing_config);
|
2015-11-17 02:16:45 -08:00
|
|
|
}
|
|
|
|
|
|
2020-09-01 23:57:20 +02:00
|
|
|
void AudioProcessingImpl::InitializeLocked() {
|
2017-06-27 16:00:38 +02:00
|
|
|
UpdateActiveSubmoduleStates();
|
|
|
|
|
|
2019-08-22 11:51:13 +02:00
|
|
|
const int render_audiobuffer_sample_rate_hz =
|
2015-11-28 12:35:15 -08:00
|
|
|
formats_.api_format.reverse_output_stream().num_frames() == 0
|
2019-08-22 11:51:13 +02:00
|
|
|
? formats_.render_processing_format.sample_rate_hz()
|
|
|
|
|
: formats_.api_format.reverse_output_stream().sample_rate_hz();
|
2015-11-28 12:35:15 -08:00
|
|
|
if (formats_.api_format.reverse_input_stream().num_channels() > 0) {
|
|
|
|
|
render_.render_audio.reset(new AudioBuffer(
|
2019-08-22 11:51:13 +02:00
|
|
|
formats_.api_format.reverse_input_stream().sample_rate_hz(),
|
2015-11-28 12:35:15 -08:00
|
|
|
formats_.api_format.reverse_input_stream().num_channels(),
|
2019-08-22 11:51:13 +02:00
|
|
|
formats_.render_processing_format.sample_rate_hz(),
|
2016-09-16 15:02:15 -07:00
|
|
|
formats_.render_processing_format.num_channels(),
|
2019-08-22 11:51:13 +02:00
|
|
|
render_audiobuffer_sample_rate_hz,
|
|
|
|
|
formats_.render_processing_format.num_channels()));
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
if (formats_.api_format.reverse_input_stream() !=
|
|
|
|
|
formats_.api_format.reverse_output_stream()) {
|
2016-02-24 05:22:32 -08:00
|
|
|
render_.render_converter = AudioConverter::Create(
|
2015-11-28 12:35:15 -08:00
|
|
|
formats_.api_format.reverse_input_stream().num_channels(),
|
|
|
|
|
formats_.api_format.reverse_input_stream().num_frames(),
|
|
|
|
|
formats_.api_format.reverse_output_stream().num_channels(),
|
2016-02-24 05:22:32 -08:00
|
|
|
formats_.api_format.reverse_output_stream().num_frames());
|
2015-08-14 10:35:55 -07:00
|
|
|
} else {
|
2015-11-28 12:35:15 -08:00
|
|
|
render_.render_converter.reset(nullptr);
|
2015-08-14 10:35:55 -07:00
|
|
|
}
|
2015-07-23 11:41:39 -07:00
|
|
|
} else {
|
2015-11-28 12:35:15 -08:00
|
|
|
render_.render_audio.reset(nullptr);
|
|
|
|
|
render_.render_converter.reset(nullptr);
|
2015-07-23 11:41:39 -07:00
|
|
|
}
|
2017-05-19 01:28:05 -07:00
|
|
|
|
2019-08-22 11:51:13 +02:00
|
|
|
capture_.capture_audio.reset(new AudioBuffer(
|
|
|
|
|
formats_.api_format.input_stream().sample_rate_hz(),
|
|
|
|
|
formats_.api_format.input_stream().num_channels(),
|
|
|
|
|
capture_nonlocked_.capture_processing_format.sample_rate_hz(),
|
|
|
|
|
formats_.api_format.output_stream().num_channels(),
|
|
|
|
|
formats_.api_format.output_stream().sample_rate_hz(),
|
|
|
|
|
formats_.api_format.output_stream().num_channels()));
|
2022-12-01 13:26:26 +01:00
|
|
|
SetDownmixMethod(*capture_.capture_audio,
|
|
|
|
|
config_.pipeline.capture_downmix_method);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2019-10-09 13:02:14 +02:00
|
|
|
if (capture_nonlocked_.capture_processing_format.sample_rate_hz() <
|
|
|
|
|
formats_.api_format.output_stream().sample_rate_hz() &&
|
|
|
|
|
formats_.api_format.output_stream().sample_rate_hz() == 48000) {
|
|
|
|
|
capture_.capture_fullband_audio.reset(
|
|
|
|
|
new AudioBuffer(formats_.api_format.input_stream().sample_rate_hz(),
|
|
|
|
|
formats_.api_format.input_stream().num_channels(),
|
|
|
|
|
formats_.api_format.output_stream().sample_rate_hz(),
|
|
|
|
|
formats_.api_format.output_stream().num_channels(),
|
|
|
|
|
formats_.api_format.output_stream().sample_rate_hz(),
|
|
|
|
|
formats_.api_format.output_stream().num_channels()));
|
2022-12-01 13:26:26 +01:00
|
|
|
SetDownmixMethod(*capture_.capture_fullband_audio,
|
|
|
|
|
config_.pipeline.capture_downmix_method);
|
2019-10-09 13:02:14 +02:00
|
|
|
} else {
|
|
|
|
|
capture_.capture_fullband_audio.reset();
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-22 05:04:30 -07:00
|
|
|
AllocateRenderQueue();
|
|
|
|
|
|
2020-01-13 14:43:13 +01:00
|
|
|
InitializeGainController1();
|
2020-01-02 15:15:36 +01:00
|
|
|
InitializeTransientSuppressor();
|
2020-01-03 14:27:14 +01:00
|
|
|
InitializeHighPassFilter(true);
|
2016-10-28 05:39:16 -07:00
|
|
|
InitializeResidualEchoDetector();
|
2017-10-14 08:28:46 +02:00
|
|
|
InitializeEchoController();
|
2023-01-16 20:19:48 +01:00
|
|
|
InitializeGainController2();
|
|
|
|
|
InitializeVoiceActivityDetector();
|
2019-10-16 11:46:11 +02:00
|
|
|
InitializeNoiseSuppressor();
|
2018-08-29 10:37:09 +02:00
|
|
|
InitializeAnalyzer();
|
2017-09-25 12:04:02 +02:00
|
|
|
InitializePostProcessor();
|
2017-12-18 16:02:40 +01:00
|
|
|
InitializePreProcessor();
|
2021-03-15 16:31:04 +00:00
|
|
|
InitializeCaptureLevelsAdjuster();
|
2015-12-08 11:07:32 -08:00
|
|
|
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
if (aec_dump_) {
|
2018-08-10 15:38:52 +02:00
|
|
|
aec_dump_->WriteInitMessage(formats_.api_format, rtc::TimeUTCMillis());
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-17 11:26:58 +01:00
|
|
|
void AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) {
|
2017-06-27 16:00:38 +02:00
|
|
|
UpdateActiveSubmoduleStates();
|
|
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
formats_.api_format = config;
|
2014-04-22 21:00:04 +00:00
|
|
|
|
2019-09-15 00:27:58 +02:00
|
|
|
// Choose maximum rate to use for the split filtering.
|
|
|
|
|
RTC_DCHECK(config_.pipeline.maximum_internal_processing_rate == 48000 ||
|
|
|
|
|
config_.pipeline.maximum_internal_processing_rate == 32000);
|
|
|
|
|
int max_splitting_rate = 48000;
|
|
|
|
|
if (config_.pipeline.maximum_internal_processing_rate == 32000) {
|
|
|
|
|
max_splitting_rate = config_.pipeline.maximum_internal_processing_rate;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-23 15:49:51 +02:00
|
|
|
int capture_processing_rate = SuitableProcessRate(
|
2016-04-09 16:06:52 -07:00
|
|
|
std::min(formats_.api_format.input_stream().sample_rate_hz(),
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
formats_.api_format.output_stream().sample_rate_hz()),
|
2019-09-15 00:27:58 +02:00
|
|
|
max_splitting_rate,
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
submodule_states_.CaptureMultiBandSubModulesActive() ||
|
|
|
|
|
submodule_states_.RenderMultiBandSubModulesActive());
|
2019-08-23 15:49:51 +02:00
|
|
|
RTC_DCHECK_NE(8000, capture_processing_rate);
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
|
2016-09-16 15:02:15 -07:00
|
|
|
capture_nonlocked_.capture_processing_format =
|
|
|
|
|
StreamConfig(capture_processing_rate);
|
2014-04-22 21:00:04 +00:00
|
|
|
|
2017-04-07 03:57:48 -07:00
|
|
|
int render_processing_rate;
|
2017-10-18 12:32:42 +02:00
|
|
|
if (!capture_nonlocked_.echo_controller_enabled) {
|
2019-08-23 15:49:51 +02:00
|
|
|
render_processing_rate = SuitableProcessRate(
|
2017-04-07 03:57:48 -07:00
|
|
|
std::min(formats_.api_format.reverse_input_stream().sample_rate_hz(),
|
|
|
|
|
formats_.api_format.reverse_output_stream().sample_rate_hz()),
|
2019-09-15 00:27:58 +02:00
|
|
|
max_splitting_rate,
|
2017-04-07 03:57:48 -07:00
|
|
|
submodule_states_.CaptureMultiBandSubModulesActive() ||
|
|
|
|
|
submodule_states_.RenderMultiBandSubModulesActive());
|
|
|
|
|
} else {
|
|
|
|
|
render_processing_rate = capture_processing_rate;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-16 15:02:15 -07:00
|
|
|
// If the forward sample rate is 8 kHz, the render stream is also processed
|
2016-04-20 15:27:58 -07:00
|
|
|
// at this rate.
|
2016-09-16 15:02:15 -07:00
|
|
|
if (capture_nonlocked_.capture_processing_format.sample_rate_hz() ==
|
|
|
|
|
kSampleRate8kHz) {
|
|
|
|
|
render_processing_rate = kSampleRate8kHz;
|
2014-04-22 21:00:04 +00:00
|
|
|
} else {
|
2016-09-16 15:02:15 -07:00
|
|
|
render_processing_rate =
|
|
|
|
|
std::max(render_processing_rate, static_cast<int>(kSampleRate16kHz));
|
2014-03-10 22:26:12 +00:00
|
|
|
}
|
|
|
|
|
|
2019-08-23 15:49:51 +02:00
|
|
|
RTC_DCHECK_NE(8000, render_processing_rate);
|
|
|
|
|
|
2017-05-19 01:28:05 -07:00
|
|
|
if (submodule_states_.RenderMultiBandSubModulesActive()) {
|
2019-09-20 07:50:35 +02:00
|
|
|
// By default, downmix the render stream to mono for analysis. This has been
|
|
|
|
|
// demonstrated to work well for AEC in most practical scenarios.
|
2019-11-27 09:34:22 +01:00
|
|
|
const bool multi_channel_render = config_.pipeline.multi_channel_render &&
|
|
|
|
|
constants_.multi_channel_render_support;
|
2019-09-20 07:50:35 +02:00
|
|
|
int render_processing_num_channels =
|
2019-11-27 09:34:22 +01:00
|
|
|
multi_channel_render
|
2019-09-20 07:50:35 +02:00
|
|
|
? formats_.api_format.reverse_input_stream().num_channels()
|
|
|
|
|
: 1;
|
|
|
|
|
formats_.render_processing_format =
|
|
|
|
|
StreamConfig(render_processing_rate, render_processing_num_channels);
|
2017-05-19 01:28:05 -07:00
|
|
|
} else {
|
|
|
|
|
formats_.render_processing_format = StreamConfig(
|
|
|
|
|
formats_.api_format.reverse_input_stream().sample_rate_hz(),
|
|
|
|
|
formats_.api_format.reverse_input_stream().num_channels());
|
|
|
|
|
}
|
2014-03-10 22:26:12 +00:00
|
|
|
|
2016-09-16 15:02:15 -07:00
|
|
|
if (capture_nonlocked_.capture_processing_format.sample_rate_hz() ==
|
|
|
|
|
kSampleRate32kHz ||
|
|
|
|
|
capture_nonlocked_.capture_processing_format.sample_rate_hz() ==
|
|
|
|
|
kSampleRate48kHz) {
|
2015-11-28 12:35:15 -08:00
|
|
|
capture_nonlocked_.split_rate = kSampleRate16kHz;
|
2014-03-10 22:26:12 +00:00
|
|
|
} else {
|
2015-11-28 12:35:15 -08:00
|
|
|
capture_nonlocked_.split_rate =
|
2016-09-16 15:02:15 -07:00
|
|
|
capture_nonlocked_.capture_processing_format.sample_rate_hz();
|
2014-03-10 22:26:12 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-01 23:57:20 +02:00
|
|
|
InitializeLocked();
|
2014-03-10 22:26:12 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-12 16:47:25 -07:00
|
|
|
void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
|
|
|
|
|
// Run in a single-threaded manner when applying the settings.
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_render(&mutex_render_);
|
|
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2016-09-12 16:47:25 -07:00
|
|
|
|
2022-11-30 16:59:05 +01:00
|
|
|
const auto adjusted_config =
|
2022-12-14 16:36:10 +01:00
|
|
|
AdjustConfig(config, gain_controller2_experiment_params_);
|
2022-11-30 16:59:05 +01:00
|
|
|
RTC_LOG(LS_INFO) << "AudioProcessing::ApplyConfig: "
|
|
|
|
|
<< adjusted_config.ToString();
|
|
|
|
|
|
2019-09-20 07:50:35 +02:00
|
|
|
const bool pipeline_config_changed =
|
2019-11-27 09:34:22 +01:00
|
|
|
config_.pipeline.multi_channel_render !=
|
2022-11-30 16:59:05 +01:00
|
|
|
adjusted_config.pipeline.multi_channel_render ||
|
2019-11-27 09:34:22 +01:00
|
|
|
config_.pipeline.multi_channel_capture !=
|
2022-11-30 16:59:05 +01:00
|
|
|
adjusted_config.pipeline.multi_channel_capture ||
|
2019-12-10 13:04:15 +01:00
|
|
|
config_.pipeline.maximum_internal_processing_rate !=
|
2022-12-01 13:26:26 +01:00
|
|
|
adjusted_config.pipeline.maximum_internal_processing_rate ||
|
|
|
|
|
config_.pipeline.capture_downmix_method !=
|
|
|
|
|
adjusted_config.pipeline.capture_downmix_method;
|
2019-09-20 07:50:35 +02:00
|
|
|
|
2019-03-06 04:16:46 +01:00
|
|
|
const bool aec_config_changed =
|
2022-11-30 16:59:05 +01:00
|
|
|
config_.echo_canceller.enabled !=
|
|
|
|
|
adjusted_config.echo_canceller.enabled ||
|
|
|
|
|
config_.echo_canceller.mobile_mode !=
|
|
|
|
|
adjusted_config.echo_canceller.mobile_mode;
|
2018-10-10 18:29:07 +02:00
|
|
|
|
2019-03-27 13:28:08 +01:00
|
|
|
const bool agc1_config_changed =
|
2022-11-30 16:59:05 +01:00
|
|
|
config_.gain_controller1 != adjusted_config.gain_controller1;
|
2019-03-27 13:28:08 +01:00
|
|
|
|
2020-01-03 10:36:34 +01:00
|
|
|
const bool agc2_config_changed =
|
2022-11-30 16:59:05 +01:00
|
|
|
config_.gain_controller2 != adjusted_config.gain_controller2;
|
2020-01-03 10:36:34 +01:00
|
|
|
|
2019-10-16 11:46:11 +02:00
|
|
|
const bool ns_config_changed =
|
2022-11-30 16:59:05 +01:00
|
|
|
config_.noise_suppression.enabled !=
|
|
|
|
|
adjusted_config.noise_suppression.enabled ||
|
|
|
|
|
config_.noise_suppression.level !=
|
|
|
|
|
adjusted_config.noise_suppression.level;
|
2019-10-16 11:46:11 +02:00
|
|
|
|
2020-01-02 15:15:36 +01:00
|
|
|
const bool ts_config_changed = config_.transient_suppression.enabled !=
|
2022-11-30 16:59:05 +01:00
|
|
|
adjusted_config.transient_suppression.enabled;
|
2020-01-02 15:15:36 +01:00
|
|
|
|
2020-01-03 14:27:14 +01:00
|
|
|
const bool pre_amplifier_config_changed =
|
2022-11-30 16:59:05 +01:00
|
|
|
config_.pre_amplifier.enabled != adjusted_config.pre_amplifier.enabled ||
|
2020-01-03 14:27:14 +01:00
|
|
|
config_.pre_amplifier.fixed_gain_factor !=
|
2022-11-30 16:59:05 +01:00
|
|
|
adjusted_config.pre_amplifier.fixed_gain_factor;
|
2020-01-03 14:27:14 +01:00
|
|
|
|
2021-03-15 16:31:04 +00:00
|
|
|
const bool gain_adjustment_config_changed =
|
2022-11-30 16:59:05 +01:00
|
|
|
config_.capture_level_adjustment !=
|
|
|
|
|
adjusted_config.capture_level_adjustment;
|
2021-03-15 16:31:04 +00:00
|
|
|
|
2022-11-30 16:59:05 +01:00
|
|
|
config_ = adjusted_config;
|
2018-08-17 16:26:14 +02:00
|
|
|
|
2019-03-06 04:16:46 +01:00
|
|
|
if (aec_config_changed) {
|
|
|
|
|
InitializeEchoController();
|
|
|
|
|
}
|
2018-09-17 11:05:17 +02:00
|
|
|
|
2019-10-16 11:46:11 +02:00
|
|
|
if (ns_config_changed) {
|
|
|
|
|
InitializeNoiseSuppressor();
|
|
|
|
|
}
|
2019-01-11 15:10:32 +01:00
|
|
|
|
2020-01-02 15:15:36 +01:00
|
|
|
if (ts_config_changed) {
|
|
|
|
|
InitializeTransientSuppressor();
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-03 14:27:14 +01:00
|
|
|
InitializeHighPassFilter(false);
|
2016-11-22 07:24:52 -08:00
|
|
|
|
2019-03-27 13:28:08 +01:00
|
|
|
if (agc1_config_changed) {
|
2020-01-13 14:43:13 +01:00
|
|
|
InitializeGainController1();
|
2019-03-27 13:28:08 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-05 15:59:06 +01:00
|
|
|
const bool config_ok = GainController2::Validate(config_.gain_controller2);
|
2017-05-22 06:57:06 -07:00
|
|
|
if (!config_ok) {
|
2020-10-14 12:49:54 +02:00
|
|
|
RTC_LOG(LS_ERROR)
|
|
|
|
|
<< "Invalid Gain Controller 2 config; using the default config.";
|
2017-05-22 06:57:06 -07:00
|
|
|
config_.gain_controller2 = AudioProcessing::Config::GainController2();
|
|
|
|
|
}
|
2020-01-03 14:27:14 +01:00
|
|
|
|
2023-01-16 20:19:48 +01:00
|
|
|
if (agc2_config_changed || ts_config_changed) {
|
|
|
|
|
// AGC2 also depends on TS because of the possible dependency on the APM VAD
|
|
|
|
|
// sub-module.
|
|
|
|
|
InitializeGainController2();
|
|
|
|
|
InitializeVoiceActivityDetector();
|
|
|
|
|
}
|
2020-01-03 14:27:14 +01:00
|
|
|
|
2021-03-15 16:31:04 +00:00
|
|
|
if (pre_amplifier_config_changed || gain_adjustment_config_changed) {
|
|
|
|
|
InitializeCaptureLevelsAdjuster();
|
2020-01-03 14:27:14 +01:00
|
|
|
}
|
2018-11-26 16:18:25 +01:00
|
|
|
|
2019-09-20 07:50:35 +02:00
|
|
|
// Reinitialization must happen after all submodule configuration to avoid
|
|
|
|
|
// additional reinitializations on the next capture / render processing call.
|
|
|
|
|
if (pipeline_config_changed) {
|
|
|
|
|
InitializeLocked(formats_.api_format);
|
|
|
|
|
}
|
2016-09-12 16:47:25 -07:00
|
|
|
}
|
|
|
|
|
|
2020-04-27 08:39:33 +02:00
|
|
|
void AudioProcessingImpl::OverrideSubmoduleCreationForTesting(
|
|
|
|
|
const ApmSubmoduleCreationOverrides& overrides) {
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock(&mutex_capture_);
|
2020-04-27 08:39:33 +02:00
|
|
|
submodule_creation_overrides_ = overrides;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-22 21:00:04 +00:00
|
|
|
int AudioProcessingImpl::proc_sample_rate_hz() const {
|
2015-11-28 12:35:15 -08:00
|
|
|
// Used as callback from submodules, hence locking is not allowed.
|
2016-09-16 15:02:15 -07:00
|
|
|
return capture_nonlocked_.capture_processing_format.sample_rate_hz();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2019-10-09 13:02:14 +02:00
|
|
|
int AudioProcessingImpl::proc_fullband_sample_rate_hz() const {
|
|
|
|
|
return capture_.capture_fullband_audio
|
|
|
|
|
? capture_.capture_fullband_audio->num_frames() * 100
|
|
|
|
|
: capture_nonlocked_.capture_processing_format.sample_rate_hz();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-22 21:00:04 +00:00
|
|
|
int AudioProcessingImpl::proc_split_sample_rate_hz() const {
|
2015-11-28 12:35:15 -08:00
|
|
|
// Used as callback from submodules, hence locking is not allowed.
|
|
|
|
|
return capture_nonlocked_.split_rate;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t AudioProcessingImpl::num_reverse_channels() const {
|
2015-11-28 12:35:15 -08:00
|
|
|
// Used as callback from submodules, hence locking is not allowed.
|
2016-09-16 15:02:15 -07:00
|
|
|
return formats_.render_processing_format.num_channels();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t AudioProcessingImpl::num_input_channels() const {
|
2015-11-28 12:35:15 -08:00
|
|
|
// Used as callback from submodules, hence locking is not allowed.
|
|
|
|
|
return formats_.api_format.input_stream().num_channels();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t AudioProcessingImpl::num_proc_channels() const {
|
2016-01-11 20:32:29 -08:00
|
|
|
// Used as callback from submodules, hence locking is not allowed.
|
2019-11-27 09:34:22 +01:00
|
|
|
const bool multi_channel_capture = config_.pipeline.multi_channel_capture &&
|
|
|
|
|
constants_.multi_channel_capture_support;
|
|
|
|
|
if (capture_nonlocked_.echo_controller_enabled && !multi_channel_capture) {
|
2019-09-20 07:50:35 +02:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return num_output_channels();
|
2016-01-11 20:32:29 -08:00
|
|
|
}
|
|
|
|
|
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t AudioProcessingImpl::num_output_channels() const {
|
2015-11-28 12:35:15 -08:00
|
|
|
// Used as callback from submodules, hence locking is not allowed.
|
|
|
|
|
return formats_.api_format.output_stream().num_channels();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-12 22:28:31 +00:00
|
|
|
void AudioProcessingImpl::set_output_will_be_muted(bool muted) {
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock(&mutex_capture_);
|
2021-02-09 08:47:51 +01:00
|
|
|
HandleCaptureOutputUsedSetting(!muted);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::HandleCaptureOutputUsedSetting(
|
|
|
|
|
bool capture_output_used) {
|
2021-03-12 23:08:09 +00:00
|
|
|
capture_.capture_output_used =
|
|
|
|
|
capture_output_used || !constants_.minimize_processing_for_unused_output;
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.agc_manager.get()) {
|
2021-02-09 08:47:51 +01:00
|
|
|
submodules_.agc_manager->HandleCaptureOutputUsedChange(
|
|
|
|
|
capture_.capture_output_used);
|
2014-12-15 09:41:24 +00:00
|
|
|
}
|
2021-03-03 10:52:44 +00:00
|
|
|
if (submodules_.echo_controller) {
|
|
|
|
|
submodules_.echo_controller->SetCaptureOutputUsage(
|
|
|
|
|
capture_.capture_output_used);
|
2021-03-12 14:12:44 +00:00
|
|
|
}
|
|
|
|
|
if (submodules_.noise_suppressor) {
|
|
|
|
|
submodules_.noise_suppressor->SetCaptureOutputUsage(
|
|
|
|
|
capture_.capture_output_used);
|
2021-03-03 10:52:44 +00:00
|
|
|
}
|
2022-11-30 15:16:21 +01:00
|
|
|
if (submodules_.gain_controller2) {
|
|
|
|
|
submodules_.gain_controller2->SetCaptureOutputUsed(
|
|
|
|
|
capture_.capture_output_used);
|
|
|
|
|
}
|
2014-02-12 22:28:31 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-16 12:10:09 +02:00
|
|
|
void AudioProcessingImpl::SetRuntimeSetting(RuntimeSetting setting) {
|
2021-02-09 08:47:51 +01:00
|
|
|
PostRuntimeSetting(setting);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AudioProcessingImpl::PostRuntimeSetting(RuntimeSetting setting) {
|
2018-05-15 10:52:28 +02:00
|
|
|
switch (setting.type()) {
|
|
|
|
|
case RuntimeSetting::Type::kCustomRenderProcessingRuntimeSetting:
|
2019-11-07 13:22:00 +01:00
|
|
|
case RuntimeSetting::Type::kPlayoutAudioDeviceChange:
|
2021-02-09 08:47:51 +01:00
|
|
|
return render_runtime_settings_enqueuer_.Enqueue(setting);
|
2018-05-15 10:52:28 +02:00
|
|
|
case RuntimeSetting::Type::kCapturePreGain:
|
2021-03-15 16:31:04 +00:00
|
|
|
case RuntimeSetting::Type::kCapturePostGain:
|
2019-03-27 13:28:08 +01:00
|
|
|
case RuntimeSetting::Type::kCaptureCompressionGain:
|
2019-04-26 11:33:37 +02:00
|
|
|
case RuntimeSetting::Type::kCaptureFixedPostGain:
|
2020-08-12 08:46:47 +02:00
|
|
|
case RuntimeSetting::Type::kCaptureOutputUsed:
|
2021-02-09 08:47:51 +01:00
|
|
|
return capture_runtime_settings_enqueuer_.Enqueue(setting);
|
|
|
|
|
case RuntimeSetting::Type::kPlayoutVolumeChange: {
|
|
|
|
|
bool enqueueing_successful;
|
|
|
|
|
enqueueing_successful =
|
|
|
|
|
capture_runtime_settings_enqueuer_.Enqueue(setting);
|
|
|
|
|
enqueueing_successful =
|
|
|
|
|
render_runtime_settings_enqueuer_.Enqueue(setting) &&
|
|
|
|
|
enqueueing_successful;
|
|
|
|
|
return enqueueing_successful;
|
|
|
|
|
}
|
2019-11-07 13:22:00 +01:00
|
|
|
case RuntimeSetting::Type::kNotSpecified:
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
2021-02-09 08:47:51 +01:00
|
|
|
return true;
|
2018-05-15 10:52:28 +02:00
|
|
|
}
|
|
|
|
|
// The language allows the enum to have a non-enumerator
|
|
|
|
|
// value. Check that this doesn't happen.
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
2021-02-09 08:47:51 +01:00
|
|
|
return true;
|
2018-04-16 12:10:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AudioProcessingImpl::RuntimeSettingEnqueuer::RuntimeSettingEnqueuer(
|
|
|
|
|
SwapQueue<RuntimeSetting>* runtime_settings)
|
2018-04-20 13:16:55 +02:00
|
|
|
: runtime_settings_(*runtime_settings) {
|
|
|
|
|
RTC_DCHECK(runtime_settings);
|
2018-04-16 12:10:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AudioProcessingImpl::RuntimeSettingEnqueuer::~RuntimeSettingEnqueuer() =
|
|
|
|
|
default;
|
|
|
|
|
|
2021-02-09 08:47:51 +01:00
|
|
|
bool AudioProcessingImpl::RuntimeSettingEnqueuer::Enqueue(
|
2018-04-16 12:10:09 +02:00
|
|
|
RuntimeSetting setting) {
|
2021-03-03 10:52:44 +00:00
|
|
|
const bool successful_insert = runtime_settings_.Insert(&setting);
|
|
|
|
|
|
|
|
|
|
if (!successful_insert) {
|
2018-04-16 12:10:09 +02:00
|
|
|
RTC_LOG(LS_ERROR) << "Cannot enqueue a new runtime setting.";
|
2020-10-23 12:40:30 +02:00
|
|
|
}
|
2021-03-03 10:52:44 +00:00
|
|
|
return successful_insert;
|
2018-04-16 12:10:09 +02:00
|
|
|
}
|
2014-02-12 22:28:31 +00:00
|
|
|
|
2022-11-17 11:26:58 +01:00
|
|
|
void AudioProcessingImpl::MaybeInitializeCapture(
|
2020-01-03 14:54:20 +01:00
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config) {
|
2015-11-28 12:35:15 -08:00
|
|
|
ProcessingConfig processing_config;
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
bool reinitialization_required = false;
|
2015-11-28 12:35:15 -08:00
|
|
|
{
|
2020-01-03 14:54:20 +01:00
|
|
|
// Acquire the capture lock in order to access api_format. The lock is
|
|
|
|
|
// released immediately, as we may need to acquire the render lock as part
|
|
|
|
|
// of the conditional reinitialization.
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2015-11-28 12:35:15 -08:00
|
|
|
processing_config = formats_.api_format;
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
reinitialization_required = UpdateActiveSubmoduleStates();
|
2015-11-28 12:35:15 -08:00
|
|
|
}
|
2015-11-16 16:27:42 -08:00
|
|
|
|
2019-05-23 14:28:00 +02:00
|
|
|
if (processing_config.input_stream() != input_config) {
|
|
|
|
|
reinitialization_required = true;
|
|
|
|
|
}
|
2015-07-23 11:41:39 -07:00
|
|
|
|
2019-05-23 14:28:00 +02:00
|
|
|
if (processing_config.output_stream() != output_config) {
|
|
|
|
|
reinitialization_required = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reinitialization_required) {
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_render(&mutex_render_);
|
|
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2022-09-29 09:43:58 +02:00
|
|
|
// Reread the API format since the render format may have changed.
|
|
|
|
|
processing_config = formats_.api_format;
|
|
|
|
|
processing_config.input_stream() = input_config;
|
|
|
|
|
processing_config.output_stream() = output_config;
|
2022-11-17 11:26:58 +01:00
|
|
|
InitializeLocked(processing_config);
|
2015-11-28 12:35:15 -08:00
|
|
|
}
|
2020-01-03 14:54:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AudioProcessingImpl::ProcessStream(const float* const* src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
|
|
|
|
float* const* dest) {
|
|
|
|
|
TRACE_EVENT0("webrtc", "AudioProcessing::ProcessStream_StreamConfig");
|
2022-12-20 16:22:44 +01:00
|
|
|
DenormalDisabler denormal_disabler;
|
2022-11-17 11:26:58 +01:00
|
|
|
RETURN_ON_ERR(
|
|
|
|
|
HandleUnsupportedAudioFormats(src, input_config, output_config, dest));
|
|
|
|
|
MaybeInitializeCapture(input_config, output_config);
|
2019-05-23 14:28:00 +02:00
|
|
|
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2014-03-04 20:58:13 +00:00
|
|
|
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
if (aec_dump_) {
|
|
|
|
|
RecordUnprocessedCaptureStream(src);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
capture_.capture_audio->CopyFrom(src, formats_.api_format.input_stream());
|
2019-10-09 13:34:36 +02:00
|
|
|
if (capture_.capture_fullband_audio) {
|
|
|
|
|
capture_.capture_fullband_audio->CopyFrom(
|
|
|
|
|
src, formats_.api_format.input_stream());
|
|
|
|
|
}
|
2016-09-16 15:02:15 -07:00
|
|
|
RETURN_ON_ERR(ProcessCaptureStreamLocked());
|
2019-10-09 13:02:14 +02:00
|
|
|
if (capture_.capture_fullband_audio) {
|
|
|
|
|
capture_.capture_fullband_audio->CopyTo(formats_.api_format.output_stream(),
|
|
|
|
|
dest);
|
|
|
|
|
} else {
|
|
|
|
|
capture_.capture_audio->CopyTo(formats_.api_format.output_stream(), dest);
|
|
|
|
|
}
|
2014-03-04 20:58:13 +00:00
|
|
|
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
if (aec_dump_) {
|
|
|
|
|
RecordProcessedCaptureStream(dest);
|
|
|
|
|
}
|
2014-03-04 20:58:13 +00:00
|
|
|
return kNoError;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-15 10:52:28 +02:00
|
|
|
void AudioProcessingImpl::HandleCaptureRuntimeSettings() {
|
2018-04-16 12:10:09 +02:00
|
|
|
RuntimeSetting setting;
|
2021-03-03 10:52:44 +00:00
|
|
|
int num_settings_processed = 0;
|
2018-05-15 10:52:28 +02:00
|
|
|
while (capture_runtime_settings_.Remove(&setting)) {
|
2018-09-10 10:18:07 +02:00
|
|
|
if (aec_dump_) {
|
|
|
|
|
aec_dump_->WriteRuntimeSetting(setting);
|
|
|
|
|
}
|
2018-04-16 12:10:09 +02:00
|
|
|
switch (setting.type()) {
|
|
|
|
|
case RuntimeSetting::Type::kCapturePreGain:
|
2021-03-15 16:31:04 +00:00
|
|
|
if (config_.pre_amplifier.enabled ||
|
|
|
|
|
config_.capture_level_adjustment.enabled) {
|
|
|
|
|
float value;
|
|
|
|
|
setting.GetFloat(&value);
|
|
|
|
|
// If the pre-amplifier is used, apply the new gain to the
|
|
|
|
|
// pre-amplifier regardless if the capture level adjustment is
|
|
|
|
|
// activated. This approach allows both functionalities to coexist
|
|
|
|
|
// until they have been properly merged.
|
|
|
|
|
if (config_.pre_amplifier.enabled) {
|
|
|
|
|
config_.pre_amplifier.fixed_gain_factor = value;
|
|
|
|
|
} else {
|
|
|
|
|
config_.capture_level_adjustment.pre_gain_factor = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use both the pre-amplifier and the capture level adjustment gains
|
|
|
|
|
// as pre-gains.
|
|
|
|
|
float gain = 1.f;
|
|
|
|
|
if (config_.pre_amplifier.enabled) {
|
|
|
|
|
gain *= config_.pre_amplifier.fixed_gain_factor;
|
|
|
|
|
}
|
|
|
|
|
if (config_.capture_level_adjustment.enabled) {
|
|
|
|
|
gain *= config_.capture_level_adjustment.pre_gain_factor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
submodules_.capture_levels_adjuster->SetPreGain(gain);
|
|
|
|
|
}
|
|
|
|
|
// TODO(bugs.chromium.org/9138): Log setting handling by Aec Dump.
|
|
|
|
|
break;
|
|
|
|
|
case RuntimeSetting::Type::kCapturePostGain:
|
|
|
|
|
if (config_.capture_level_adjustment.enabled) {
|
2018-04-16 16:31:22 +02:00
|
|
|
float value;
|
|
|
|
|
setting.GetFloat(&value);
|
2021-03-15 16:31:04 +00:00
|
|
|
config_.capture_level_adjustment.post_gain_factor = value;
|
|
|
|
|
submodules_.capture_levels_adjuster->SetPostGain(
|
|
|
|
|
config_.capture_level_adjustment.post_gain_factor);
|
2018-04-16 16:31:22 +02:00
|
|
|
}
|
|
|
|
|
// TODO(bugs.chromium.org/9138): Log setting handling by Aec Dump.
|
2018-04-16 12:10:09 +02:00
|
|
|
break;
|
2019-03-27 13:28:08 +01:00
|
|
|
case RuntimeSetting::Type::kCaptureCompressionGain: {
|
2022-11-30 15:16:21 +01:00
|
|
|
if (!submodules_.agc_manager &&
|
|
|
|
|
!(submodules_.gain_controller2 &&
|
|
|
|
|
config_.gain_controller2.input_volume_controller.enabled)) {
|
2019-11-18 08:52:22 +01:00
|
|
|
float value;
|
|
|
|
|
setting.GetFloat(&value);
|
|
|
|
|
int int_value = static_cast<int>(value + .5f);
|
|
|
|
|
config_.gain_controller1.compression_gain_db = int_value;
|
2020-01-13 14:43:13 +01:00
|
|
|
if (submodules_.gain_control) {
|
|
|
|
|
int error =
|
|
|
|
|
submodules_.gain_control->set_compression_gain_db(int_value);
|
|
|
|
|
RTC_DCHECK_EQ(kNoError, error);
|
|
|
|
|
}
|
2019-11-18 08:52:22 +01:00
|
|
|
}
|
2019-03-27 13:28:08 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2019-04-26 11:33:37 +02:00
|
|
|
case RuntimeSetting::Type::kCaptureFixedPostGain: {
|
2020-01-03 10:36:34 +01:00
|
|
|
if (submodules_.gain_controller2) {
|
2019-04-26 11:33:37 +02:00
|
|
|
float value;
|
|
|
|
|
setting.GetFloat(&value);
|
|
|
|
|
config_.gain_controller2.fixed_digital.gain_db = value;
|
2021-10-14 12:14:21 +02:00
|
|
|
submodules_.gain_controller2->SetFixedGainDb(value);
|
2019-04-26 11:33:37 +02:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-05-10 15:50:02 +02:00
|
|
|
case RuntimeSetting::Type::kPlayoutVolumeChange: {
|
|
|
|
|
int value;
|
|
|
|
|
setting.GetInt(&value);
|
|
|
|
|
capture_.playout_volume = value;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-07 13:22:00 +01:00
|
|
|
case RuntimeSetting::Type::kPlayoutAudioDeviceChange:
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
2019-11-07 13:22:00 +01:00
|
|
|
break;
|
2018-05-15 10:52:28 +02:00
|
|
|
case RuntimeSetting::Type::kCustomRenderProcessingRuntimeSetting:
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
2018-05-15 10:52:28 +02:00
|
|
|
break;
|
|
|
|
|
case RuntimeSetting::Type::kNotSpecified:
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
2018-05-15 10:52:28 +02:00
|
|
|
break;
|
2020-08-12 08:46:47 +02:00
|
|
|
case RuntimeSetting::Type::kCaptureOutputUsed:
|
2021-02-09 08:47:51 +01:00
|
|
|
bool value;
|
|
|
|
|
setting.GetBool(&value);
|
|
|
|
|
HandleCaptureOutputUsedSetting(value);
|
2020-08-12 08:46:47 +02:00
|
|
|
break;
|
2018-05-15 10:52:28 +02:00
|
|
|
}
|
2021-03-03 10:52:44 +00:00
|
|
|
++num_settings_processed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num_settings_processed >= RuntimeSettingQueueSize()) {
|
|
|
|
|
// Handle overrun of the runtime settings queue, which likely will has
|
|
|
|
|
// caused settings to be discarded.
|
|
|
|
|
HandleOverrunInCaptureRuntimeSettingsQueue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::HandleOverrunInCaptureRuntimeSettingsQueue() {
|
|
|
|
|
// Fall back to a safe state for the case when a setting for capture output
|
|
|
|
|
// usage setting has been missed.
|
2021-03-12 23:08:09 +00:00
|
|
|
HandleCaptureOutputUsedSetting(/*capture_output_used=*/true);
|
2018-05-15 10:52:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::HandleRenderRuntimeSettings() {
|
|
|
|
|
RuntimeSetting setting;
|
|
|
|
|
while (render_runtime_settings_.Remove(&setting)) {
|
2018-09-10 10:18:07 +02:00
|
|
|
if (aec_dump_) {
|
|
|
|
|
aec_dump_->WriteRuntimeSetting(setting);
|
|
|
|
|
}
|
2018-05-15 10:52:28 +02:00
|
|
|
switch (setting.type()) {
|
2019-11-07 13:22:00 +01:00
|
|
|
case RuntimeSetting::Type::kPlayoutAudioDeviceChange: // fall-through
|
2019-11-11 13:32:20 +01:00
|
|
|
case RuntimeSetting::Type::kPlayoutVolumeChange: // fall-through
|
2018-05-15 10:52:28 +02:00
|
|
|
case RuntimeSetting::Type::kCustomRenderProcessingRuntimeSetting:
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.render_pre_processor) {
|
|
|
|
|
submodules_.render_pre_processor->SetRuntimeSetting(setting);
|
2018-05-15 10:52:28 +02:00
|
|
|
}
|
|
|
|
|
break;
|
2019-03-27 13:28:08 +01:00
|
|
|
case RuntimeSetting::Type::kCapturePreGain: // fall-through
|
2021-03-15 16:31:04 +00:00
|
|
|
case RuntimeSetting::Type::kCapturePostGain: // fall-through
|
2019-03-27 13:28:08 +01:00
|
|
|
case RuntimeSetting::Type::kCaptureCompressionGain: // fall-through
|
2019-04-26 11:33:37 +02:00
|
|
|
case RuntimeSetting::Type::kCaptureFixedPostGain: // fall-through
|
2020-08-12 08:46:47 +02:00
|
|
|
case RuntimeSetting::Type::kCaptureOutputUsed: // fall-through
|
2018-04-20 13:16:55 +02:00
|
|
|
case RuntimeSetting::Type::kNotSpecified:
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
2018-04-16 12:10:09 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 07:19:21 -07:00
|
|
|
void AudioProcessingImpl::QueueBandedRenderAudio(AudioBuffer* audio) {
|
2016-11-28 15:21:39 -08:00
|
|
|
RTC_DCHECK_GE(160, audio->num_frames_per_band());
|
2016-10-22 05:04:30 -07:00
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.echo_control_mobile) {
|
2019-04-29 12:14:50 +02:00
|
|
|
EchoControlMobileImpl::PackRenderAudioBuffer(audio, num_output_channels(),
|
|
|
|
|
num_reverse_channels(),
|
|
|
|
|
&aecm_render_queue_buffer_);
|
|
|
|
|
RTC_DCHECK(aecm_render_signal_queue_);
|
|
|
|
|
// Insert the samples into the queue.
|
|
|
|
|
if (!aecm_render_signal_queue_->Insert(&aecm_render_queue_buffer_)) {
|
|
|
|
|
// The data queue is full and needs to be emptied.
|
|
|
|
|
EmptyQueuedRenderAudio();
|
2016-10-25 04:45:24 -07:00
|
|
|
|
2019-04-29 12:14:50 +02:00
|
|
|
// Retry the insert (should always work).
|
|
|
|
|
bool result =
|
|
|
|
|
aecm_render_signal_queue_->Insert(&aecm_render_queue_buffer_);
|
|
|
|
|
RTC_DCHECK(result);
|
|
|
|
|
}
|
2016-10-22 05:04:30 -07:00
|
|
|
}
|
2016-10-25 05:42:20 -07:00
|
|
|
|
2020-01-13 14:43:13 +01:00
|
|
|
if (!submodules_.agc_manager && submodules_.gain_control) {
|
2019-11-22 18:22:04 +01:00
|
|
|
GainControlImpl::PackRenderAudioBuffer(*audio, &agc_render_queue_buffer_);
|
2016-10-25 05:42:20 -07:00
|
|
|
// Insert the samples into the queue.
|
|
|
|
|
if (!agc_render_signal_queue_->Insert(&agc_render_queue_buffer_)) {
|
|
|
|
|
// The data queue is full and needs to be emptied.
|
|
|
|
|
EmptyQueuedRenderAudio();
|
|
|
|
|
|
|
|
|
|
// Retry the insert (should always work).
|
|
|
|
|
bool result = agc_render_signal_queue_->Insert(&agc_render_queue_buffer_);
|
|
|
|
|
RTC_DCHECK(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-15 07:19:21 -07:00
|
|
|
}
|
2016-10-28 05:39:16 -07:00
|
|
|
|
2017-05-15 07:19:21 -07:00
|
|
|
void AudioProcessingImpl::QueueNonbandedRenderAudio(AudioBuffer* audio) {
|
2021-12-06 15:40:04 +01:00
|
|
|
if (submodules_.echo_detector) {
|
|
|
|
|
PackRenderAudioBufferForEchoDetector(*audio, red_render_queue_buffer_);
|
|
|
|
|
RTC_DCHECK(red_render_signal_queue_);
|
|
|
|
|
// Insert the samples into the queue.
|
|
|
|
|
if (!red_render_signal_queue_->Insert(&red_render_queue_buffer_)) {
|
|
|
|
|
// The data queue is full and needs to be emptied.
|
|
|
|
|
EmptyQueuedRenderAudio();
|
2016-10-28 05:39:16 -07:00
|
|
|
|
2021-12-06 15:40:04 +01:00
|
|
|
// Retry the insert (should always work).
|
|
|
|
|
bool result = red_render_signal_queue_->Insert(&red_render_queue_buffer_);
|
|
|
|
|
RTC_DCHECK(result);
|
|
|
|
|
}
|
2016-10-28 05:39:16 -07:00
|
|
|
}
|
2016-10-22 05:04:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::AllocateRenderQueue() {
|
2016-10-25 05:42:20 -07:00
|
|
|
const size_t new_agc_render_queue_element_max_size =
|
2017-05-15 07:19:21 -07:00
|
|
|
std::max(static_cast<size_t>(1), kMaxAllowedValuesOfSamplesPerBand);
|
2016-10-25 05:42:20 -07:00
|
|
|
|
2016-10-28 05:39:16 -07:00
|
|
|
const size_t new_red_render_queue_element_max_size =
|
|
|
|
|
std::max(static_cast<size_t>(1), kMaxAllowedValuesOfSamplesPerFrame);
|
|
|
|
|
|
2016-10-25 04:45:24 -07:00
|
|
|
// Reallocate the queues if the queue item sizes are too small to fit the
|
|
|
|
|
// data to put in the queues.
|
|
|
|
|
|
2016-10-25 05:42:20 -07:00
|
|
|
if (agc_render_queue_element_max_size_ <
|
|
|
|
|
new_agc_render_queue_element_max_size) {
|
|
|
|
|
agc_render_queue_element_max_size_ = new_agc_render_queue_element_max_size;
|
2016-10-25 04:45:24 -07:00
|
|
|
|
|
|
|
|
std::vector<int16_t> template_queue_element(
|
2016-10-25 05:42:20 -07:00
|
|
|
agc_render_queue_element_max_size_);
|
2016-10-25 04:45:24 -07:00
|
|
|
|
2016-10-25 05:42:20 -07:00
|
|
|
agc_render_signal_queue_.reset(
|
2016-10-25 04:45:24 -07:00
|
|
|
new SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>(
|
|
|
|
|
kMaxNumFramesToBuffer, template_queue_element,
|
|
|
|
|
RenderQueueItemVerifier<int16_t>(
|
2016-10-25 05:42:20 -07:00
|
|
|
agc_render_queue_element_max_size_)));
|
2016-10-25 04:45:24 -07:00
|
|
|
|
2016-10-25 05:42:20 -07:00
|
|
|
agc_render_queue_buffer_.resize(agc_render_queue_element_max_size_);
|
|
|
|
|
agc_capture_queue_buffer_.resize(agc_render_queue_element_max_size_);
|
2016-10-25 04:45:24 -07:00
|
|
|
} else {
|
2016-10-25 05:42:20 -07:00
|
|
|
agc_render_signal_queue_->Clear();
|
2016-10-22 05:04:30 -07:00
|
|
|
}
|
2016-10-28 05:39:16 -07:00
|
|
|
|
2021-12-06 15:40:04 +01:00
|
|
|
if (submodules_.echo_detector) {
|
|
|
|
|
if (red_render_queue_element_max_size_ <
|
|
|
|
|
new_red_render_queue_element_max_size) {
|
|
|
|
|
red_render_queue_element_max_size_ =
|
|
|
|
|
new_red_render_queue_element_max_size;
|
2016-10-28 05:39:16 -07:00
|
|
|
|
2021-12-06 15:40:04 +01:00
|
|
|
std::vector<float> template_queue_element(
|
|
|
|
|
red_render_queue_element_max_size_);
|
2016-10-28 05:39:16 -07:00
|
|
|
|
2021-12-06 15:40:04 +01:00
|
|
|
red_render_signal_queue_.reset(
|
|
|
|
|
new SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>(
|
|
|
|
|
kMaxNumFramesToBuffer, template_queue_element,
|
|
|
|
|
RenderQueueItemVerifier<float>(
|
|
|
|
|
red_render_queue_element_max_size_)));
|
2016-10-28 05:39:16 -07:00
|
|
|
|
2021-12-06 15:40:04 +01:00
|
|
|
red_render_queue_buffer_.resize(red_render_queue_element_max_size_);
|
|
|
|
|
red_capture_queue_buffer_.resize(red_render_queue_element_max_size_);
|
|
|
|
|
} else {
|
|
|
|
|
red_render_signal_queue_->Clear();
|
|
|
|
|
}
|
2016-10-28 05:39:16 -07:00
|
|
|
}
|
2016-10-22 05:04:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::EmptyQueuedRenderAudio() {
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2020-05-14 14:31:18 +02:00
|
|
|
EmptyQueuedRenderAudioLocked();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::EmptyQueuedRenderAudioLocked() {
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.echo_control_mobile) {
|
2019-04-29 12:14:50 +02:00
|
|
|
RTC_DCHECK(aecm_render_signal_queue_);
|
|
|
|
|
while (aecm_render_signal_queue_->Remove(&aecm_capture_queue_buffer_)) {
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_control_mobile->ProcessRenderAudio(
|
2019-04-29 12:14:50 +02:00
|
|
|
aecm_capture_queue_buffer_);
|
|
|
|
|
}
|
2016-10-25 05:42:20 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-13 14:43:13 +01:00
|
|
|
if (submodules_.gain_control) {
|
|
|
|
|
while (agc_render_signal_queue_->Remove(&agc_capture_queue_buffer_)) {
|
|
|
|
|
submodules_.gain_control->ProcessRenderAudio(agc_capture_queue_buffer_);
|
|
|
|
|
}
|
2016-10-22 05:04:30 -07:00
|
|
|
}
|
2016-10-28 05:39:16 -07:00
|
|
|
|
2021-12-06 15:40:04 +01:00
|
|
|
if (submodules_.echo_detector) {
|
|
|
|
|
while (red_render_signal_queue_->Remove(&red_capture_queue_buffer_)) {
|
|
|
|
|
submodules_.echo_detector->AnalyzeRenderAudio(red_capture_queue_buffer_);
|
|
|
|
|
}
|
2016-10-28 05:39:16 -07:00
|
|
|
}
|
2016-10-22 05:04:30 -07:00
|
|
|
}
|
|
|
|
|
|
2020-03-16 12:06:02 +01:00
|
|
|
int AudioProcessingImpl::ProcessStream(const int16_t* const src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
2020-03-19 14:55:58 +01:00
|
|
|
int16_t* const dest) {
|
2020-03-17 13:23:58 +01:00
|
|
|
TRACE_EVENT0("webrtc", "AudioProcessing::ProcessStream_AudioFrame");
|
2022-11-17 11:26:58 +01:00
|
|
|
|
|
|
|
|
RETURN_ON_ERR(
|
|
|
|
|
HandleUnsupportedAudioFormats(src, input_config, output_config, dest));
|
|
|
|
|
MaybeInitializeCapture(input_config, output_config);
|
2019-05-23 14:28:00 +02:00
|
|
|
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2022-12-20 16:22:44 +01:00
|
|
|
DenormalDisabler denormal_disabler;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
if (aec_dump_) {
|
2020-03-16 12:06:02 +01:00
|
|
|
RecordUnprocessedCaptureStream(src, input_config);
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
}
|
|
|
|
|
|
2020-03-16 12:06:02 +01:00
|
|
|
capture_.capture_audio->CopyFrom(src, input_config);
|
2019-10-11 13:14:44 +02:00
|
|
|
if (capture_.capture_fullband_audio) {
|
2020-03-16 12:06:02 +01:00
|
|
|
capture_.capture_fullband_audio->CopyFrom(src, input_config);
|
2019-10-11 13:14:44 +02:00
|
|
|
}
|
2016-09-16 15:02:15 -07:00
|
|
|
RETURN_ON_ERR(ProcessCaptureStreamLocked());
|
2019-10-09 13:34:36 +02:00
|
|
|
if (submodule_states_.CaptureMultiBandProcessingPresent() ||
|
2019-08-15 12:15:46 +02:00
|
|
|
submodule_states_.CaptureFullBandProcessingActive()) {
|
2019-10-09 13:02:14 +02:00
|
|
|
if (capture_.capture_fullband_audio) {
|
2020-03-16 12:06:02 +01:00
|
|
|
capture_.capture_fullband_audio->CopyTo(output_config, dest);
|
2019-10-09 13:02:14 +02:00
|
|
|
} else {
|
2020-03-16 12:06:02 +01:00
|
|
|
capture_.capture_audio->CopyTo(output_config, dest);
|
2019-10-09 13:02:14 +02:00
|
|
|
}
|
2019-08-15 12:15:46 +02:00
|
|
|
}
|
2020-03-16 12:06:02 +01:00
|
|
|
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
if (aec_dump_) {
|
2020-03-16 12:06:02 +01:00
|
|
|
RecordProcessedCaptureStream(dest, output_config);
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
}
|
2014-03-04 20:58:13 +00:00
|
|
|
return kNoError;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-16 15:02:15 -07:00
|
|
|
int AudioProcessingImpl::ProcessCaptureStreamLocked() {
|
2020-05-14 14:31:18 +02:00
|
|
|
EmptyQueuedRenderAudioLocked();
|
2018-05-15 10:52:28 +02:00
|
|
|
HandleCaptureRuntimeSettings();
|
2022-12-20 16:22:44 +01:00
|
|
|
DenormalDisabler denormal_disabler;
|
2018-04-16 12:10:09 +02:00
|
|
|
|
2016-03-15 09:34:24 -07:00
|
|
|
// Ensure that not both the AEC and AECM are active at the same time.
|
2018-07-23 14:48:07 +00:00
|
|
|
// TODO(peah): Simplify once the public API Enable functions for these
|
|
|
|
|
// are moved to APM.
|
2019-12-23 10:22:08 +01:00
|
|
|
RTC_DCHECK_LE(
|
|
|
|
|
!!submodules_.echo_controller + !!submodules_.echo_control_mobile, 1);
|
2016-03-15 09:34:24 -07:00
|
|
|
|
2022-09-07 17:14:26 +02:00
|
|
|
data_dumper_->DumpRaw(
|
|
|
|
|
"applied_input_volume",
|
|
|
|
|
capture_.applied_input_volume.value_or(kUnspecifiedDataDumpInputVolume));
|
|
|
|
|
|
2016-09-16 15:02:15 -07:00
|
|
|
AudioBuffer* capture_buffer = capture_.capture_audio.get(); // For brevity.
|
2019-12-20 00:42:22 +01:00
|
|
|
AudioBuffer* linear_aec_buffer = capture_.linear_aec_output.get();
|
2015-08-14 10:35:55 -07:00
|
|
|
|
2019-12-10 13:04:15 +01:00
|
|
|
if (submodules_.high_pass_filter &&
|
|
|
|
|
config_.high_pass_filter.apply_in_full_band &&
|
|
|
|
|
!constants_.enforce_split_band_hpf) {
|
|
|
|
|
submodules_.high_pass_filter->Process(capture_buffer,
|
|
|
|
|
/*use_split_band_data=*/false);
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 16:31:04 +00:00
|
|
|
if (submodules_.capture_levels_adjuster) {
|
|
|
|
|
if (config_.capture_level_adjustment.analog_mic_gain_emulation.enabled) {
|
2022-09-07 15:15:52 +02:00
|
|
|
// When the input volume is emulated, retrieve the volume applied to the
|
|
|
|
|
// input audio and notify that to APM so that the volume is passed to the
|
|
|
|
|
// active AGC.
|
|
|
|
|
set_stream_analog_level_locked(
|
|
|
|
|
submodules_.capture_levels_adjuster->GetAnalogMicGainLevel());
|
2021-03-15 16:31:04 +00:00
|
|
|
}
|
|
|
|
|
submodules_.capture_levels_adjuster->ApplyPreLevelAdjustment(
|
|
|
|
|
*capture_buffer);
|
2018-04-16 16:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
2019-08-20 09:19:21 +02:00
|
|
|
capture_input_rms_.Analyze(rtc::ArrayView<const float>(
|
2019-08-22 11:51:13 +02:00
|
|
|
capture_buffer->channels_const()[0],
|
2016-11-29 08:09:09 -08:00
|
|
|
capture_nonlocked_.capture_processing_format.num_frames()));
|
2016-12-20 13:45:58 -08:00
|
|
|
const bool log_rms = ++capture_rms_interval_counter_ >= 1000;
|
|
|
|
|
if (log_rms) {
|
|
|
|
|
capture_rms_interval_counter_ = 0;
|
|
|
|
|
RmsLevel::Levels levels = capture_input_rms_.AverageAndPeak();
|
2016-12-06 04:28:04 -08:00
|
|
|
RTC_HISTOGRAM_COUNTS_LINEAR("WebRTC.Audio.ApmCaptureInputLevelAverageRms",
|
|
|
|
|
levels.average, 1, RmsLevel::kMinLevelDb, 64);
|
|
|
|
|
RTC_HISTOGRAM_COUNTS_LINEAR("WebRTC.Audio.ApmCaptureInputLevelPeakRms",
|
|
|
|
|
levels.peak, 1, RmsLevel::kMinLevelDb, 64);
|
2016-11-29 08:09:09 -08:00
|
|
|
}
|
|
|
|
|
|
2022-09-07 17:14:26 +02:00
|
|
|
if (capture_.applied_input_volume.has_value()) {
|
2022-10-26 13:30:25 +00:00
|
|
|
applied_input_volume_stats_reporter_.UpdateStatistics(
|
2022-09-07 17:14:26 +02:00
|
|
|
*capture_.applied_input_volume);
|
|
|
|
|
}
|
2021-10-06 17:32:17 +02:00
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.echo_controller) {
|
2022-09-07 17:14:26 +02:00
|
|
|
// Determine if the echo path gain has changed by checking all the gains
|
|
|
|
|
// applied before AEC.
|
|
|
|
|
capture_.echo_path_gain_change = capture_.applied_input_volume_changed;
|
2018-07-16 17:08:41 +02:00
|
|
|
|
2021-03-15 16:31:04 +00:00
|
|
|
// Detect and flag any change in the capture level adjustment pre-gain.
|
|
|
|
|
if (submodules_.capture_levels_adjuster) {
|
|
|
|
|
float pre_adjustment_gain =
|
|
|
|
|
submodules_.capture_levels_adjuster->GetPreAdjustmentGain();
|
2018-10-02 17:00:59 +02:00
|
|
|
capture_.echo_path_gain_change =
|
|
|
|
|
capture_.echo_path_gain_change ||
|
2021-03-15 16:31:04 +00:00
|
|
|
(capture_.prev_pre_adjustment_gain != pre_adjustment_gain &&
|
2022-09-07 17:14:26 +02:00
|
|
|
capture_.prev_pre_adjustment_gain >= 0.0f);
|
2021-03-15 16:31:04 +00:00
|
|
|
capture_.prev_pre_adjustment_gain = pre_adjustment_gain;
|
2018-10-02 17:00:59 +02:00
|
|
|
}
|
2019-05-10 15:50:02 +02:00
|
|
|
|
|
|
|
|
// Detect volume change.
|
|
|
|
|
capture_.echo_path_gain_change =
|
|
|
|
|
capture_.echo_path_gain_change ||
|
|
|
|
|
(capture_.prev_playout_volume != capture_.playout_volume &&
|
|
|
|
|
capture_.prev_playout_volume >= 0);
|
|
|
|
|
capture_.prev_playout_volume = capture_.playout_volume;
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_controller->AnalyzeCapture(capture_buffer);
|
2016-12-14 01:16:23 -08:00
|
|
|
}
|
|
|
|
|
|
2020-01-13 14:43:13 +01:00
|
|
|
if (submodules_.agc_manager) {
|
2022-09-06 17:36:26 +02:00
|
|
|
submodules_.agc_manager->AnalyzePreProcess(*capture_buffer);
|
2014-12-15 09:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-30 15:16:21 +01:00
|
|
|
if (submodules_.gain_controller2 &&
|
|
|
|
|
config_.gain_controller2.input_volume_controller.enabled) {
|
|
|
|
|
// Expect the volume to be available if the input controller is enabled.
|
|
|
|
|
RTC_DCHECK(capture_.applied_input_volume.has_value());
|
|
|
|
|
if (capture_.applied_input_volume.has_value()) {
|
|
|
|
|
submodules_.gain_controller2->Analyze(*capture_.applied_input_volume,
|
|
|
|
|
*capture_buffer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
if (submodule_states_.CaptureMultiBandSubModulesActive() &&
|
|
|
|
|
SampleRateSupportsMultiBand(
|
2016-09-16 15:02:15 -07:00
|
|
|
capture_nonlocked_.capture_processing_format.sample_rate_hz())) {
|
|
|
|
|
capture_buffer->SplitIntoFrequencyBands();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-27 09:34:22 +01:00
|
|
|
const bool multi_channel_capture = config_.pipeline.multi_channel_capture &&
|
|
|
|
|
constants_.multi_channel_capture_support;
|
|
|
|
|
if (submodules_.echo_controller && !multi_channel_capture) {
|
2017-02-23 05:16:26 -08:00
|
|
|
// Force down-mixing of the number of channels after the detection of
|
|
|
|
|
// capture signal saturation.
|
|
|
|
|
// TODO(peah): Look into ensuring that this kind of tampering with the
|
|
|
|
|
// AudioBuffer functionality should not be needed.
|
|
|
|
|
capture_buffer->set_num_channels(1);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 13:04:15 +01:00
|
|
|
if (submodules_.high_pass_filter &&
|
|
|
|
|
(!config_.high_pass_filter.apply_in_full_band ||
|
|
|
|
|
constants_.enforce_split_band_hpf)) {
|
|
|
|
|
submodules_.high_pass_filter->Process(capture_buffer,
|
|
|
|
|
/*use_split_band_data=*/true);
|
2016-11-22 07:24:52 -08:00
|
|
|
}
|
2019-10-29 22:59:44 +01:00
|
|
|
|
2020-01-13 14:43:13 +01:00
|
|
|
if (submodules_.gain_control) {
|
|
|
|
|
RETURN_ON_ERR(
|
|
|
|
|
submodules_.gain_control->AnalyzeCaptureAudio(*capture_buffer));
|
|
|
|
|
}
|
2019-12-20 00:42:22 +01:00
|
|
|
|
2020-01-30 07:40:58 +01:00
|
|
|
if ((!config_.noise_suppression.analyze_linear_aec_output_when_available ||
|
|
|
|
|
!linear_aec_buffer || submodules_.echo_control_mobile) &&
|
|
|
|
|
submodules_.noise_suppressor) {
|
|
|
|
|
submodules_.noise_suppressor->Analyze(*capture_buffer);
|
2019-10-16 11:46:11 +02:00
|
|
|
}
|
2016-03-15 09:34:24 -07:00
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.echo_control_mobile) {
|
2019-04-29 12:14:50 +02:00
|
|
|
// Ensure that the stream delay was set before the call to the
|
|
|
|
|
// AECM ProcessCaptureAudio function.
|
2020-01-17 10:55:09 +01:00
|
|
|
if (!capture_.was_stream_delay_set) {
|
2019-04-29 12:14:50 +02:00
|
|
|
return AudioProcessing::kStreamParameterNotSetError;
|
|
|
|
|
}
|
2018-02-12 21:42:56 +01:00
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.noise_suppressor) {
|
2019-10-29 22:59:44 +01:00
|
|
|
submodules_.noise_suppressor->Process(capture_buffer);
|
2018-04-18 09:35:13 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
RETURN_ON_ERR(submodules_.echo_control_mobile->ProcessCaptureAudio(
|
2017-02-06 03:39:42 -08:00
|
|
|
capture_buffer, stream_delay_ms()));
|
2019-04-29 12:14:50 +02:00
|
|
|
} else {
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.echo_controller) {
|
2019-04-29 12:14:50 +02:00
|
|
|
data_dumper_->DumpRaw("stream_delay", stream_delay_ms());
|
2016-12-14 01:16:23 -08:00
|
|
|
|
2020-01-17 10:55:09 +01:00
|
|
|
if (capture_.was_stream_delay_set) {
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_controller->SetAudioBufferDelay(stream_delay_ms());
|
2019-04-29 12:14:50 +02:00
|
|
|
}
|
2016-03-15 04:32:28 -07:00
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_controller->ProcessCapture(
|
2019-11-13 11:12:29 +01:00
|
|
|
capture_buffer, linear_aec_buffer, capture_.echo_path_gain_change);
|
2019-04-29 12:14:50 +02:00
|
|
|
}
|
|
|
|
|
|
2019-12-20 00:42:22 +01:00
|
|
|
if (config_.noise_suppression.analyze_linear_aec_output_when_available &&
|
2020-01-30 07:40:58 +01:00
|
|
|
linear_aec_buffer && submodules_.noise_suppressor) {
|
|
|
|
|
submodules_.noise_suppressor->Analyze(*linear_aec_buffer);
|
2019-12-20 00:42:22 +01:00
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.noise_suppressor) {
|
2019-10-29 22:59:44 +01:00
|
|
|
submodules_.noise_suppressor->Process(capture_buffer);
|
2019-10-16 11:46:11 +02:00
|
|
|
}
|
2017-06-07 10:08:10 +02:00
|
|
|
}
|
2016-10-28 05:39:16 -07:00
|
|
|
|
2020-01-13 14:43:13 +01:00
|
|
|
if (submodules_.agc_manager) {
|
2022-09-06 17:36:26 +02:00
|
|
|
submodules_.agc_manager->Process(*capture_buffer);
|
2019-11-22 12:11:40 +01:00
|
|
|
|
|
|
|
|
absl::optional<int> new_digital_gain =
|
|
|
|
|
submodules_.agc_manager->GetDigitalComressionGain();
|
2020-01-13 14:43:13 +01:00
|
|
|
if (new_digital_gain && submodules_.gain_control) {
|
2019-11-22 12:11:40 +01:00
|
|
|
submodules_.gain_control->set_compression_gain_db(*new_digital_gain);
|
|
|
|
|
}
|
2014-12-15 09:41:24 +00:00
|
|
|
}
|
2020-01-13 14:43:13 +01:00
|
|
|
|
|
|
|
|
if (submodules_.gain_control) {
|
|
|
|
|
// TODO(peah): Add reporting from AEC3 whether there is echo.
|
|
|
|
|
RETURN_ON_ERR(submodules_.gain_control->ProcessCaptureAudio(
|
|
|
|
|
capture_buffer, /*stream_has_echo*/ false));
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2021-03-11 11:40:46 +00:00
|
|
|
if (submodule_states_.CaptureMultiBandProcessingPresent() &&
|
|
|
|
|
SampleRateSupportsMultiBand(
|
|
|
|
|
capture_nonlocked_.capture_processing_format.sample_rate_hz())) {
|
|
|
|
|
capture_buffer->MergeFrequencyBands();
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2021-03-12 23:08:09 +00:00
|
|
|
if (capture_.capture_output_used) {
|
|
|
|
|
if (capture_.capture_fullband_audio) {
|
|
|
|
|
const auto& ec = submodules_.echo_controller;
|
|
|
|
|
bool ec_active = ec ? ec->ActiveProcessing() : false;
|
|
|
|
|
// Only update the fullband buffer if the multiband processing has changed
|
|
|
|
|
// the signal. Keep the original signal otherwise.
|
|
|
|
|
if (submodule_states_.CaptureMultiBandProcessingActive(ec_active)) {
|
|
|
|
|
capture_buffer->CopyTo(capture_.capture_fullband_audio.get());
|
|
|
|
|
}
|
|
|
|
|
capture_buffer = capture_.capture_fullband_audio.get();
|
2019-10-09 13:34:36 +02:00
|
|
|
}
|
2019-10-09 13:02:14 +02:00
|
|
|
|
2021-12-06 15:40:04 +01:00
|
|
|
if (submodules_.echo_detector) {
|
2021-03-12 23:08:09 +00:00
|
|
|
submodules_.echo_detector->AnalyzeCaptureAudio(
|
|
|
|
|
rtc::ArrayView<const float>(capture_buffer->channels()[0],
|
|
|
|
|
capture_buffer->num_frames()));
|
|
|
|
|
}
|
2017-05-15 07:19:21 -07:00
|
|
|
|
2022-06-20 17:52:43 +02:00
|
|
|
absl::optional<float> voice_probability;
|
|
|
|
|
if (!!submodules_.voice_activity_detector) {
|
|
|
|
|
voice_probability = submodules_.voice_activity_detector->Analyze(
|
|
|
|
|
AudioFrameView<const float>(capture_buffer->channels(),
|
|
|
|
|
capture_buffer->num_channels(),
|
|
|
|
|
capture_buffer->num_frames()));
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-12 23:08:09 +00:00
|
|
|
if (submodules_.transient_suppressor) {
|
2022-06-20 17:52:43 +02:00
|
|
|
float transient_suppressor_voice_probability = 1.0f;
|
2022-03-18 12:39:00 +01:00
|
|
|
switch (transient_suppressor_vad_mode_) {
|
|
|
|
|
case TransientSuppressor::VadMode::kDefault:
|
|
|
|
|
if (submodules_.agc_manager) {
|
2022-06-20 17:52:43 +02:00
|
|
|
transient_suppressor_voice_probability =
|
|
|
|
|
submodules_.agc_manager->voice_probability();
|
2022-03-18 12:39:00 +01:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case TransientSuppressor::VadMode::kRnnVad:
|
2022-06-20 17:52:43 +02:00
|
|
|
RTC_DCHECK(voice_probability.has_value());
|
|
|
|
|
transient_suppressor_voice_probability = *voice_probability;
|
2022-03-18 12:39:00 +01:00
|
|
|
break;
|
|
|
|
|
case TransientSuppressor::VadMode::kNoVad:
|
|
|
|
|
// The transient suppressor will ignore `voice_probability`.
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-06-20 17:52:43 +02:00
|
|
|
float delayed_voice_probability =
|
|
|
|
|
submodules_.transient_suppressor->Suppress(
|
|
|
|
|
capture_buffer->channels()[0], capture_buffer->num_frames(),
|
|
|
|
|
capture_buffer->num_channels(),
|
|
|
|
|
capture_buffer->split_bands_const(0)[kBand0To8kHz],
|
|
|
|
|
capture_buffer->num_frames_per_band(),
|
|
|
|
|
/*reference_data=*/nullptr, /*reference_length=*/0,
|
|
|
|
|
transient_suppressor_voice_probability, capture_.key_pressed);
|
|
|
|
|
if (voice_probability.has_value()) {
|
|
|
|
|
*voice_probability = delayed_voice_probability;
|
|
|
|
|
}
|
2021-03-12 23:08:09 +00:00
|
|
|
}
|
2014-12-15 09:41:24 +00:00
|
|
|
|
2021-07-28 20:50:03 +02:00
|
|
|
// Experimental APM sub-module that analyzes `capture_buffer`.
|
2021-03-12 23:08:09 +00:00
|
|
|
if (submodules_.capture_analyzer) {
|
|
|
|
|
submodules_.capture_analyzer->Analyze(capture_buffer);
|
|
|
|
|
}
|
2014-12-15 09:41:24 +00:00
|
|
|
|
2021-03-12 23:08:09 +00:00
|
|
|
if (submodules_.gain_controller2) {
|
2022-11-30 15:16:21 +01:00
|
|
|
// TODO(bugs.webrtc.org/7494): Let AGC2 detect applied input volume
|
|
|
|
|
// changes.
|
2022-09-07 17:14:26 +02:00
|
|
|
submodules_.gain_controller2->Process(
|
|
|
|
|
voice_probability, capture_.applied_input_volume_changed,
|
|
|
|
|
capture_buffer);
|
2021-03-12 23:08:09 +00:00
|
|
|
}
|
2018-08-29 10:37:09 +02:00
|
|
|
|
2021-03-12 23:08:09 +00:00
|
|
|
if (submodules_.capture_post_processor) {
|
|
|
|
|
submodules_.capture_post_processor->Process(capture_buffer);
|
|
|
|
|
}
|
2017-05-22 06:57:06 -07:00
|
|
|
|
2021-03-12 23:08:09 +00:00
|
|
|
capture_output_rms_.Analyze(rtc::ArrayView<const float>(
|
|
|
|
|
capture_buffer->channels_const()[0],
|
|
|
|
|
capture_nonlocked_.capture_processing_format.num_frames()));
|
|
|
|
|
if (log_rms) {
|
|
|
|
|
RmsLevel::Levels levels = capture_output_rms_.AverageAndPeak();
|
|
|
|
|
RTC_HISTOGRAM_COUNTS_LINEAR(
|
|
|
|
|
"WebRTC.Audio.ApmCaptureOutputLevelAverageRms", levels.average, 1,
|
|
|
|
|
RmsLevel::kMinLevelDb, 64);
|
|
|
|
|
RTC_HISTOGRAM_COUNTS_LINEAR("WebRTC.Audio.ApmCaptureOutputLevelPeakRms",
|
|
|
|
|
levels.peak, 1, RmsLevel::kMinLevelDb, 64);
|
|
|
|
|
}
|
2014-03-04 20:58:13 +00:00
|
|
|
|
2021-03-12 23:08:09 +00:00
|
|
|
// Compute echo-detector stats.
|
2021-12-06 15:40:04 +01:00
|
|
|
if (submodules_.echo_detector) {
|
2021-03-12 23:08:09 +00:00
|
|
|
auto ed_metrics = submodules_.echo_detector->GetMetrics();
|
|
|
|
|
capture_.stats.residual_echo_likelihood = ed_metrics.echo_likelihood;
|
|
|
|
|
capture_.stats.residual_echo_likelihood_recent_max =
|
|
|
|
|
ed_metrics.echo_likelihood_recent_max;
|
|
|
|
|
}
|
2019-11-18 08:52:22 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-12 23:08:09 +00:00
|
|
|
// Compute echo-controller stats.
|
2019-12-30 14:32:14 +01:00
|
|
|
if (submodules_.echo_controller) {
|
|
|
|
|
auto ec_metrics = submodules_.echo_controller->GetMetrics();
|
|
|
|
|
capture_.stats.echo_return_loss = ec_metrics.echo_return_loss;
|
|
|
|
|
capture_.stats.echo_return_loss_enhancement =
|
|
|
|
|
ec_metrics.echo_return_loss_enhancement;
|
|
|
|
|
capture_.stats.delay_ms = ec_metrics.delay_ms;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Pass stats for reporting.
|
|
|
|
|
stats_reporter_.UpdateStatistics(capture_.stats);
|
|
|
|
|
|
2022-09-07 16:58:33 +02:00
|
|
|
UpdateRecommendedInputVolumeLocked();
|
2022-10-27 00:05:32 +02:00
|
|
|
if (capture_.recommended_input_volume.has_value()) {
|
|
|
|
|
recommended_input_volume_stats_reporter_.UpdateStatistics(
|
|
|
|
|
*capture_.recommended_input_volume);
|
|
|
|
|
}
|
2022-09-07 16:58:33 +02:00
|
|
|
|
2021-03-15 16:31:04 +00:00
|
|
|
if (submodules_.capture_levels_adjuster) {
|
|
|
|
|
submodules_.capture_levels_adjuster->ApplyPostLevelAdjustment(
|
|
|
|
|
*capture_buffer);
|
|
|
|
|
|
|
|
|
|
if (config_.capture_level_adjustment.analog_mic_gain_emulation.enabled) {
|
2022-09-07 15:15:52 +02:00
|
|
|
// If the input volume emulation is used, retrieve the recommended input
|
|
|
|
|
// volume and set that to emulate the input volume on the next processed
|
|
|
|
|
// audio frame.
|
2022-09-07 16:58:33 +02:00
|
|
|
RTC_DCHECK(capture_.recommended_input_volume.has_value());
|
2022-09-07 15:15:52 +02:00
|
|
|
submodules_.capture_levels_adjuster->SetAnalogMicGainLevel(
|
2022-09-07 16:58:33 +02:00
|
|
|
*capture_.recommended_input_volume);
|
2021-03-15 16:31:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-12 14:18:36 +00:00
|
|
|
// Temporarily set the output to zero after the stream has been unmuted
|
|
|
|
|
// (capture output is again used). The purpose of this is to avoid clicks and
|
|
|
|
|
// artefacts in the audio that results when the processing again is
|
|
|
|
|
// reactivated after unmuting.
|
|
|
|
|
if (!capture_.capture_output_used_last_frame &&
|
|
|
|
|
capture_.capture_output_used) {
|
|
|
|
|
for (size_t ch = 0; ch < capture_buffer->num_channels(); ++ch) {
|
|
|
|
|
rtc::ArrayView<float> channel_view(capture_buffer->channels()[ch],
|
|
|
|
|
capture_buffer->num_frames());
|
|
|
|
|
std::fill(channel_view.begin(), channel_view.end(), 0.f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
capture_.capture_output_used_last_frame = capture_.capture_output_used;
|
|
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
capture_.was_stream_delay_set = false;
|
2022-09-07 17:14:26 +02:00
|
|
|
|
2022-09-07 16:58:33 +02:00
|
|
|
data_dumper_->DumpRaw("recommended_input_volume",
|
|
|
|
|
capture_.recommended_input_volume.value_or(
|
|
|
|
|
kUnspecifiedDataDumpInputVolume));
|
2022-09-07 17:14:26 +02:00
|
|
|
|
2014-03-04 20:58:13 +00:00
|
|
|
return kNoError;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-22 15:21:31 +02:00
|
|
|
int AudioProcessingImpl::AnalyzeReverseStream(
|
|
|
|
|
const float* const* data,
|
|
|
|
|
const StreamConfig& reverse_config) {
|
|
|
|
|
TRACE_EVENT0("webrtc", "AudioProcessing::AnalyzeReverseStream_StreamConfig");
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock(&mutex_render_);
|
2022-12-20 16:22:44 +01:00
|
|
|
DenormalDisabler denormal_disabler;
|
2022-11-17 11:26:58 +01:00
|
|
|
RTC_DCHECK(data);
|
|
|
|
|
for (size_t i = 0; i < reverse_config.num_channels(); ++i) {
|
|
|
|
|
RTC_DCHECK(data[i]);
|
|
|
|
|
}
|
|
|
|
|
RETURN_ON_ERR(
|
|
|
|
|
AudioFormatValidityToErrorCode(ValidateAudioFormat(reverse_config)));
|
|
|
|
|
|
|
|
|
|
MaybeInitializeRender(reverse_config, reverse_config);
|
2019-10-22 15:21:31 +02:00
|
|
|
return AnalyzeReverseStreamLocked(data, reverse_config, reverse_config);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-16 15:02:15 -07:00
|
|
|
int AudioProcessingImpl::ProcessReverseStream(const float* const* src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
|
|
|
|
float* const* dest) {
|
2015-12-17 06:42:29 -08:00
|
|
|
TRACE_EVENT0("webrtc", "AudioProcessing::ProcessReverseStream_StreamConfig");
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock(&mutex_render_);
|
2022-12-20 16:22:44 +01:00
|
|
|
DenormalDisabler denormal_disabler;
|
2022-11-17 11:26:58 +01:00
|
|
|
RETURN_ON_ERR(
|
|
|
|
|
HandleUnsupportedAudioFormats(src, input_config, output_config, dest));
|
|
|
|
|
|
|
|
|
|
MaybeInitializeRender(input_config, output_config);
|
2021-08-10 15:23:23 +02:00
|
|
|
|
2016-09-16 15:02:15 -07:00
|
|
|
RETURN_ON_ERR(AnalyzeReverseStreamLocked(src, input_config, output_config));
|
2022-11-17 11:26:58 +01:00
|
|
|
|
2017-12-18 16:02:40 +01:00
|
|
|
if (submodule_states_.RenderMultiBandProcessingActive() ||
|
|
|
|
|
submodule_states_.RenderFullBandProcessingActive()) {
|
2015-11-28 12:35:15 -08:00
|
|
|
render_.render_audio->CopyTo(formats_.api_format.reverse_output_stream(),
|
|
|
|
|
dest);
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
} else if (formats_.api_format.reverse_input_stream() !=
|
|
|
|
|
formats_.api_format.reverse_output_stream()) {
|
2016-09-16 15:02:15 -07:00
|
|
|
render_.render_converter->Convert(src, input_config.num_samples(), dest,
|
|
|
|
|
output_config.num_samples());
|
2015-08-14 10:35:55 -07:00
|
|
|
} else {
|
2016-09-16 15:02:15 -07:00
|
|
|
CopyAudioIfNeeded(src, input_config.num_frames(),
|
|
|
|
|
input_config.num_channels(), dest);
|
2015-08-14 10:35:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return kNoError;
|
2015-07-23 11:41:39 -07:00
|
|
|
}
|
|
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
int AudioProcessingImpl::AnalyzeReverseStreamLocked(
|
2015-08-14 10:35:55 -07:00
|
|
|
const float* const* src,
|
2016-09-16 15:02:15 -07:00
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config) {
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
if (aec_dump_) {
|
|
|
|
|
const size_t channel_size =
|
|
|
|
|
formats_.api_format.reverse_input_stream().num_frames();
|
|
|
|
|
const size_t num_channels =
|
|
|
|
|
formats_.api_format.reverse_input_stream().num_channels();
|
|
|
|
|
aec_dump_->WriteRenderStreamMessage(
|
2018-02-16 11:54:07 +01:00
|
|
|
AudioFrameView<const float>(src, num_channels, channel_size));
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
}
|
2015-11-28 12:35:15 -08:00
|
|
|
render_.render_audio->CopyFrom(src,
|
|
|
|
|
formats_.api_format.reverse_input_stream());
|
2016-09-16 15:02:15 -07:00
|
|
|
return ProcessRenderStreamLocked();
|
2015-08-14 10:35:55 -07:00
|
|
|
}
|
|
|
|
|
|
2020-03-16 12:06:02 +01:00
|
|
|
int AudioProcessingImpl::ProcessReverseStream(const int16_t* const src,
|
|
|
|
|
const StreamConfig& input_config,
|
|
|
|
|
const StreamConfig& output_config,
|
|
|
|
|
int16_t* const dest) {
|
2020-03-17 13:23:58 +01:00
|
|
|
TRACE_EVENT0("webrtc", "AudioProcessing::ProcessReverseStream_AudioFrame");
|
2020-03-19 12:33:29 +01:00
|
|
|
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock(&mutex_render_);
|
2022-12-20 16:22:44 +01:00
|
|
|
DenormalDisabler denormal_disabler;
|
2021-08-10 15:23:23 +02:00
|
|
|
|
2022-11-17 11:26:58 +01:00
|
|
|
RETURN_ON_ERR(
|
|
|
|
|
HandleUnsupportedAudioFormats(src, input_config, output_config, dest));
|
|
|
|
|
MaybeInitializeRender(input_config, output_config);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
if (aec_dump_) {
|
2020-03-16 12:06:02 +01:00
|
|
|
aec_dump_->WriteRenderStreamMessage(src, input_config.num_frames(),
|
|
|
|
|
input_config.num_channels());
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
}
|
|
|
|
|
|
2020-03-16 12:06:02 +01:00
|
|
|
render_.render_audio->CopyFrom(src, input_config);
|
2016-09-16 15:02:15 -07:00
|
|
|
RETURN_ON_ERR(ProcessRenderStreamLocked());
|
2019-08-15 12:15:46 +02:00
|
|
|
if (submodule_states_.RenderMultiBandProcessingActive() ||
|
|
|
|
|
submodule_states_.RenderFullBandProcessingActive()) {
|
2020-03-16 12:06:02 +01:00
|
|
|
render_.render_audio->CopyTo(output_config, dest);
|
2019-08-15 12:15:46 +02:00
|
|
|
}
|
2016-03-17 20:39:53 -07:00
|
|
|
return kNoError;
|
2014-03-04 20:58:13 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-09-16 15:02:15 -07:00
|
|
|
int AudioProcessingImpl::ProcessRenderStreamLocked() {
|
|
|
|
|
AudioBuffer* render_buffer = render_.render_audio.get(); // For brevity.
|
2017-05-15 07:19:21 -07:00
|
|
|
|
2018-05-15 10:52:28 +02:00
|
|
|
HandleRenderRuntimeSettings();
|
2022-12-20 16:22:44 +01:00
|
|
|
DenormalDisabler denormal_disabler;
|
2018-05-15 10:52:28 +02:00
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.render_pre_processor) {
|
|
|
|
|
submodules_.render_pre_processor->Process(render_buffer);
|
2017-12-18 16:02:40 +01:00
|
|
|
}
|
|
|
|
|
|
2018-08-09 14:23:11 +02:00
|
|
|
QueueNonbandedRenderAudio(render_buffer);
|
|
|
|
|
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
if (submodule_states_.RenderMultiBandSubModulesActive() &&
|
2016-09-16 15:02:15 -07:00
|
|
|
SampleRateSupportsMultiBand(
|
|
|
|
|
formats_.render_processing_format.sample_rate_hz())) {
|
|
|
|
|
render_buffer->SplitIntoFrequencyBands();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2017-05-19 01:28:05 -07:00
|
|
|
if (submodule_states_.RenderMultiBandSubModulesActive()) {
|
|
|
|
|
QueueBandedRenderAudio(render_buffer);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-09 14:23:11 +02:00
|
|
|
// TODO(peah): Perform the queuing inside QueueRenderAudiuo().
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.echo_controller) {
|
|
|
|
|
submodules_.echo_controller->AnalyzeRender(render_buffer);
|
2016-12-14 01:16:23 -08:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
if (submodule_states_.RenderMultiBandProcessingActive() &&
|
2016-09-16 15:02:15 -07:00
|
|
|
SampleRateSupportsMultiBand(
|
|
|
|
|
formats_.render_processing_format.sample_rate_hz())) {
|
|
|
|
|
render_buffer->MergeFrequencyBands();
|
2015-08-14 10:35:55 -07:00
|
|
|
}
|
|
|
|
|
|
2014-03-04 20:58:13 +00:00
|
|
|
return kNoError;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AudioProcessingImpl::set_stream_delay_ms(int delay) {
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock(&mutex_capture_);
|
2012-05-29 21:14:06 +00:00
|
|
|
Error retval = kNoError;
|
2015-11-28 12:35:15 -08:00
|
|
|
capture_.was_stream_delay_set = true;
|
2012-03-06 19:03:39 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
if (delay < 0) {
|
2012-05-29 21:14:06 +00:00
|
|
|
delay = 0;
|
|
|
|
|
retval = kBadStreamParameterWarning;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO(ajm): the max is rather arbitrarily chosen; investigate.
|
|
|
|
|
if (delay > 500) {
|
2012-05-29 21:14:06 +00:00
|
|
|
delay = 500;
|
|
|
|
|
retval = kBadStreamParameterWarning;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-28 12:35:15 -08:00
|
|
|
capture_nonlocked_.stream_delay_ms = delay;
|
2012-05-29 21:14:06 +00:00
|
|
|
return retval;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-13 11:12:29 +01:00
|
|
|
bool AudioProcessingImpl::GetLinearAecOutput(
|
|
|
|
|
rtc::ArrayView<std::array<float, 160>> linear_output) const {
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock(&mutex_capture_);
|
2019-11-13 11:12:29 +01:00
|
|
|
AudioBuffer* linear_aec_buffer = capture_.linear_aec_output.get();
|
|
|
|
|
|
|
|
|
|
RTC_DCHECK(linear_aec_buffer);
|
|
|
|
|
if (linear_aec_buffer) {
|
|
|
|
|
RTC_DCHECK_EQ(1, linear_aec_buffer->num_bands());
|
|
|
|
|
RTC_DCHECK_EQ(linear_output.size(), linear_aec_buffer->num_channels());
|
|
|
|
|
|
|
|
|
|
for (size_t ch = 0; ch < linear_aec_buffer->num_channels(); ++ch) {
|
|
|
|
|
RTC_DCHECK_EQ(linear_output[ch].size(), linear_aec_buffer->num_frames());
|
|
|
|
|
rtc::ArrayView<const float> channel_view =
|
|
|
|
|
rtc::ArrayView<const float>(linear_aec_buffer->channels_const()[ch],
|
|
|
|
|
linear_aec_buffer->num_frames());
|
2020-11-13 14:30:30 +01:00
|
|
|
FloatS16ToFloat(channel_view.data(), channel_view.size(),
|
|
|
|
|
linear_output[ch].data());
|
2019-11-13 11:12:29 +01:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
RTC_LOG(LS_ERROR) << "No linear AEC output available";
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
2019-11-13 11:12:29 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
int AudioProcessingImpl::stream_delay_ms() const {
|
2015-11-28 12:35:15 -08:00
|
|
|
// Used as callback from submodules, hence locking is not allowed.
|
|
|
|
|
return capture_nonlocked_.stream_delay_ms;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-04 20:58:13 +00:00
|
|
|
void AudioProcessingImpl::set_stream_key_pressed(bool key_pressed) {
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock(&mutex_capture_);
|
2015-11-28 12:35:15 -08:00
|
|
|
capture_.key_pressed = key_pressed;
|
2014-03-04 20:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-27 13:28:08 +01:00
|
|
|
void AudioProcessingImpl::set_stream_analog_level(int level) {
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2022-09-07 15:15:52 +02:00
|
|
|
set_stream_analog_level_locked(level);
|
|
|
|
|
}
|
2019-11-18 08:52:22 +01:00
|
|
|
|
2022-09-07 15:15:52 +02:00
|
|
|
void AudioProcessingImpl::set_stream_analog_level_locked(int level) {
|
2022-09-07 17:14:26 +02:00
|
|
|
capture_.applied_input_volume_changed =
|
|
|
|
|
capture_.applied_input_volume.has_value() &&
|
|
|
|
|
*capture_.applied_input_volume != level;
|
|
|
|
|
capture_.applied_input_volume = level;
|
2021-03-15 16:31:04 +00:00
|
|
|
|
2022-09-07 16:58:33 +02:00
|
|
|
// Invalidate any previously recommended input volume which will be updated by
|
|
|
|
|
// `ProcessStream()`.
|
|
|
|
|
capture_.recommended_input_volume = absl::nullopt;
|
|
|
|
|
|
2019-11-18 08:52:22 +01:00
|
|
|
if (submodules_.agc_manager) {
|
|
|
|
|
submodules_.agc_manager->set_stream_analog_level(level);
|
2021-03-15 16:31:04 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (submodules_.gain_control) {
|
2019-11-18 08:52:22 +01:00
|
|
|
int error = submodules_.gain_control->set_stream_analog_level(level);
|
|
|
|
|
RTC_DCHECK_EQ(kNoError, error);
|
2021-03-15 16:31:04 +00:00
|
|
|
return;
|
2019-11-18 08:52:22 +01:00
|
|
|
}
|
2019-03-27 13:28:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AudioProcessingImpl::recommended_stream_analog_level() const {
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2022-09-07 16:58:33 +02:00
|
|
|
if (!capture_.applied_input_volume.has_value()) {
|
|
|
|
|
RTC_LOG(LS_ERROR) << "set_stream_analog_level has not been called";
|
|
|
|
|
}
|
|
|
|
|
// Input volume to recommend when `set_stream_analog_level()` is not called.
|
|
|
|
|
constexpr int kFallBackInputVolume = 255;
|
|
|
|
|
// When APM has no input volume to recommend, return the latest applied input
|
|
|
|
|
// volume that has been observed in order to possibly produce no input volume
|
|
|
|
|
// change. If no applied input volume has been observed, return a fall-back
|
|
|
|
|
// value.
|
|
|
|
|
return capture_.recommended_input_volume.value_or(
|
|
|
|
|
capture_.applied_input_volume.value_or(kFallBackInputVolume));
|
2020-05-14 14:31:18 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-07 16:58:33 +02:00
|
|
|
void AudioProcessingImpl::UpdateRecommendedInputVolumeLocked() {
|
2022-09-07 17:14:26 +02:00
|
|
|
if (!capture_.applied_input_volume.has_value()) {
|
2022-09-07 16:58:33 +02:00
|
|
|
// When `set_stream_analog_level()` is not called, no input level can be
|
|
|
|
|
// recommended.
|
|
|
|
|
capture_.recommended_input_volume = absl::nullopt;
|
|
|
|
|
return;
|
2022-09-07 17:14:26 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-18 08:52:22 +01:00
|
|
|
if (submodules_.agc_manager) {
|
2022-09-07 16:58:33 +02:00
|
|
|
capture_.recommended_input_volume =
|
|
|
|
|
submodules_.agc_manager->recommended_analog_level();
|
|
|
|
|
return;
|
2021-03-15 16:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (submodules_.gain_control) {
|
2022-09-07 16:58:33 +02:00
|
|
|
capture_.recommended_input_volume =
|
|
|
|
|
submodules_.gain_control->stream_analog_level();
|
|
|
|
|
return;
|
2019-11-18 08:52:22 +01:00
|
|
|
}
|
2021-03-15 16:31:04 +00:00
|
|
|
|
2022-11-30 15:16:21 +01:00
|
|
|
if (submodules_.gain_controller2 &&
|
|
|
|
|
config_.gain_controller2.input_volume_controller.enabled) {
|
|
|
|
|
capture_.recommended_input_volume =
|
2022-12-14 12:48:37 +01:00
|
|
|
submodules_.gain_controller2->recommended_input_volume();
|
2022-11-30 15:16:21 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-07 16:58:33 +02:00
|
|
|
capture_.recommended_input_volume = capture_.applied_input_volume;
|
2019-03-27 13:28:08 +01:00
|
|
|
}
|
|
|
|
|
|
2022-07-25 22:07:08 +02:00
|
|
|
bool AudioProcessingImpl::CreateAndAttachAecDump(absl::string_view file_name,
|
|
|
|
|
int64_t max_log_size_bytes,
|
|
|
|
|
rtc::TaskQueue* worker_queue) {
|
2022-08-16 14:44:38 +02:00
|
|
|
std::unique_ptr<AecDump> aec_dump =
|
|
|
|
|
AecDumpFactory::Create(file_name, max_log_size_bytes, worker_queue);
|
2020-05-11 11:03:47 +02:00
|
|
|
if (!aec_dump) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AttachAecDump(std::move(aec_dump));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AudioProcessingImpl::CreateAndAttachAecDump(FILE* handle,
|
|
|
|
|
int64_t max_log_size_bytes,
|
|
|
|
|
rtc::TaskQueue* worker_queue) {
|
|
|
|
|
std::unique_ptr<AecDump> aec_dump =
|
|
|
|
|
AecDumpFactory::Create(handle, max_log_size_bytes, worker_queue);
|
|
|
|
|
if (!aec_dump) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AttachAecDump(std::move(aec_dump));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
void AudioProcessingImpl::AttachAecDump(std::unique_ptr<AecDump> aec_dump) {
|
|
|
|
|
RTC_DCHECK(aec_dump);
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_render(&mutex_render_);
|
|
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
|
|
|
|
|
// The previously attached AecDump will be destroyed with the
|
|
|
|
|
// 'aec_dump' parameter, which is after locks are released.
|
|
|
|
|
aec_dump_.swap(aec_dump);
|
|
|
|
|
WriteAecDumpConfigMessage(true);
|
2018-08-10 15:38:52 +02:00
|
|
|
aec_dump_->WriteInitMessage(formats_.api_format, rtc::TimeUTCMillis());
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::DetachAecDump() {
|
|
|
|
|
// The d-tor of a task-queue based AecDump blocks until all pending
|
|
|
|
|
// tasks are done. This construction avoids blocking while holding
|
|
|
|
|
// the render and capture locks.
|
|
|
|
|
std::unique_ptr<AecDump> aec_dump = nullptr;
|
|
|
|
|
{
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_render(&mutex_render_);
|
|
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
aec_dump = std::move(aec_dump_);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 07:24:52 -08:00
|
|
|
AudioProcessing::Config AudioProcessingImpl::GetConfig() const {
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_render(&mutex_render_);
|
|
|
|
|
MutexLock lock_capture(&mutex_capture_);
|
2016-11-22 07:24:52 -08:00
|
|
|
return config_;
|
|
|
|
|
}
|
|
|
|
|
|
The audio processing module (APM) relies on two for
functionalities doing sample-rate conversions:
-The implicit resampling done in the AudioBuffer CopyTo,
CopyFrom, InterleaveTo and DeinterleaveFrom methods.
-The multi-band splitting scheme.
The selection of rates in these have been difficult and
complicated, partly due to that the APM API which allows
for activating the APM submodules without notifying
the APM.
This CL adds functionality that for each capture frame
polls all submodules for whether they are active or not
and compares this against a cached result.
Furthermore, new functionality is added that based on the
results of the comparison do a reinitialization of the APM.
This has several advantages
-The code deciding on whether to analysis and synthesis is
needed for the bandsplitting can be much simplified and
centralized.
-The selection of the processing rate can be done such as
to avoid the implicit resampling that was in some cases
unnecessarily done.
-The optimization for whether an output copy is needed
that was done to improve performance due to the implicit
resampling is no longer needed, which simplifies the
code and makes it less error-prone in the sense that
is no longer neccessary to keep track of whether any
module has changed the signal.
Finally, it should be noted that the polling of the state
for all the submodules was done previously as well, but in
a less obvious and distributed manner.
BUG=webrtc:6181, webrtc:6220, webrtc:5298, webrtc:6296, webrtc:6298, webrtc:6297
Review-Url: https://codereview.webrtc.org/2304123002
Cr-Commit-Position: refs/heads/master@{#14175}
2016-09-10 04:42:27 -07:00
|
|
|
bool AudioProcessingImpl::UpdateActiveSubmoduleStates() {
|
|
|
|
|
return submodule_states_.Update(
|
2019-12-09 10:18:44 +01:00
|
|
|
config_.high_pass_filter.enabled, !!submodules_.echo_control_mobile,
|
2021-12-06 15:40:04 +01:00
|
|
|
!!submodules_.noise_suppressor, !!submodules_.gain_control,
|
2022-06-16 16:35:45 +02:00
|
|
|
!!submodules_.gain_controller2, !!submodules_.voice_activity_detector,
|
2021-03-15 16:31:04 +00:00
|
|
|
config_.pre_amplifier.enabled || config_.capture_level_adjustment.enabled,
|
|
|
|
|
capture_nonlocked_.echo_controller_enabled,
|
Reland "Reland "Remove unused APM voice activity detection sub-module""
This reverts commit 09aaf6f7bcfb4da644bd86c76896a04a41f776e1.
Reason for revert: downstream fixed (see https://chromium-review.googlesource.com/c/chromium/src/+/3461371)
Original change's description:
> Revert "Reland "Remove unused APM voice activity detection sub-module""
>
> This reverts commit 54d1344d985b00d4d1580dd18057d4618c11ad1f.
>
> Reason for revert: Breaks chromium roll, see
> https://ci.chromium.org/ui/p/chromium/builders/try/linux_chromium_tsan_rel_ng/1080583/overview
>
> https://chromium-review.googlesource.com/c/chromium/src/+/3461512
>
> Original change's description:
> > Reland "Remove unused APM voice activity detection sub-module"
> >
> > This reverts commit a751f167c68343f76528436defdbc61600a8d7b3.
> >
> > Reason for revert: dependency in a downstream project removed
> >
> > Original change's description:
> > > Revert "Remove unused APM voice activity detection sub-module"
> > >
> > > This reverts commit b4e06d032e6f82a65c52ed0c5364ae9e7c0a0215.
> > >
> > > Reason for revert: breaking downstream projects
> > >
> > > Original change's description:
> > > > Remove unused APM voice activity detection sub-module
> > > >
> > > > API changes:
> > > > - webrtc::AudioProcessing::Config::VoiceDetection removed
> > > > - webrtc::AudioProcessingStats::voice_detected deprecated
> > > > - cricket::AudioOptions::typing_detection deprecated
> > > > - webrtc::StatsReport::StatsValueName::
> > > > kStatsValueNameTypingNoiseState deprecated
> > > >
> > > > PSA: https://groups.google.com/g/discuss-webrtc/c/7X6uwmJarE0
> > > >
> > > > Bug: webrtc:11226,webrtc:11292
> > > > Change-Id: I8d008b56708cf62961b9857ec052b59fda3b41bf
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250666
> > > > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > > > Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
> > > > Reviewed-by: Sam Zackrisson <saza@webrtc.org>
> > > > Reviewed-by: Björn Terelius <terelius@webrtc.org>
> > > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > > > Cr-Commit-Position: refs/heads/main@{#35975}
> > >
> > > TBR=gustaf@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,terelius@webrtc.org,hta@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com
> > >
> > > Change-Id: Iee01fdb874b4e0331277f3ffe60dacaabc3859a2
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: webrtc:11226,webrtc:11292
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251600
> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > > Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
> > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> > > Cr-Commit-Position: refs/heads/main@{#35977}
> >
> > # Not skipping CQ checks because this is a reland.
> >
> > Bug: webrtc:11226,webrtc:11292
> > Change-Id: I2fcbc5fdade16bfe6a0f0a02841a33a598d4f2ad
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251660
> > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#35984}
>
> TBR=mbonadei@webrtc.org,gustaf@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,terelius@webrtc.org,hta@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com
>
> Change-Id: Ib308a3af2dcce85a0074ef5a4680ccec3f82712f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:11226,webrtc:11292
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251688
> Reviewed-by: Henrik Boström <hbos@webrtc.org>
> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
> Auto-Submit: Henrik Boström <hbos@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#35990}
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: webrtc:11226,webrtc:11292
Change-Id: Idfda6a517027ad323caf44c526a88468e5b52b65
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251762
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36012}
2022-02-15 14:18:09 +00:00
|
|
|
!!submodules_.transient_suppressor);
|
2015-08-14 10:35:55 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-02 15:15:36 +01:00
|
|
|
void AudioProcessingImpl::InitializeTransientSuppressor() {
|
2023-01-16 20:19:48 +01:00
|
|
|
// Choose the VAD mode for TS and detect a VAD mode change.
|
|
|
|
|
const TransientSuppressor::VadMode previous_vad_mode =
|
|
|
|
|
transient_suppressor_vad_mode_;
|
|
|
|
|
transient_suppressor_vad_mode_ = TransientSuppressor::VadMode::kDefault;
|
|
|
|
|
if (UseApmVadSubModule(config_, gain_controller2_experiment_params_)) {
|
|
|
|
|
transient_suppressor_vad_mode_ = TransientSuppressor::VadMode::kRnnVad;
|
|
|
|
|
}
|
|
|
|
|
const bool vad_mode_changed =
|
|
|
|
|
previous_vad_mode != transient_suppressor_vad_mode_;
|
|
|
|
|
|
2021-05-18 12:17:56 +02:00
|
|
|
if (config_.transient_suppression.enabled &&
|
|
|
|
|
!constants_.transient_suppressor_forced_off) {
|
2020-04-01 15:24:40 +02:00
|
|
|
// Attempt to create a transient suppressor, if one is not already created.
|
2023-01-16 20:19:48 +01:00
|
|
|
if (!submodules_.transient_suppressor || vad_mode_changed) {
|
2022-03-18 12:39:00 +01:00
|
|
|
submodules_.transient_suppressor = CreateTransientSuppressor(
|
2022-04-08 09:54:27 +02:00
|
|
|
submodule_creation_overrides_, transient_suppressor_vad_mode_,
|
2020-04-01 15:24:40 +02:00
|
|
|
proc_fullband_sample_rate_hz(), capture_nonlocked_.split_rate,
|
|
|
|
|
num_proc_channels());
|
2022-04-08 09:54:27 +02:00
|
|
|
if (!submodules_.transient_suppressor) {
|
|
|
|
|
RTC_LOG(LS_WARNING)
|
|
|
|
|
<< "No transient suppressor created (probably disabled)";
|
|
|
|
|
}
|
2020-04-01 15:24:40 +02:00
|
|
|
} else {
|
2022-04-08 09:54:27 +02:00
|
|
|
submodules_.transient_suppressor->Initialize(
|
|
|
|
|
proc_fullband_sample_rate_hz(), capture_nonlocked_.split_rate,
|
|
|
|
|
num_proc_channels());
|
2014-12-15 09:41:24 +00:00
|
|
|
}
|
2020-01-02 15:15:36 +01:00
|
|
|
} else {
|
|
|
|
|
submodules_.transient_suppressor.reset();
|
2014-12-15 09:41:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-03 14:27:14 +01:00
|
|
|
void AudioProcessingImpl::InitializeHighPassFilter(bool forced_reset) {
|
2019-12-04 08:34:12 +01:00
|
|
|
bool high_pass_filter_needed_by_aec =
|
|
|
|
|
config_.echo_canceller.enabled &&
|
|
|
|
|
config_.echo_canceller.enforce_high_pass_filtering &&
|
|
|
|
|
!config_.echo_canceller.mobile_mode;
|
|
|
|
|
if (submodule_states_.HighPassFilteringRequired() ||
|
|
|
|
|
high_pass_filter_needed_by_aec) {
|
2019-12-10 13:04:15 +01:00
|
|
|
bool use_full_band = config_.high_pass_filter.apply_in_full_band &&
|
|
|
|
|
!constants_.enforce_split_band_hpf;
|
|
|
|
|
int rate = use_full_band ? proc_fullband_sample_rate_hz()
|
|
|
|
|
: proc_split_sample_rate_hz();
|
|
|
|
|
size_t num_channels =
|
|
|
|
|
use_full_band ? num_output_channels() : num_proc_channels();
|
|
|
|
|
|
2020-01-03 14:27:14 +01:00
|
|
|
if (!submodules_.high_pass_filter ||
|
|
|
|
|
rate != submodules_.high_pass_filter->sample_rate_hz() ||
|
|
|
|
|
forced_reset ||
|
|
|
|
|
num_channels != submodules_.high_pass_filter->num_channels()) {
|
|
|
|
|
submodules_.high_pass_filter.reset(
|
|
|
|
|
new HighPassFilter(rate, num_channels));
|
|
|
|
|
}
|
2016-11-22 07:24:52 -08:00
|
|
|
} else {
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.high_pass_filter.reset();
|
2016-11-22 07:24:52 -08:00
|
|
|
}
|
|
|
|
|
}
|
2017-05-22 06:57:06 -07:00
|
|
|
|
2017-10-14 08:28:46 +02:00
|
|
|
void AudioProcessingImpl::InitializeEchoController() {
|
2019-04-29 12:14:50 +02:00
|
|
|
bool use_echo_controller =
|
|
|
|
|
echo_control_factory_ ||
|
2019-12-09 10:18:44 +01:00
|
|
|
(config_.echo_canceller.enabled && !config_.echo_canceller.mobile_mode);
|
2019-04-29 12:14:50 +02:00
|
|
|
|
|
|
|
|
if (use_echo_controller) {
|
|
|
|
|
// Create and activate the echo controller.
|
2019-03-06 04:16:46 +01:00
|
|
|
if (echo_control_factory_) {
|
2019-11-01 20:44:11 +01:00
|
|
|
submodules_.echo_controller = echo_control_factory_->Create(
|
|
|
|
|
proc_sample_rate_hz(), num_reverse_channels(), num_proc_channels());
|
2019-11-07 17:15:12 +01:00
|
|
|
RTC_DCHECK(submodules_.echo_controller);
|
2019-03-06 04:16:46 +01:00
|
|
|
} else {
|
2022-04-07 15:28:14 +02:00
|
|
|
EchoCanceller3Config config;
|
|
|
|
|
absl::optional<EchoCanceller3Config> multichannel_config;
|
|
|
|
|
if (use_setup_specific_default_aec3_config_) {
|
|
|
|
|
multichannel_config = EchoCanceller3::CreateDefaultMultichannelConfig();
|
|
|
|
|
}
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_controller = std::make_unique<EchoCanceller3>(
|
2022-04-07 15:28:14 +02:00
|
|
|
config, multichannel_config, proc_sample_rate_hz(),
|
|
|
|
|
num_reverse_channels(), num_proc_channels());
|
2019-03-06 04:16:46 +01:00
|
|
|
}
|
|
|
|
|
|
2019-11-13 11:12:29 +01:00
|
|
|
// Setup the storage for returning the linear AEC output.
|
|
|
|
|
if (config_.echo_canceller.export_linear_aec_output) {
|
|
|
|
|
constexpr int kLinearOutputRateHz = 16000;
|
|
|
|
|
capture_.linear_aec_output = std::make_unique<AudioBuffer>(
|
|
|
|
|
kLinearOutputRateHz, num_proc_channels(), kLinearOutputRateHz,
|
|
|
|
|
num_proc_channels(), kLinearOutputRateHz, num_proc_channels());
|
|
|
|
|
} else {
|
|
|
|
|
capture_.linear_aec_output.reset();
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 04:16:46 +01:00
|
|
|
capture_nonlocked_.echo_controller_enabled = true;
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_control_mobile.reset();
|
2019-04-29 12:14:50 +02:00
|
|
|
aecm_render_signal_queue_.reset();
|
2019-04-25 15:18:06 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_controller.reset();
|
2019-04-25 15:18:06 +02:00
|
|
|
capture_nonlocked_.echo_controller_enabled = false;
|
2019-11-13 11:12:29 +01:00
|
|
|
capture_.linear_aec_output.reset();
|
2019-04-25 15:18:06 +02:00
|
|
|
|
|
|
|
|
if (!config_.echo_canceller.enabled) {
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_control_mobile.reset();
|
2019-04-29 12:14:50 +02:00
|
|
|
aecm_render_signal_queue_.reset();
|
2019-04-25 15:18:06 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2019-03-06 04:16:46 +01:00
|
|
|
|
2019-04-25 15:18:06 +02:00
|
|
|
if (config_.echo_canceller.mobile_mode) {
|
|
|
|
|
// Create and activate AECM.
|
2019-04-29 12:14:50 +02:00
|
|
|
size_t max_element_size =
|
|
|
|
|
std::max(static_cast<size_t>(1),
|
|
|
|
|
kMaxAllowedValuesOfSamplesPerBand *
|
|
|
|
|
EchoControlMobileImpl::NumCancellersRequired(
|
|
|
|
|
num_output_channels(), num_reverse_channels()));
|
|
|
|
|
|
|
|
|
|
std::vector<int16_t> template_queue_element(max_element_size);
|
|
|
|
|
|
|
|
|
|
aecm_render_signal_queue_.reset(
|
|
|
|
|
new SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>(
|
|
|
|
|
kMaxNumFramesToBuffer, template_queue_element,
|
|
|
|
|
RenderQueueItemVerifier<int16_t>(max_element_size)));
|
|
|
|
|
|
|
|
|
|
aecm_render_queue_buffer_.resize(max_element_size);
|
|
|
|
|
aecm_capture_queue_buffer_.resize(max_element_size);
|
|
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_control_mobile.reset(new EchoControlMobileImpl());
|
2019-04-29 12:14:50 +02:00
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_control_mobile->Initialize(proc_split_sample_rate_hz(),
|
|
|
|
|
num_reverse_channels(),
|
|
|
|
|
num_output_channels());
|
2019-04-25 15:18:06 +02:00
|
|
|
return;
|
2016-12-14 01:16:23 -08:00
|
|
|
}
|
2019-04-25 15:18:06 +02:00
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_control_mobile.reset();
|
2019-04-29 12:14:50 +02:00
|
|
|
aecm_render_signal_queue_.reset();
|
2016-12-14 01:16:23 -08:00
|
|
|
}
|
2016-11-22 07:24:52 -08:00
|
|
|
|
2020-01-13 14:43:13 +01:00
|
|
|
void AudioProcessingImpl::InitializeGainController1() {
|
2022-11-30 15:16:21 +01:00
|
|
|
if (config_.gain_controller2.enabled &&
|
|
|
|
|
config_.gain_controller2.input_volume_controller.enabled &&
|
|
|
|
|
config_.gain_controller1.enabled &&
|
|
|
|
|
(config_.gain_controller1.mode ==
|
|
|
|
|
AudioProcessing::Config::GainController1::kAdaptiveAnalog ||
|
|
|
|
|
config_.gain_controller1.analog_gain_controller.enabled)) {
|
|
|
|
|
RTC_LOG(LS_ERROR) << "APM configuration not valid: "
|
|
|
|
|
<< "Multiple input volume controllers enabled.";
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-13 14:43:13 +01:00
|
|
|
if (!config_.gain_controller1.enabled) {
|
|
|
|
|
submodules_.agc_manager.reset();
|
|
|
|
|
submodules_.gain_control.reset();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-05 16:04:31 +02:00
|
|
|
RTC_HISTOGRAM_BOOLEAN(
|
|
|
|
|
"WebRTC.Audio.GainController.Analog.Enabled",
|
|
|
|
|
config_.gain_controller1.analog_gain_controller.enabled);
|
|
|
|
|
|
2020-01-13 14:43:13 +01:00
|
|
|
if (!submodules_.gain_control) {
|
|
|
|
|
submodules_.gain_control.reset(new GainControlImpl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
submodules_.gain_control->Initialize(num_proc_channels(),
|
|
|
|
|
proc_sample_rate_hz());
|
|
|
|
|
if (!config_.gain_controller1.analog_gain_controller.enabled) {
|
|
|
|
|
int error = submodules_.gain_control->set_mode(
|
|
|
|
|
Agc1ConfigModeToInterfaceMode(config_.gain_controller1.mode));
|
|
|
|
|
RTC_DCHECK_EQ(kNoError, error);
|
|
|
|
|
error = submodules_.gain_control->set_target_level_dbfs(
|
|
|
|
|
config_.gain_controller1.target_level_dbfs);
|
|
|
|
|
RTC_DCHECK_EQ(kNoError, error);
|
|
|
|
|
error = submodules_.gain_control->set_compression_gain_db(
|
|
|
|
|
config_.gain_controller1.compression_gain_db);
|
|
|
|
|
RTC_DCHECK_EQ(kNoError, error);
|
|
|
|
|
error = submodules_.gain_control->enable_limiter(
|
|
|
|
|
config_.gain_controller1.enable_limiter);
|
|
|
|
|
RTC_DCHECK_EQ(kNoError, error);
|
2021-11-02 11:02:48 +01:00
|
|
|
constexpr int kAnalogLevelMinimum = 0;
|
|
|
|
|
constexpr int kAnalogLevelMaximum = 255;
|
2020-01-13 14:43:13 +01:00
|
|
|
error = submodules_.gain_control->set_analog_level_limits(
|
2021-11-02 11:02:48 +01:00
|
|
|
kAnalogLevelMinimum, kAnalogLevelMaximum);
|
2020-01-13 14:43:13 +01:00
|
|
|
RTC_DCHECK_EQ(kNoError, error);
|
|
|
|
|
|
|
|
|
|
submodules_.agc_manager.reset();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!submodules_.agc_manager.get() ||
|
|
|
|
|
submodules_.agc_manager->num_channels() !=
|
2022-02-03 16:30:25 +01:00
|
|
|
static_cast<int>(num_proc_channels())) {
|
2020-01-13 14:43:13 +01:00
|
|
|
int stream_analog_level = -1;
|
|
|
|
|
const bool re_creation = !!submodules_.agc_manager;
|
|
|
|
|
if (re_creation) {
|
2022-09-05 16:04:31 +02:00
|
|
|
stream_analog_level = submodules_.agc_manager->recommended_analog_level();
|
2020-01-13 14:43:13 +01:00
|
|
|
}
|
|
|
|
|
submodules_.agc_manager.reset(new AgcManagerDirect(
|
2022-07-19 12:18:38 +02:00
|
|
|
num_proc_channels(), config_.gain_controller1.analog_gain_controller));
|
2020-01-13 14:43:13 +01:00
|
|
|
if (re_creation) {
|
|
|
|
|
submodules_.agc_manager->set_stream_analog_level(stream_analog_level);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
submodules_.agc_manager->Initialize();
|
2022-07-19 12:18:38 +02:00
|
|
|
submodules_.agc_manager->SetupDigitalGainControl(*submodules_.gain_control);
|
2021-02-09 08:47:51 +01:00
|
|
|
submodules_.agc_manager->HandleCaptureOutputUsedChange(
|
|
|
|
|
capture_.capture_output_used);
|
2020-01-13 14:43:13 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-16 20:19:48 +01:00
|
|
|
void AudioProcessingImpl::InitializeGainController2() {
|
2021-10-14 12:14:21 +02:00
|
|
|
if (!config_.gain_controller2.enabled) {
|
2020-01-03 10:36:34 +01:00
|
|
|
submodules_.gain_controller2.reset();
|
2021-10-14 12:14:21 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2023-01-16 20:19:48 +01:00
|
|
|
// Override the input volume controller configuration if the AGC2 experiment
|
|
|
|
|
// is running and its parameters require to fully switch the gain control to
|
|
|
|
|
// AGC2.
|
|
|
|
|
const bool input_volume_controller_config_overridden =
|
|
|
|
|
gain_controller2_experiment_params_.has_value() &&
|
|
|
|
|
gain_controller2_experiment_params_->agc2_config.has_value();
|
|
|
|
|
const InputVolumeController::Config input_volume_controller_config =
|
|
|
|
|
input_volume_controller_config_overridden
|
|
|
|
|
? gain_controller2_experiment_params_->agc2_config
|
|
|
|
|
->input_volume_controller
|
|
|
|
|
: InputVolumeController::Config{};
|
|
|
|
|
// If the APM VAD sub-module is not used, let AGC2 use its internal VAD.
|
|
|
|
|
const bool use_internal_vad =
|
|
|
|
|
!UseApmVadSubModule(config_, gain_controller2_experiment_params_);
|
|
|
|
|
submodules_.gain_controller2 = std::make_unique<GainController2>(
|
|
|
|
|
config_.gain_controller2, input_volume_controller_config,
|
|
|
|
|
proc_fullband_sample_rate_hz(), num_proc_channels(), use_internal_vad);
|
|
|
|
|
submodules_.gain_controller2->SetCaptureOutputUsed(
|
|
|
|
|
capture_.capture_output_used);
|
2022-06-16 16:35:45 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-16 20:19:48 +01:00
|
|
|
void AudioProcessingImpl::InitializeVoiceActivityDetector() {
|
|
|
|
|
if (!UseApmVadSubModule(config_, gain_controller2_experiment_params_)) {
|
2022-06-16 16:35:45 +02:00
|
|
|
submodules_.voice_activity_detector.reset();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-01-16 20:19:48 +01:00
|
|
|
|
|
|
|
|
if (!submodules_.voice_activity_detector) {
|
2022-06-16 16:35:45 +02:00
|
|
|
RTC_DCHECK(!!submodules_.gain_controller2);
|
|
|
|
|
// TODO(bugs.webrtc.org/13663): Cache CPU features in APM and use here.
|
|
|
|
|
submodules_.voice_activity_detector =
|
|
|
|
|
std::make_unique<VoiceActivityDetectorWrapper>(
|
|
|
|
|
submodules_.gain_controller2->GetCpuFeatures(),
|
|
|
|
|
proc_fullband_sample_rate_hz());
|
2023-01-16 20:19:48 +01:00
|
|
|
} else {
|
|
|
|
|
submodules_.voice_activity_detector->Initialize(
|
|
|
|
|
proc_fullband_sample_rate_hz());
|
2017-05-22 06:57:06 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-16 11:46:11 +02:00
|
|
|
void AudioProcessingImpl::InitializeNoiseSuppressor() {
|
2019-10-29 22:59:44 +01:00
|
|
|
submodules_.noise_suppressor.reset();
|
|
|
|
|
|
2019-10-16 11:46:11 +02:00
|
|
|
if (config_.noise_suppression.enabled) {
|
2020-04-01 15:24:40 +02:00
|
|
|
auto map_level =
|
|
|
|
|
[](AudioProcessing::Config::NoiseSuppression::Level level) {
|
|
|
|
|
using NoiseSuppresionConfig =
|
|
|
|
|
AudioProcessing::Config::NoiseSuppression;
|
|
|
|
|
switch (level) {
|
|
|
|
|
case NoiseSuppresionConfig::kLow:
|
|
|
|
|
return NsConfig::SuppressionLevel::k6dB;
|
|
|
|
|
case NoiseSuppresionConfig::kModerate:
|
|
|
|
|
return NsConfig::SuppressionLevel::k12dB;
|
|
|
|
|
case NoiseSuppresionConfig::kHigh:
|
|
|
|
|
return NsConfig::SuppressionLevel::k18dB;
|
|
|
|
|
case NoiseSuppresionConfig::kVeryHigh:
|
|
|
|
|
return NsConfig::SuppressionLevel::k21dB;
|
|
|
|
|
}
|
2020-11-08 00:49:37 +01:00
|
|
|
RTC_CHECK_NOTREACHED();
|
2020-04-01 15:24:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
NsConfig cfg;
|
|
|
|
|
cfg.target_level = map_level(config_.noise_suppression.level);
|
|
|
|
|
submodules_.noise_suppressor = std::make_unique<NoiseSuppressor>(
|
|
|
|
|
cfg, proc_sample_rate_hz(), num_proc_channels());
|
2019-10-16 11:46:11 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 16:31:04 +00:00
|
|
|
void AudioProcessingImpl::InitializeCaptureLevelsAdjuster() {
|
|
|
|
|
if (config_.pre_amplifier.enabled ||
|
|
|
|
|
config_.capture_level_adjustment.enabled) {
|
|
|
|
|
// Use both the pre-amplifier and the capture level adjustment gains as
|
|
|
|
|
// pre-gains.
|
|
|
|
|
float pre_gain = 1.f;
|
|
|
|
|
if (config_.pre_amplifier.enabled) {
|
|
|
|
|
pre_gain *= config_.pre_amplifier.fixed_gain_factor;
|
|
|
|
|
}
|
|
|
|
|
if (config_.capture_level_adjustment.enabled) {
|
|
|
|
|
pre_gain *= config_.capture_level_adjustment.pre_gain_factor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
submodules_.capture_levels_adjuster =
|
|
|
|
|
std::make_unique<CaptureLevelsAdjuster>(
|
|
|
|
|
config_.capture_level_adjustment.analog_mic_gain_emulation.enabled,
|
|
|
|
|
config_.capture_level_adjustment.analog_mic_gain_emulation
|
|
|
|
|
.initial_level,
|
|
|
|
|
pre_gain, config_.capture_level_adjustment.post_gain_factor);
|
2018-04-16 16:31:22 +02:00
|
|
|
} else {
|
2021-03-15 16:31:04 +00:00
|
|
|
submodules_.capture_levels_adjuster.reset();
|
2018-04-16 16:31:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 05:39:16 -07:00
|
|
|
void AudioProcessingImpl::InitializeResidualEchoDetector() {
|
2021-12-06 15:40:04 +01:00
|
|
|
if (submodules_.echo_detector) {
|
|
|
|
|
submodules_.echo_detector->Initialize(
|
|
|
|
|
proc_fullband_sample_rate_hz(), 1,
|
|
|
|
|
formats_.render_processing_format.sample_rate_hz(), 1);
|
|
|
|
|
}
|
2016-10-28 05:39:16 -07:00
|
|
|
}
|
|
|
|
|
|
2018-08-29 10:37:09 +02:00
|
|
|
void AudioProcessingImpl::InitializeAnalyzer() {
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.capture_analyzer) {
|
|
|
|
|
submodules_.capture_analyzer->Initialize(proc_fullband_sample_rate_hz(),
|
|
|
|
|
num_proc_channels());
|
2018-08-29 10:37:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-25 12:04:02 +02:00
|
|
|
void AudioProcessingImpl::InitializePostProcessor() {
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.capture_post_processor) {
|
|
|
|
|
submodules_.capture_post_processor->Initialize(
|
2019-10-09 13:02:14 +02:00
|
|
|
proc_fullband_sample_rate_hz(), num_proc_channels());
|
2017-09-25 12:04:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-18 16:02:40 +01:00
|
|
|
void AudioProcessingImpl::InitializePreProcessor() {
|
2019-10-18 13:29:43 +02:00
|
|
|
if (submodules_.render_pre_processor) {
|
|
|
|
|
submodules_.render_pre_processor->Initialize(
|
2017-12-18 16:02:40 +01:00
|
|
|
formats_.render_processing_format.sample_rate_hz(),
|
|
|
|
|
formats_.render_processing_format.num_channels());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
void AudioProcessingImpl::WriteAecDumpConfigMessage(bool forced) {
|
|
|
|
|
if (!aec_dump_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-25 15:18:06 +02:00
|
|
|
|
|
|
|
|
std::string experiments_description = "";
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
// TODO(peah): Add semicolon-separated concatenations of experiment
|
|
|
|
|
// descriptions for other submodules.
|
2020-02-18 14:50:28 +01:00
|
|
|
if (!!submodules_.capture_post_processor) {
|
|
|
|
|
experiments_description += "CapturePostProcessor;";
|
|
|
|
|
}
|
|
|
|
|
if (!!submodules_.render_pre_processor) {
|
|
|
|
|
experiments_description += "RenderPreProcessor;";
|
|
|
|
|
}
|
2017-10-16 13:49:04 +02:00
|
|
|
if (capture_nonlocked_.echo_controller_enabled) {
|
|
|
|
|
experiments_description += "EchoController;";
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
}
|
2017-10-13 11:05:17 +02:00
|
|
|
if (config_.gain_controller2.enabled) {
|
|
|
|
|
experiments_description += "GainController2;";
|
|
|
|
|
}
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
|
|
|
|
|
InternalAPMConfig apm_config;
|
|
|
|
|
|
2019-03-06 04:16:46 +01:00
|
|
|
apm_config.aec_enabled = config_.echo_canceller.enabled;
|
2019-12-09 10:18:44 +01:00
|
|
|
apm_config.aec_delay_agnostic_enabled = false;
|
|
|
|
|
apm_config.aec_extended_filter_enabled = false;
|
|
|
|
|
apm_config.aec_suppression_level = 0;
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
|
2019-10-18 13:29:43 +02:00
|
|
|
apm_config.aecm_enabled = !!submodules_.echo_control_mobile;
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
apm_config.aecm_comfort_noise_enabled =
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_control_mobile &&
|
|
|
|
|
submodules_.echo_control_mobile->is_comfort_noise_enabled();
|
2019-04-29 12:14:50 +02:00
|
|
|
apm_config.aecm_routing_mode =
|
2019-10-18 13:29:43 +02:00
|
|
|
submodules_.echo_control_mobile
|
|
|
|
|
? static_cast<int>(submodules_.echo_control_mobile->routing_mode())
|
2019-04-29 12:14:50 +02:00
|
|
|
: 0;
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
|
2020-01-13 14:43:13 +01:00
|
|
|
apm_config.agc_enabled = !!submodules_.gain_control;
|
|
|
|
|
|
|
|
|
|
apm_config.agc_mode = submodules_.gain_control
|
|
|
|
|
? static_cast<int>(submodules_.gain_control->mode())
|
|
|
|
|
: GainControl::kAdaptiveAnalog;
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
apm_config.agc_limiter_enabled =
|
2020-01-13 14:43:13 +01:00
|
|
|
submodules_.gain_control ? submodules_.gain_control->is_limiter_enabled()
|
|
|
|
|
: false;
|
2019-11-18 08:52:22 +01:00
|
|
|
apm_config.noise_robust_agc_enabled = !!submodules_.agc_manager;
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
|
|
|
|
|
apm_config.hpf_enabled = config_.high_pass_filter.enabled;
|
|
|
|
|
|
2019-10-16 11:46:11 +02:00
|
|
|
apm_config.ns_enabled = config_.noise_suppression.enabled;
|
|
|
|
|
apm_config.ns_level = static_cast<int>(config_.noise_suppression.level);
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
|
|
|
|
|
apm_config.transient_suppression_enabled =
|
2020-01-02 15:15:36 +01:00
|
|
|
config_.transient_suppression.enabled;
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
apm_config.experiments_description = experiments_description;
|
2018-04-16 13:52:32 +02:00
|
|
|
apm_config.pre_amplifier_enabled = config_.pre_amplifier.enabled;
|
|
|
|
|
apm_config.pre_amplifier_fixed_gain_factor =
|
|
|
|
|
config_.pre_amplifier.fixed_gain_factor;
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
|
|
|
|
|
if (!forced && apm_config == apm_config_for_aec_dump_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
aec_dump_->WriteConfig(apm_config);
|
|
|
|
|
apm_config_for_aec_dump_ = apm_config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::RecordUnprocessedCaptureStream(
|
|
|
|
|
const float* const* src) {
|
|
|
|
|
RTC_DCHECK(aec_dump_);
|
|
|
|
|
WriteAecDumpConfigMessage(false);
|
|
|
|
|
|
|
|
|
|
const size_t channel_size = formats_.api_format.input_stream().num_frames();
|
|
|
|
|
const size_t num_channels = formats_.api_format.input_stream().num_channels();
|
|
|
|
|
aec_dump_->AddCaptureStreamInput(
|
2018-02-16 11:54:07 +01:00
|
|
|
AudioFrameView<const float>(src, num_channels, channel_size));
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
RecordAudioProcessingState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::RecordUnprocessedCaptureStream(
|
2020-03-16 12:06:02 +01:00
|
|
|
const int16_t* const data,
|
|
|
|
|
const StreamConfig& config) {
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
RTC_DCHECK(aec_dump_);
|
|
|
|
|
WriteAecDumpConfigMessage(false);
|
|
|
|
|
|
2020-03-16 12:06:02 +01:00
|
|
|
aec_dump_->AddCaptureStreamInput(data, config.num_channels(),
|
|
|
|
|
config.num_frames());
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
RecordAudioProcessingState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::RecordProcessedCaptureStream(
|
|
|
|
|
const float* const* processed_capture_stream) {
|
|
|
|
|
RTC_DCHECK(aec_dump_);
|
|
|
|
|
|
|
|
|
|
const size_t channel_size = formats_.api_format.output_stream().num_frames();
|
|
|
|
|
const size_t num_channels =
|
|
|
|
|
formats_.api_format.output_stream().num_channels();
|
2018-02-16 11:54:07 +01:00
|
|
|
aec_dump_->AddCaptureStreamOutput(AudioFrameView<const float>(
|
|
|
|
|
processed_capture_stream, num_channels, channel_size));
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
aec_dump_->WriteCaptureStreamMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::RecordProcessedCaptureStream(
|
2020-03-16 12:06:02 +01:00
|
|
|
const int16_t* const data,
|
|
|
|
|
const StreamConfig& config) {
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
RTC_DCHECK(aec_dump_);
|
|
|
|
|
|
2020-03-16 12:06:02 +01:00
|
|
|
aec_dump_->AddCaptureStreamOutput(data, config.num_channels(),
|
2020-03-18 21:59:52 +01:00
|
|
|
config.num_frames());
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
aec_dump_->WriteCaptureStreamMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::RecordAudioProcessingState() {
|
|
|
|
|
RTC_DCHECK(aec_dump_);
|
|
|
|
|
AecDump::AudioProcessingState audio_proc_state;
|
|
|
|
|
audio_proc_state.delay = capture_nonlocked_.stream_delay_ms;
|
2019-12-09 10:18:44 +01:00
|
|
|
audio_proc_state.drift = 0;
|
2022-09-07 17:14:26 +02:00
|
|
|
audio_proc_state.applied_input_volume = capture_.applied_input_volume;
|
AudioProcessingModule has a feature to make a recording of its
configuration, inputs and outputs over a period of time. It is
activated by AudioProcessing::StartRecording. The data is stored in
binary protobuf format in a specified file. The file IO is, as of
this CL, done from the real-time audio thread.
This CL contains an interface for AecDump, a new APM submodule that
will handle the recordings. Calls to the new interface from the
AudioProcessingModule are added. These calls have no effect, and for a
short while, audio_processing_impl.cc will contain two copies of
recording calls.
The original calls are guarded by the WEBRTC_AUDIOPROC_DEBUG_DUMP
preprocessor define. They still have an effect, while the new ones do
not. In the following CLs, the old recording calls will be removed,
and an implementation of AecDump added.
The reasons for the refactoring is to move file IO operations from the
real-time audio thread, to add a top-level low-priority task queue for
logging tasks like this, to simplify and modularize audio_processing_impl.cc
and remove some of the preprocessor directives. These goals will be
archived by the upcoming CLs. The implementation is in
https://codereview.webrtc.org/2865113002.
BUG=webrtc:7404
Review-Url: https://codereview.webrtc.org/2778783002
Cr-Commit-Position: refs/heads/master@{#18233}
2017-05-23 07:20:05 -07:00
|
|
|
audio_proc_state.keypress = capture_.key_pressed;
|
|
|
|
|
aec_dump_->AddAudioProcessingState(audio_proc_state);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-02 15:15:36 +01:00
|
|
|
AudioProcessingImpl::ApmCaptureState::ApmCaptureState()
|
2020-01-17 10:55:09 +01:00
|
|
|
: was_stream_delay_set(false),
|
2021-02-09 08:47:51 +01:00
|
|
|
capture_output_used(true),
|
2021-03-12 14:18:36 +00:00
|
|
|
capture_output_used_last_frame(true),
|
2016-08-29 14:46:07 -07:00
|
|
|
key_pressed(false),
|
2016-09-16 15:02:15 -07:00
|
|
|
capture_processing_format(kSampleRate16kHz),
|
2017-04-10 14:12:41 -07:00
|
|
|
split_rate(kSampleRate16kHz),
|
2018-07-16 17:08:41 +02:00
|
|
|
echo_path_gain_change(false),
|
2022-09-07 17:14:26 +02:00
|
|
|
prev_pre_adjustment_gain(-1.0f),
|
2019-05-10 15:50:02 +02:00
|
|
|
playout_volume(-1),
|
2022-09-07 17:14:26 +02:00
|
|
|
prev_playout_volume(-1),
|
|
|
|
|
applied_input_volume_changed(false) {}
|
2016-08-29 14:46:07 -07:00
|
|
|
|
|
|
|
|
AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default;
|
|
|
|
|
|
|
|
|
|
AudioProcessingImpl::ApmRenderState::ApmRenderState() = default;
|
|
|
|
|
|
|
|
|
|
AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default;
|
|
|
|
|
|
2019-12-30 14:32:14 +01:00
|
|
|
AudioProcessingImpl::ApmStatsReporter::ApmStatsReporter()
|
|
|
|
|
: stats_message_queue_(1) {}
|
|
|
|
|
|
|
|
|
|
AudioProcessingImpl::ApmStatsReporter::~ApmStatsReporter() = default;
|
|
|
|
|
|
|
|
|
|
AudioProcessingStats AudioProcessingImpl::ApmStatsReporter::GetStatistics() {
|
2020-07-07 15:53:34 +02:00
|
|
|
MutexLock lock_stats(&mutex_stats_);
|
2019-12-30 14:32:14 +01:00
|
|
|
bool new_stats_available = stats_message_queue_.Remove(&cached_stats_);
|
|
|
|
|
// If the message queue is full, return the cached stats.
|
|
|
|
|
static_cast<void>(new_stats_available);
|
|
|
|
|
|
|
|
|
|
return cached_stats_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AudioProcessingImpl::ApmStatsReporter::UpdateStatistics(
|
|
|
|
|
const AudioProcessingStats& new_stats) {
|
|
|
|
|
AudioProcessingStats stats_to_queue = new_stats;
|
|
|
|
|
bool stats_message_passed = stats_message_queue_.Insert(&stats_to_queue);
|
|
|
|
|
// If the message queue is full, discard the new stats.
|
|
|
|
|
static_cast<void>(stats_message_passed);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
} // namespace webrtc
|