Fixed client loading failure on huge amounts of installed audio io devices
This commit is contained in:
parent
a636515de8
commit
67ae1eacea
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user