Put "is speaking?" threshold in remote config; lower default

This commit is contained in:
Evan Hahn 2022-03-01 17:39:09 -06:00 committed by GitHub
parent 2b0c98f943
commit cfa0711909
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 6 deletions

View file

@ -0,0 +1,20 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type * as RemoteConfig from '../RemoteConfig';
import { DEFAULT_AUDIO_LEVEL_FOR_SPEAKING } from './constants';
export function getAudioLevelForSpeaking(
getValueFromRemoteConfig: typeof RemoteConfig.getValue
): number {
const configValue = getValueFromRemoteConfig(
'desktop.calling.audioLevelForSpeaking'
);
if (typeof configValue !== 'string') {
return DEFAULT_AUDIO_LEVEL_FOR_SPEAKING;
}
const result = parseFloat(configValue);
const isResultValid = result > 0 && result <= 1;
return isResultValid ? result : DEFAULT_AUDIO_LEVEL_FOR_SPEAKING;
}