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);
await this.setInputStream(newStream);
this.inputDeviceId = deviceId;
backupStream.getAudioTracks().forEach((track) => track.stop());
backupStream = null;
if (backupStream && backupStream.active) {
backupStream.getAudioTracks().forEach((track) => track.stop());
backupStream = null;
}
return newStream;
} catch (error) {