Fixed whisper session cleanup

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

View file

@ -110,6 +110,13 @@ export class VoiceConnection extends AbstractVoiceConnection {
this.voiceClients = undefined; this.voiceClients = undefined;
this.currentAudioSource = 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(); this.events.destroy();
} }
@ -118,8 +125,9 @@ export class VoiceConnection extends AbstractVoiceConnection {
} }
async acquireVoiceRecorder(recorder: RecorderProfile | undefined, enforce?: boolean) { async acquireVoiceRecorder(recorder: RecorderProfile | undefined, enforce?: boolean) {
if(this.currentAudioSource === recorder && !enforce) if(this.currentAudioSource === recorder && !enforce) {
return; return;
}
if(this.currentAudioSource) { if(this.currentAudioSource) {
await this.voiceBridge?.setInput(undefined); await this.voiceBridge?.setInput(undefined);
@ -157,7 +165,7 @@ export class VoiceConnection extends AbstractVoiceConnection {
this.handleRecorderStart(); this.handleRecorderStart();
} }
} else { } else {
await this.voiceBridge.setInput(undefined); await this.voiceBridge?.setInput(undefined);
} }
this.events.fire("notify_recorder_changed"); this.events.fire("notify_recorder_changed");