avmerge: Fix errors if close is called twice

This can happen if the quality is changed from an avmerge source
to an integrated source, and then changed back to an avmerge source

Close is called the first change, but on the last change, it's
called again because the avMerge object is still present, resulting
in InvalidStateError

Signed-off-by: Jesús <heckyel@hyperbola.info>
This commit is contained in:
James Taylor 2021-08-25 14:29:40 -07:00 committed by Jesús
parent 70eb5cc94f
commit 5ff216d1ba
No known key found for this signature in database
GPG Key ID: F6EE7BC59A315766

View File

@ -37,6 +37,7 @@ function AVMerge(video, srcPair, startTime){
this.startTime = startTime;
this.video = video;
this.mediaSource = null;
this.closed = false;
this.setup();
}
AVMerge.prototype.setup = function() {
@ -67,6 +68,9 @@ AVMerge.prototype.sourceOpen = function(_) {
//this.video.onseeked = function() {console.log('seeked')};
}
AVMerge.prototype.close = function() {
if (this.closed)
return;
this.closed = true;
this.videoStream.close();
this.audioStream.close();
this.timeUpdateEvt.remove();