mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 22:00:47 +01:00
AGC2 Input Volume Controller: min input volume field trial update
Always enforce the minimum input volume, not only if overridden. The only exception is when the applied input volume is zero: in that case zero is still recommended. This CL also adapts the unit tests and replaces "mic level" with the "input volume". Bug: webrtc:7494 Change-Id: I20c14624fbd357ab91ea05521c3723ec1045a8db Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285462 Reviewed-by: Hanna Silen <silen@webrtc.org> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38769}
This commit is contained in:
parent
8b47ea459e
commit
03bccbe62d
3 changed files with 76 additions and 93 deletions
|
@ -32,7 +32,6 @@ constexpr int kLevelQuantizationSlack = 25;
|
||||||
|
|
||||||
constexpr int kMaxMicLevel = 255;
|
constexpr int kMaxMicLevel = 255;
|
||||||
static_assert(kGainMapSize > kMaxMicLevel, "gain map too small");
|
static_assert(kGainMapSize > kMaxMicLevel, "gain map too small");
|
||||||
constexpr int kMinMicLevel = 12;
|
|
||||||
|
|
||||||
// Prevent very large microphone level changes.
|
// Prevent very large microphone level changes.
|
||||||
constexpr int kMaxResidualGainChange = 15;
|
constexpr int kMaxResidualGainChange = 15;
|
||||||
|
@ -49,31 +48,29 @@ Agc1ClippingPredictorConfig CreateClippingPredictorConfig(bool enabled) {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the "WebRTC-Audio-2ndAgcMinMicLevelExperiment" field trial is specified,
|
// Returns the minimum input volume to recommend.
|
||||||
// parses it and returns a value between 0 and 255 depending on the field-trial
|
// If the "WebRTC-Audio-Agc2-MinInputVolume" field trial is specified, parses it
|
||||||
// string. Returns an unspecified value if the field trial is not specified, if
|
// and returns the value specified after "Enabled-" if valid - i.e., in the
|
||||||
// disabled or if it cannot be parsed. Example:
|
// range 0-255. Otherwise returns the default value.
|
||||||
// 'WebRTC-Audio-2ndAgcMinMicLevelExperiment/Enabled-80' => returns 80.
|
// Example:
|
||||||
absl::optional<int> GetMinMicLevelOverride() {
|
// "WebRTC-Audio-Agc2-MinInputVolume/Enabled-80" => returns 80.
|
||||||
constexpr char kMinMicLevelFieldTrial[] =
|
int GetMinInputVolume() {
|
||||||
"WebRTC-Audio-2ndAgcMinMicLevelExperiment";
|
constexpr int kDefaultMinInputVolume = 12;
|
||||||
if (!webrtc::field_trial::IsEnabled(kMinMicLevelFieldTrial)) {
|
constexpr char kFieldTrial[] = "WebRTC-Audio-Agc2-MinInputVolume";
|
||||||
return absl::nullopt;
|
if (!webrtc::field_trial::IsEnabled(kFieldTrial)) {
|
||||||
|
return kDefaultMinInputVolume;
|
||||||
}
|
}
|
||||||
const auto field_trial_string =
|
std::string field_trial_str = webrtc::field_trial::FindFullName(kFieldTrial);
|
||||||
webrtc::field_trial::FindFullName(kMinMicLevelFieldTrial);
|
int min_input_volume = -1;
|
||||||
int min_mic_level = -1;
|
sscanf(field_trial_str.c_str(), "Enabled-%d", &min_input_volume);
|
||||||
sscanf(field_trial_string.c_str(), "Enabled-%d", &min_mic_level);
|
if (min_input_volume >= 0 && min_input_volume <= 255) {
|
||||||
if (min_mic_level >= 0 && min_mic_level <= 255) {
|
return min_input_volume;
|
||||||
return min_mic_level;
|
|
||||||
} else {
|
|
||||||
RTC_LOG(LS_WARNING) << "[agc] Invalid parameter for "
|
|
||||||
<< kMinMicLevelFieldTrial << ", ignored.";
|
|
||||||
return absl::nullopt;
|
|
||||||
}
|
}
|
||||||
|
RTC_LOG(LS_WARNING) << "Invalid volume for " << kFieldTrial << ", ignored.";
|
||||||
|
return kDefaultMinInputVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelFromGainError(int gain_error, int level, int min_mic_level) {
|
int LevelFromGainError(int gain_error, int level, int min_input_volume) {
|
||||||
RTC_DCHECK_GE(level, 0);
|
RTC_DCHECK_GE(level, 0);
|
||||||
RTC_DCHECK_LE(level, kMaxMicLevel);
|
RTC_DCHECK_LE(level, kMaxMicLevel);
|
||||||
if (gain_error == 0) {
|
if (gain_error == 0) {
|
||||||
|
@ -88,7 +85,7 @@ int LevelFromGainError(int gain_error, int level, int min_mic_level) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (kGainMap[new_level] - kGainMap[level] > gain_error &&
|
while (kGainMap[new_level] - kGainMap[level] > gain_error &&
|
||||||
new_level > min_mic_level) {
|
new_level > min_input_volume) {
|
||||||
--new_level;
|
--new_level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,11 +151,11 @@ int GetSpeechLevelErrorDb(float speech_level_dbfs,
|
||||||
|
|
||||||
MonoInputVolumeController::MonoInputVolumeController(
|
MonoInputVolumeController::MonoInputVolumeController(
|
||||||
int clipped_level_min,
|
int clipped_level_min,
|
||||||
int min_mic_level,
|
int min_input_volume,
|
||||||
int update_input_volume_wait_frames,
|
int update_input_volume_wait_frames,
|
||||||
float speech_probability_threshold,
|
float speech_probability_threshold,
|
||||||
float speech_ratio_threshold)
|
float speech_ratio_threshold)
|
||||||
: min_mic_level_(min_mic_level),
|
: min_input_volume_(min_input_volume),
|
||||||
max_level_(kMaxMicLevel),
|
max_level_(kMaxMicLevel),
|
||||||
clipped_level_min_(clipped_level_min),
|
clipped_level_min_(clipped_level_min),
|
||||||
update_input_volume_wait_frames_(
|
update_input_volume_wait_frames_(
|
||||||
|
@ -167,8 +164,8 @@ MonoInputVolumeController::MonoInputVolumeController(
|
||||||
speech_ratio_threshold_(speech_ratio_threshold) {
|
speech_ratio_threshold_(speech_ratio_threshold) {
|
||||||
RTC_DCHECK_GE(clipped_level_min_, 0);
|
RTC_DCHECK_GE(clipped_level_min_, 0);
|
||||||
RTC_DCHECK_LE(clipped_level_min_, 255);
|
RTC_DCHECK_LE(clipped_level_min_, 255);
|
||||||
RTC_DCHECK_GE(min_mic_level_, 0);
|
RTC_DCHECK_GE(min_input_volume_, 0);
|
||||||
RTC_DCHECK_LE(min_mic_level_, 255);
|
RTC_DCHECK_LE(min_input_volume_, 255);
|
||||||
RTC_DCHECK_GE(update_input_volume_wait_frames_, 0);
|
RTC_DCHECK_GE(update_input_volume_wait_frames_, 0);
|
||||||
RTC_DCHECK_GE(speech_probability_threshold_, 0.0f);
|
RTC_DCHECK_GE(speech_probability_threshold_, 0.0f);
|
||||||
RTC_DCHECK_LE(speech_probability_threshold_, 1.0f);
|
RTC_DCHECK_LE(speech_probability_threshold_, 1.0f);
|
||||||
|
@ -331,8 +328,8 @@ int MonoInputVolumeController::CheckVolumeAndReset() {
|
||||||
}
|
}
|
||||||
RTC_DLOG(LS_INFO) << "[agc] Initial GetMicVolume()=" << level;
|
RTC_DLOG(LS_INFO) << "[agc] Initial GetMicVolume()=" << level;
|
||||||
|
|
||||||
if (level < min_mic_level_) {
|
if (level < min_input_volume_) {
|
||||||
level = min_mic_level_;
|
level = min_input_volume_;
|
||||||
RTC_DLOG(LS_INFO) << "[agc] Initial volume too low, raising to " << level;
|
RTC_DLOG(LS_INFO) << "[agc] Initial volume too low, raising to " << level;
|
||||||
recommended_input_volume_ = level;
|
recommended_input_volume_ = level;
|
||||||
}
|
}
|
||||||
|
@ -357,13 +354,13 @@ void MonoInputVolumeController::UpdateInputVolume(int rms_error_dbfs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLevel(LevelFromGainError(residual_gain, level_, min_mic_level_));
|
SetLevel(LevelFromGainError(residual_gain, level_, min_input_volume_));
|
||||||
}
|
}
|
||||||
|
|
||||||
InputVolumeController::InputVolumeController(int num_capture_channels,
|
InputVolumeController::InputVolumeController(int num_capture_channels,
|
||||||
const Config& config)
|
const Config& config)
|
||||||
: num_capture_channels_(num_capture_channels),
|
: num_capture_channels_(num_capture_channels),
|
||||||
min_mic_level_override_(GetMinMicLevelOverride()),
|
min_input_volume_(GetMinInputVolume()),
|
||||||
capture_output_used_(true),
|
capture_output_used_(true),
|
||||||
clipped_level_step_(config.clipped_level_step),
|
clipped_level_step_(config.clipped_level_step),
|
||||||
clipped_ratio_threshold_(config.clipped_ratio_threshold),
|
clipped_ratio_threshold_(config.clipped_ratio_threshold),
|
||||||
|
@ -381,16 +378,12 @@ InputVolumeController::InputVolumeController(int num_capture_channels,
|
||||||
target_range_max_dbfs_(config.target_range_max_dbfs),
|
target_range_max_dbfs_(config.target_range_max_dbfs),
|
||||||
target_range_min_dbfs_(config.target_range_min_dbfs),
|
target_range_min_dbfs_(config.target_range_min_dbfs),
|
||||||
channel_controllers_(num_capture_channels) {
|
channel_controllers_(num_capture_channels) {
|
||||||
const int min_mic_level = min_mic_level_override_.value_or(kMinMicLevel);
|
RTC_LOG(LS_INFO)
|
||||||
RTC_LOG(LS_INFO) << "[agc] Input volume controller enabled";
|
<< "[agc] Input volume controller enabled (min input volume: "
|
||||||
RTC_LOG(LS_INFO) << "[agc] Min mic level: " << min_mic_level
|
<< min_input_volume_ << ")";
|
||||||
<< " (overridden: "
|
|
||||||
<< (min_mic_level_override_.has_value() ? "yes" : "no")
|
|
||||||
<< ")";
|
|
||||||
|
|
||||||
for (auto& controller : channel_controllers_) {
|
for (auto& controller : channel_controllers_) {
|
||||||
controller = std::make_unique<MonoInputVolumeController>(
|
controller = std::make_unique<MonoInputVolumeController>(
|
||||||
config.clipped_level_min, min_mic_level,
|
config.clipped_level_min, min_input_volume_,
|
||||||
config.update_input_volume_wait_frames,
|
config.update_input_volume_wait_frames,
|
||||||
config.speech_probability_threshold, config.speech_ratio_threshold);
|
config.speech_probability_threshold, config.speech_ratio_threshold);
|
||||||
}
|
}
|
||||||
|
@ -551,9 +544,9 @@ void InputVolumeController::AggregateChannelLevels() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (min_mic_level_override_.has_value() && new_recommended_input_volume > 0) {
|
if (new_recommended_input_volume > 0) {
|
||||||
new_recommended_input_volume =
|
new_recommended_input_volume =
|
||||||
std::max(new_recommended_input_volume, *min_mic_level_override_);
|
std::max(new_recommended_input_volume, min_input_volume_);
|
||||||
}
|
}
|
||||||
|
|
||||||
recommended_input_volume_ = new_recommended_input_volume;
|
recommended_input_volume_ = new_recommended_input_volume;
|
||||||
|
|
|
@ -143,8 +143,8 @@ class InputVolumeController final {
|
||||||
|
|
||||||
const int num_capture_channels_;
|
const int num_capture_channels_;
|
||||||
|
|
||||||
// If not empty, the value is used to override the minimum input volume.
|
// Minimum input volume that can be recommended.
|
||||||
const absl::optional<int> min_mic_level_override_;
|
const int min_input_volume_;
|
||||||
|
|
||||||
// TODO(bugs.webrtc.org/7494): Create a separate member for the applied input
|
// TODO(bugs.webrtc.org/7494): Create a separate member for the applied input
|
||||||
// volume.
|
// volume.
|
||||||
|
@ -220,7 +220,7 @@ class MonoInputVolumeController {
|
||||||
int clipped_level_min() const { return clipped_level_min_; }
|
int clipped_level_min() const { return clipped_level_min_; }
|
||||||
|
|
||||||
// Only used for testing.
|
// Only used for testing.
|
||||||
int min_mic_level() const { return min_mic_level_; }
|
int min_input_volume() const { return min_input_volume_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Sets a new input volume, after first checking that it hasn't been updated
|
// Sets a new input volume, after first checking that it hasn't been updated
|
||||||
|
@ -238,7 +238,7 @@ class MonoInputVolumeController {
|
||||||
// action and cache the updated level.
|
// action and cache the updated level.
|
||||||
void UpdateInputVolume(int rms_error_dbfs);
|
void UpdateInputVolume(int rms_error_dbfs);
|
||||||
|
|
||||||
const int min_mic_level_;
|
const int min_input_volume_;
|
||||||
|
|
||||||
int level_ = 0;
|
int level_ = 0;
|
||||||
int max_level_;
|
int max_level_;
|
||||||
|
|
|
@ -120,34 +120,32 @@ void CallPreProcessAudioBuffer(int num_calls,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr char kMinMicLevelFieldTrial[] =
|
constexpr char kMinInputVolumeFieldTrial[] = "WebRTC-Audio-Agc2-MinInputVolume";
|
||||||
"WebRTC-Audio-2ndAgcMinMicLevelExperiment";
|
|
||||||
|
|
||||||
std::string GetAgcMinMicLevelExperimentFieldTrial(const std::string& value) {
|
std::string GetAgcMinInputVolumeFieldTrial(const std::string& value) {
|
||||||
char field_trial_buffer[64];
|
char field_trial_buffer[64];
|
||||||
rtc::SimpleStringBuilder builder(field_trial_buffer);
|
rtc::SimpleStringBuilder builder(field_trial_buffer);
|
||||||
builder << kMinMicLevelFieldTrial << "/" << value << "/";
|
builder << kMinInputVolumeFieldTrial << "/" << value << "/";
|
||||||
return builder.str();
|
return builder.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetAgcMinMicLevelExperimentFieldTrialEnabled(
|
std::string GetAgcMinInputVolumeFieldTrialEnabled(
|
||||||
int enabled_value,
|
int enabled_value,
|
||||||
const std::string& suffix = "") {
|
const std::string& suffix = "") {
|
||||||
RTC_DCHECK_GE(enabled_value, 0);
|
RTC_DCHECK_GE(enabled_value, 0);
|
||||||
RTC_DCHECK_LE(enabled_value, 255);
|
RTC_DCHECK_LE(enabled_value, 255);
|
||||||
char field_trial_buffer[64];
|
char field_trial_buffer[64];
|
||||||
rtc::SimpleStringBuilder builder(field_trial_buffer);
|
rtc::SimpleStringBuilder builder(field_trial_buffer);
|
||||||
builder << kMinMicLevelFieldTrial << "/Enabled-" << enabled_value << suffix
|
builder << kMinInputVolumeFieldTrial << "/Enabled-" << enabled_value << suffix
|
||||||
<< "/";
|
<< "/";
|
||||||
return builder.str();
|
return builder.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetAgcMinMicLevelExperimentFieldTrial(
|
std::string GetAgcMinInputVolumeFieldTrial(absl::optional<int> volume) {
|
||||||
absl::optional<int> min_mic_level) {
|
if (volume.has_value()) {
|
||||||
if (min_mic_level.has_value()) {
|
return GetAgcMinInputVolumeFieldTrialEnabled(*volume);
|
||||||
return GetAgcMinMicLevelExperimentFieldTrialEnabled(*min_mic_level);
|
|
||||||
}
|
}
|
||||||
return GetAgcMinMicLevelExperimentFieldTrial("Disabled");
|
return GetAgcMinInputVolumeFieldTrial("Disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
// (Over)writes `samples_value` for the samples in `audio_buffer`.
|
// (Over)writes `samples_value` for the samples in `audio_buffer`.
|
||||||
|
@ -382,7 +380,7 @@ class InputVolumeControllerParametrizedTest
|
||||||
: public ::testing::TestWithParam<absl::optional<int>> {
|
: public ::testing::TestWithParam<absl::optional<int>> {
|
||||||
protected:
|
protected:
|
||||||
InputVolumeControllerParametrizedTest()
|
InputVolumeControllerParametrizedTest()
|
||||||
: field_trials_(GetAgcMinMicLevelExperimentFieldTrial(GetParam())) {}
|
: field_trials_(GetAgcMinInputVolumeFieldTrial(GetParam())) {}
|
||||||
|
|
||||||
bool IsMinMicLevelOverridden() const { return GetParam().has_value(); }
|
bool IsMinMicLevelOverridden() const { return GetParam().has_value(); }
|
||||||
int GetMinMicLevel() const { return GetParam().value_or(kMinMicLevel); }
|
int GetMinMicLevel() const { return GetParam().value_or(kMinMicLevel); }
|
||||||
|
@ -573,34 +571,30 @@ TEST_P(InputVolumeControllerParametrizedTest,
|
||||||
EXPECT_EQ(65, helper.manager.recommended_analog_level());
|
EXPECT_EQ(65, helper.manager.recommended_analog_level());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks that, when the min mic level override is not specified, AGC ramps up
|
// Checks that the minimum input volume is enforced during the upward adjustment
|
||||||
// towards the minimum mic level after the mic level is manually set below the
|
// of the input volume.
|
||||||
// minimum gain to enforce.
|
|
||||||
TEST_P(InputVolumeControllerParametrizedTest,
|
TEST_P(InputVolumeControllerParametrizedTest,
|
||||||
RecoveryAfterManualLevelChangeBelowMinWithoutMinMicLevelOverride) {
|
EnforceMinInputVolumeDuringUpwardsAdjustment) {
|
||||||
if (IsMinMicLevelOverridden()) {
|
|
||||||
GTEST_SKIP() << "Skipped. Min mic level overridden.";
|
|
||||||
}
|
|
||||||
|
|
||||||
InputVolumeControllerTestHelper helper;
|
InputVolumeControllerTestHelper helper;
|
||||||
helper.CallAgcSequence(kInitialInputVolume, kHighSpeechProbability,
|
helper.CallAgcSequence(kInitialInputVolume, kHighSpeechProbability,
|
||||||
kSpeechLevel);
|
kSpeechLevel);
|
||||||
|
|
||||||
// Manual change below min, but strictly positive, otherwise AGC won't take
|
// Manual change below min, but strictly positive, otherwise no action will be
|
||||||
// any action.
|
// taken.
|
||||||
helper.manager.set_stream_analog_level(1);
|
helper.manager.set_stream_analog_level(1);
|
||||||
helper.CallProcess(/*num_calls=*/1, kHighSpeechProbability, -17.0f);
|
helper.CallProcess(/*num_calls=*/1, kHighSpeechProbability, -17.0f);
|
||||||
EXPECT_EQ(1, helper.manager.recommended_analog_level());
|
|
||||||
|
|
||||||
// Continues working as usual afterwards.
|
// Trigger an upward adjustment of the input volume.
|
||||||
|
EXPECT_EQ(helper.manager.recommended_analog_level(), GetMinMicLevel());
|
||||||
helper.CallProcess(/*num_calls=*/1, kHighSpeechProbability, -29.0f);
|
helper.CallProcess(/*num_calls=*/1, kHighSpeechProbability, -29.0f);
|
||||||
EXPECT_EQ(1, helper.manager.recommended_analog_level());
|
EXPECT_EQ(helper.manager.recommended_analog_level(), GetMinMicLevel());
|
||||||
|
|
||||||
helper.CallProcess(/*num_calls=*/1, kHighSpeechProbability, -48.0f);
|
helper.CallProcess(/*num_calls=*/1, kHighSpeechProbability, -48.0f);
|
||||||
EXPECT_EQ(10, helper.manager.recommended_analog_level());
|
EXPECT_EQ(helper.manager.recommended_analog_level(), GetMinMicLevel());
|
||||||
|
|
||||||
helper.CallProcess(/*num_calls=*/1, kHighSpeechProbability, -38.0f);
|
// After a number of consistently low speech level observations, the input
|
||||||
EXPECT_EQ(16, helper.manager.recommended_analog_level());
|
// volume is eventually raised above the minimum.
|
||||||
|
helper.CallProcess(/*num_calls=*/10, kHighSpeechProbability, -38.0f);
|
||||||
|
EXPECT_GT(helper.manager.recommended_analog_level(), GetMinMicLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks that, when the min mic level override is specified, AGC immediately
|
// Checks that, when the min mic level override is specified, AGC immediately
|
||||||
|
@ -608,10 +602,6 @@ TEST_P(InputVolumeControllerParametrizedTest,
|
||||||
// minimum gain to enforce.
|
// minimum gain to enforce.
|
||||||
TEST_P(InputVolumeControllerParametrizedTest,
|
TEST_P(InputVolumeControllerParametrizedTest,
|
||||||
RecoveryAfterManualLevelChangeBelowMin) {
|
RecoveryAfterManualLevelChangeBelowMin) {
|
||||||
if (!IsMinMicLevelOverridden()) {
|
|
||||||
GTEST_SKIP() << "Skipped. Min mic level not overridden.";
|
|
||||||
}
|
|
||||||
|
|
||||||
InputVolumeControllerTestHelper helper;
|
InputVolumeControllerTestHelper helper;
|
||||||
helper.CallAgcSequence(kInitialInputVolume, kHighSpeechProbability,
|
helper.CallAgcSequence(kInitialInputVolume, kHighSpeechProbability,
|
||||||
kSpeechLevel);
|
kSpeechLevel);
|
||||||
|
@ -783,18 +773,19 @@ TEST_P(InputVolumeControllerParametrizedTest,
|
||||||
TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentDefault) {
|
TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentDefault) {
|
||||||
std::unique_ptr<InputVolumeController> manager = CreateInputVolumeController(
|
std::unique_ptr<InputVolumeController> manager = CreateInputVolumeController(
|
||||||
kClippedLevelStep, kClippedRatioThreshold, kClippedWaitFrames);
|
kClippedLevelStep, kClippedRatioThreshold, kClippedWaitFrames);
|
||||||
EXPECT_EQ(manager->channel_controllers_[0]->min_mic_level(), kMinMicLevel);
|
EXPECT_EQ(manager->channel_controllers_[0]->min_input_volume(), kMinMicLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentDisabled) {
|
TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentDisabled) {
|
||||||
for (const std::string& field_trial_suffix : {"", "_20220210"}) {
|
for (const std::string& field_trial_suffix : {"", "_20220210"}) {
|
||||||
test::ScopedFieldTrials field_trial(
|
test::ScopedFieldTrials field_trial(
|
||||||
GetAgcMinMicLevelExperimentFieldTrial("Disabled" + field_trial_suffix));
|
GetAgcMinInputVolumeFieldTrial("Disabled" + field_trial_suffix));
|
||||||
std::unique_ptr<InputVolumeController> manager =
|
std::unique_ptr<InputVolumeController> manager =
|
||||||
CreateInputVolumeController(kClippedLevelStep, kClippedRatioThreshold,
|
CreateInputVolumeController(kClippedLevelStep, kClippedRatioThreshold,
|
||||||
kClippedWaitFrames);
|
kClippedWaitFrames);
|
||||||
|
|
||||||
EXPECT_EQ(manager->channel_controllers_[0]->min_mic_level(), kMinMicLevel);
|
EXPECT_EQ(manager->channel_controllers_[0]->min_input_volume(),
|
||||||
|
kMinMicLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,20 +793,20 @@ TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentDisabled) {
|
||||||
// ignored.
|
// ignored.
|
||||||
TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentOutOfRangeAbove) {
|
TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentOutOfRangeAbove) {
|
||||||
test::ScopedFieldTrials field_trial(
|
test::ScopedFieldTrials field_trial(
|
||||||
GetAgcMinMicLevelExperimentFieldTrial("Enabled-256"));
|
GetAgcMinInputVolumeFieldTrial("Enabled-256"));
|
||||||
std::unique_ptr<InputVolumeController> manager = CreateInputVolumeController(
|
std::unique_ptr<InputVolumeController> manager = CreateInputVolumeController(
|
||||||
kClippedLevelStep, kClippedRatioThreshold, kClippedWaitFrames);
|
kClippedLevelStep, kClippedRatioThreshold, kClippedWaitFrames);
|
||||||
EXPECT_EQ(manager->channel_controllers_[0]->min_mic_level(), kMinMicLevel);
|
EXPECT_EQ(manager->channel_controllers_[0]->min_input_volume(), kMinMicLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks that a field-trial parameter outside of the valid range [0,255] is
|
// Checks that a field-trial parameter outside of the valid range [0,255] is
|
||||||
// ignored.
|
// ignored.
|
||||||
TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentOutOfRangeBelow) {
|
TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentOutOfRangeBelow) {
|
||||||
test::ScopedFieldTrials field_trial(
|
test::ScopedFieldTrials field_trial(
|
||||||
GetAgcMinMicLevelExperimentFieldTrial("Enabled--1"));
|
GetAgcMinInputVolumeFieldTrial("Enabled--1"));
|
||||||
std::unique_ptr<InputVolumeController> manager = CreateInputVolumeController(
|
std::unique_ptr<InputVolumeController> manager = CreateInputVolumeController(
|
||||||
kClippedLevelStep, kClippedRatioThreshold, kClippedWaitFrames);
|
kClippedLevelStep, kClippedRatioThreshold, kClippedWaitFrames);
|
||||||
EXPECT_EQ(manager->channel_controllers_[0]->min_mic_level(), kMinMicLevel);
|
EXPECT_EQ(manager->channel_controllers_[0]->min_input_volume(), kMinMicLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verifies that a valid experiment changes the minimum microphone level. The
|
// Verifies that a valid experiment changes the minimum microphone level. The
|
||||||
|
@ -825,14 +816,13 @@ TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentEnabled50) {
|
||||||
constexpr int kMinMicLevelOverride = 50;
|
constexpr int kMinMicLevelOverride = 50;
|
||||||
for (const std::string& field_trial_suffix : {"", "_20220210"}) {
|
for (const std::string& field_trial_suffix : {"", "_20220210"}) {
|
||||||
SCOPED_TRACE(field_trial_suffix);
|
SCOPED_TRACE(field_trial_suffix);
|
||||||
test::ScopedFieldTrials field_trial(
|
test::ScopedFieldTrials field_trial(GetAgcMinInputVolumeFieldTrialEnabled(
|
||||||
GetAgcMinMicLevelExperimentFieldTrialEnabled(kMinMicLevelOverride,
|
kMinMicLevelOverride, field_trial_suffix));
|
||||||
field_trial_suffix));
|
|
||||||
std::unique_ptr<InputVolumeController> manager =
|
std::unique_ptr<InputVolumeController> manager =
|
||||||
CreateInputVolumeController(kClippedLevelStep, kClippedRatioThreshold,
|
CreateInputVolumeController(kClippedLevelStep, kClippedRatioThreshold,
|
||||||
kClippedWaitFrames);
|
kClippedWaitFrames);
|
||||||
|
|
||||||
EXPECT_EQ(manager->channel_controllers_[0]->min_mic_level(),
|
EXPECT_EQ(manager->channel_controllers_[0]->min_input_volume(),
|
||||||
kMinMicLevelOverride);
|
kMinMicLevelOverride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -858,7 +848,7 @@ TEST(InputVolumeControllerTest,
|
||||||
std::unique_ptr<InputVolumeController> manager_with_override;
|
std::unique_ptr<InputVolumeController> manager_with_override;
|
||||||
{
|
{
|
||||||
test::ScopedFieldTrials field_trial(
|
test::ScopedFieldTrials field_trial(
|
||||||
GetAgcMinMicLevelExperimentFieldTrialEnabled(kMinMicLevelOverride));
|
GetAgcMinInputVolumeFieldTrialEnabled(kMinMicLevelOverride));
|
||||||
manager_with_override = factory();
|
manager_with_override = factory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -915,7 +905,7 @@ TEST(InputVolumeControllerTest,
|
||||||
std::unique_ptr<InputVolumeController> manager_with_override;
|
std::unique_ptr<InputVolumeController> manager_with_override;
|
||||||
{
|
{
|
||||||
test::ScopedFieldTrials field_trial(
|
test::ScopedFieldTrials field_trial(
|
||||||
GetAgcMinMicLevelExperimentFieldTrialEnabled(kMinMicLevelOverride));
|
GetAgcMinInputVolumeFieldTrialEnabled(kMinMicLevelOverride));
|
||||||
manager_with_override = factory();
|
manager_with_override = factory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -976,7 +966,7 @@ TEST(InputVolumeControllerTest,
|
||||||
kMinMicLevelOverride,
|
kMinMicLevelOverride,
|
||||||
"Use a lower override value.");
|
"Use a lower override value.");
|
||||||
test::ScopedFieldTrials field_trial(
|
test::ScopedFieldTrials field_trial(
|
||||||
GetAgcMinMicLevelExperimentFieldTrialEnabled(kMinMicLevelOverride));
|
GetAgcMinInputVolumeFieldTrialEnabled(kMinMicLevelOverride));
|
||||||
manager_with_override = factory();
|
manager_with_override = factory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1041,7 +1031,7 @@ TEST(InputVolumeControllerTest,
|
||||||
kMinMicLevelOverride,
|
kMinMicLevelOverride,
|
||||||
"Use a lower override value.");
|
"Use a lower override value.");
|
||||||
test::ScopedFieldTrials field_trial(
|
test::ScopedFieldTrials field_trial(
|
||||||
GetAgcMinMicLevelExperimentFieldTrialEnabled(kMinMicLevelOverride));
|
GetAgcMinInputVolumeFieldTrialEnabled(kMinMicLevelOverride));
|
||||||
manager_with_override = factory();
|
manager_with_override = factory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue