Skip to content

Commit

Permalink
Add feature flag for ADM2 on Windows
Browse files Browse the repository at this point in the history
Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com>
  • Loading branch information
automated-signal and EvanHahn-Signal committed Nov 5, 2021
1 parent 04c3409 commit 0a8c671
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions ts/RemoteConfig.ts
Expand Up @@ -8,6 +8,7 @@ import * as log from './logging/log';

export type ConfigKeyType =
| 'desktop.announcementGroup'
| 'desktop.calling.useWindowsAdm2'
| 'desktop.clientExpiration'
| 'desktop.disableGV1'
| 'desktop.groupCallOutboundRing'
Expand Down
20 changes: 20 additions & 0 deletions ts/calling/audioDeviceModule.ts
Expand Up @@ -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',
Expand All @@ -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;
}
9 changes: 2 additions & 7 deletions ts/services/calling.ts
Expand Up @@ -59,6 +59,7 @@ import {
} from '../types/Calling';
import {
AudioDeviceModule,
getAudioDeviceModule,
parseAudioDeviceModule,
} from '../calling/audioDeviceModule';
import {
Expand All @@ -67,7 +68,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';
Expand All @@ -76,7 +76,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,
Expand Down Expand Up @@ -259,11 +258,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
Expand Down

0 comments on commit 0a8c671

Please sign in to comment.