fix(audio): check if backup stream exists before trying to clean it up

This commit is contained in:
prlanzarin 2022-08-25 17:14:41 +00:00
parent ec1879f96b
commit bf802ced4c

View File

@ -97,8 +97,10 @@ export default class BaseAudioBridge {
newStream = await navigator.mediaDevices.getUserMedia(constraints); newStream = await navigator.mediaDevices.getUserMedia(constraints);
await this.setInputStream(newStream); await this.setInputStream(newStream);
this.inputDeviceId = deviceId; this.inputDeviceId = deviceId;
backupStream.getAudioTracks().forEach((track) => track.stop()); if (backupStream && backupStream.active) {
backupStream = null; backupStream.getAudioTracks().forEach((track) => track.stop());
backupStream = null;
}
return newStream; return newStream;
} catch (error) { } catch (error) {