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