diff --git a/modules/renderer/audio/InputDeviceList.ts b/modules/renderer/audio/InputDeviceList.ts index e0c685f..b1f72cd 100644 --- a/modules/renderer/audio/InputDeviceList.ts +++ b/modules/renderer/audio/InputDeviceList.ts @@ -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"