Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 364db46

Browse files
committed
Make setDevice() methods async
Signed-off-by: Šimon Brandner <[email protected]>
1 parent dc9192c commit 364db46

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/MediaDeviceHandler.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ export default class MediaDeviceHandler extends EventEmitter {
7272
/**
7373
* Retrieves devices from the SettingsStore and tells the js-sdk to use them
7474
*/
75-
public static loadDevices(): void {
75+
public static async loadDevices(): Promise<void> {
7676
const audioDeviceId = SettingsStore.getValue("webrtc_audioinput");
7777
const videoDeviceId = SettingsStore.getValue("webrtc_videoinput");
7878

79-
MatrixClientPeg.get().getMediaHandler().setAudioInput(audioDeviceId);
80-
MatrixClientPeg.get().getMediaHandler().setVideoInput(videoDeviceId);
79+
await MatrixClientPeg.get().getMediaHandler().setAudioInput(audioDeviceId);
80+
await MatrixClientPeg.get().getMediaHandler().setVideoInput(videoDeviceId);
8181
}
8282

8383
public setAudioOutput(deviceId: string): void {
@@ -90,26 +90,26 @@ export default class MediaDeviceHandler extends EventEmitter {
9090
* need to be ended and started again for this change to take effect
9191
* @param {string} deviceId
9292
*/
93-
public setAudioInput(deviceId: string): void {
93+
public async setAudioInput(deviceId: string): Promise<void> {
9494
SettingsStore.setValue("webrtc_audioinput", null, SettingLevel.DEVICE, deviceId);
95-
MatrixClientPeg.get().getMediaHandler().setAudioInput(deviceId);
95+
return MatrixClientPeg.get().getMediaHandler().setAudioInput(deviceId);
9696
}
9797

9898
/**
9999
* This will not change the device that a potential call uses. The call will
100100
* need to be ended and started again for this change to take effect
101101
* @param {string} deviceId
102102
*/
103-
public setVideoInput(deviceId: string): void {
103+
public async setVideoInput(deviceId: string): Promise<void> {
104104
SettingsStore.setValue("webrtc_videoinput", null, SettingLevel.DEVICE, deviceId);
105-
MatrixClientPeg.get().getMediaHandler().setVideoInput(deviceId);
105+
return MatrixClientPeg.get().getMediaHandler().setVideoInput(deviceId);
106106
}
107107

108-
public setDevice(deviceId: string, kind: MediaDeviceKindEnum): void {
108+
public async setDevice(deviceId: string, kind: MediaDeviceKindEnum): Promise<void> {
109109
switch (kind) {
110110
case MediaDeviceKindEnum.AudioOutput: this.setAudioOutput(deviceId); break;
111-
case MediaDeviceKindEnum.AudioInput: this.setAudioInput(deviceId); break;
112-
case MediaDeviceKindEnum.VideoInput: this.setVideoInput(deviceId); break;
111+
case MediaDeviceKindEnum.AudioInput: await this.setAudioInput(deviceId); break;
112+
case MediaDeviceKindEnum.VideoInput: await this.setVideoInput(deviceId); break;
113113
}
114114
}
115115

0 commit comments

Comments
 (0)