Put "is speaking?" threshold in remote config; lower default
This commit is contained in:
parent
2b0c98f943
commit
cfa0711909
6 changed files with 39 additions and 6 deletions
20
ts/calling/getAudioLevelForSpeaking.ts
Normal file
20
ts/calling/getAudioLevelForSpeaking.ts
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue