diff --git a/ts/RemoteConfig.ts b/ts/RemoteConfig.ts index b3460ab98..6a586a7ab 100644 --- a/ts/RemoteConfig.ts +++ b/ts/RemoteConfig.ts @@ -8,6 +8,7 @@ import * as log from './logging/log'; export type ConfigKeyType = | 'desktop.announcementGroup' + | 'desktop.calling.useWindowsAdm2' | 'desktop.clientExpiration' | 'desktop.disableGV1' | 'desktop.groupCallOutboundRing' diff --git a/ts/calling/audioDeviceModule.ts b/ts/calling/audioDeviceModule.ts index 9d7e36488..d88beeb9d 100644 --- a/ts/calling/audioDeviceModule.ts +++ b/ts/calling/audioDeviceModule.ts @@ -2,6 +2,9 @@ // SPDX-License-Identifier: AGPL-3.0-only import { makeEnumParser } from '../util/enum'; +import { isEnabled } from '../RemoteConfig'; +import { isAlpha, isBeta } from '../util/version'; +import * as OS from '../OS'; export enum AudioDeviceModule { Default = 'Default', @@ -12,3 +15,20 @@ export const parseAudioDeviceModule = makeEnumParser( AudioDeviceModule, AudioDeviceModule.Default ); + +export function getAudioDeviceModule(): AudioDeviceModule { + if (!OS.isWindows()) { + return AudioDeviceModule.Default; + } + + const appVersion = window.getVersion(); + if ( + isEnabled('desktop.calling.useWindowsAdm2') || + isBeta(appVersion) || + isAlpha(appVersion) + ) { + return AudioDeviceModule.WindowsAdm2; + } + + return AudioDeviceModule.Default; +} diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 9adb45050..1a4c50896 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -57,6 +57,7 @@ import { } from '../types/Calling'; import { AudioDeviceModule, + getAudioDeviceModule, parseAudioDeviceModule, } from '../calling/audioDeviceModule'; import { @@ -65,7 +66,6 @@ import { } from '../calling/findBestMatchingDevice'; import type { LocalizerType } from '../types/Util'; import { UUID } from '../types/UUID'; -import * as OS from '../OS'; import type { ConversationModel } from '../models/conversations'; import * as Bytes from '../Bytes'; import { uuidToBytes, bytesToUuid } from '../Crypto'; @@ -74,7 +74,6 @@ import { getOwn } from '../util/getOwn'; import { isNormalNumber } from '../util/isNormalNumber'; import * as durations from '../util/durations'; import { handleMessageSend } from '../util/handleMessageSend'; -import { isAlpha, isBeta } from '../util/version'; import { fetchMembershipProof, getMembershipList, @@ -257,11 +256,7 @@ export class CallingClass { this.previousAudioDeviceModule = parseAudioDeviceModule( window.storage.get('previousAudioDeviceModule') ); - this.currentAudioDeviceModule = - OS.isWindows() && - (isAlpha(window.getVersion()) || isBeta(window.getVersion())) - ? AudioDeviceModule.WindowsAdm2 - : AudioDeviceModule.Default; + this.currentAudioDeviceModule = getAudioDeviceModule(); window.storage.put( 'previousAudioDeviceModule', this.currentAudioDeviceModule