Fixed whisper session cleanup

canary
WolverinDEV 2020-09-28 10:46:11 +02:00 committed by WolverinDEV
parent f81bab0775
commit 6781cb4e96
2 changed files with 13 additions and 3 deletions

View File

@ -83,8 +83,9 @@ export class ServerConnection extends AbstractServerConnection {
log.warn(LogCategory.NETWORKING, tr("Failed to disconnect on server connection destroy: %o"), error);
}).then(() => {
clearInterval(this.pingStatistics.thread_id);
if(this.connectCancelCallback)
if(this.connectCancelCallback) {
this.connectCancelCallback();
}
for(const listener of this.returnListeners) {
try {
@ -92,6 +93,7 @@ export class ServerConnection extends AbstractServerConnection {
} catch(error) {
log.warn(LogCategory.NETWORKING, tr("Failed to reject command promise: %o"), error);
}
clearTimeout(listener.timeout);
}
this.returnListeners = undefined;

View File

@ -110,6 +110,13 @@ export class VoiceConnection extends AbstractVoiceConnection {
this.voiceClients = undefined;
this.currentAudioSource = undefined;
});
if(Object.keys(this.voiceClients).length !== 0) {
logWarn(LogCategory.AUDIO, tr("Voice connection will be destroyed, but some voice clients are still left (%d)."), Object.keys(this.voiceClients).length);
}
const whisperSessions = Object.keys(this.whisperSessions);
whisperSessions.forEach(session => this.whisperSessions[session].destroy());
this.whisperSessions = {};
this.events.destroy();
}
@ -118,8 +125,9 @@ export class VoiceConnection extends AbstractVoiceConnection {
}
async acquireVoiceRecorder(recorder: RecorderProfile | undefined, enforce?: boolean) {
if(this.currentAudioSource === recorder && !enforce)
if(this.currentAudioSource === recorder && !enforce) {
return;
}
if(this.currentAudioSource) {
await this.voiceBridge?.setInput(undefined);
@ -157,7 +165,7 @@ export class VoiceConnection extends AbstractVoiceConnection {
this.handleRecorderStart();
}
} else {
await this.voiceBridge.setInput(undefined);
await this.voiceBridge?.setInput(undefined);
}
this.events.fire("notify_recorder_changed");