try {
resolve(audioContainer.input);
- record = false;
+ record = false;
} catch (e) {
reject()
}
// Format the audio.
const audio = bufSplit(
- Buffer.from(input as string, 'hex'),
+ Buffer.from(input as string, 'hex'),
8192
);
// -------------------------------------------------------------
// Get's called on window close.
-// export function stopStream() {
-// console.log("AUDIO:Stopping audio stream.")
-// if (ai) {
-// ai.quit()
-// }
-// if (ao) {
-// ao.quit()
-// }
-// console.log("AUDIO:Audio closed.")
-// }
+export async function stopStream() {
+ console.log("AUDIO:Stopping audio stream.")
+ if (ai) {
+ try {
+ await ai.quit()
+ } catch(e){
+ console.log('AUDIO: Failed to shutdown audio input.');
+ throw e;
+ }
+ }
+ if (ao) {
+ try {
+ await ao.quit()
+ } catch(e){
+ console.log('AUDIO: Failed to shutdown audio output.');
+ throw e;
+ }
+ }
+}
import { app, dialog } from "electron";
import { createWindow } from './window';
import { initSession } from './session';
-import { initAudioIO } from './audio';
+import { initAudioIO, stopStream } from './audio';
import { backgroundMitt } from '@/modules/emitter';
let win: boolean;
});
// Must keep to ensure app doesn't quit on close.
- app.on("before-quit", () => {
+ app.on("before-quit", async () => {
+ await stopStream();
});
// Must keep to ensure app doesn't quit on close.