Fixed client loading failure on huge amounts of installed audio io devices

This commit is contained in:
WolverinDEV 2020-11-18 14:36:29 +01:00
parent a636515de8
commit 67ae1eacea
1 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import {AbstractDeviceList, DeviceListEvents, IDevice, PermissionState} from "tc
import {Registry} from "tc-shared/events";
import * as loader from "tc-loader";
import * as native from "tc-native/connection";
import {audio} from "tc-native/connection";
interface NativeIDevice extends IDevice {
@ -34,8 +35,9 @@ class InputDeviceList extends AbstractDeviceList {
}
getDevices(): NativeIDevice[] {
if(this.cachedDevices)
if(this.cachedDevices) {
return this.cachedDevices;
}
this.cachedDevices = audio.available_devices()
.filter(e => e.input_supported || e.input_default)
@ -62,7 +64,12 @@ export let inputDeviceList;
loader.register_task(loader.Stage.JAVASCRIPT_INITIALIZING, {
function: async () => {
inputDeviceList = new InputDeviceList();
inputDeviceList.getDevices();
await new Promise(resolve => {
native.audio.initialize(() => {
inputDeviceList.getDevices();
resolve();
});
});
},
priority: 80,
name: "initialize input devices"