Skip to content

Commit

Permalink
Reset stream controller ENDED state after flushing the buffer
Browse files Browse the repository at this point in the history
Resumes streaming after level or track switch after the last segment has been appended
  • Loading branch information
Rob Walch committed Apr 14, 2021
1 parent e326e50 commit a4dc9dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/controller/audio-stream-controller.ts
Expand Up @@ -648,12 +648,7 @@ class AudioStreamController
'Buffer full error also media.currentTime is not buffered, flush audio buffer'
);
this.fragCurrent = null;
// flush everything
this.hls.trigger(Events.BUFFER_FLUSHING, {
startOffset: 0,
endOffset: Number.POSITIVE_INFINITY,
type: 'audio',
});
super.flushMainBuffer(0, Number.POSITIVE_INFINITY, 'audio');
}
}
break;
Expand Down Expand Up @@ -824,11 +819,7 @@ class AudioStreamController
const { hls, media, trackId } = this;
if (media) {
this.log('Switching audio track : flushing all audio');
hls.trigger(Events.BUFFER_FLUSHING, {
startOffset: 0,
endOffset: Number.POSITIVE_INFINITY,
type: 'audio',
});
super.flushMainBuffer(0, Number.POSITIVE_INFINITY, 'audio');
}
this.audioSwitch = false;
hls.trigger(Events.AUDIO_TRACK_SWITCHED, { id: trackId });
Expand Down
3 changes: 3 additions & 0 deletions src/controller/base-stream-controller.ts
Expand Up @@ -1185,6 +1185,9 @@ export default class BaseStreamController
// (so that we will check against video.buffered ranges in case of alt audio track)
const bufferedTimeRanges = BufferHelper.getBuffered(media);
this.fragmentTracker.detectEvictedFragments(type, bufferedTimeRanges);
if (this.state === State.ENDED) {
this.state = State.IDLE;
}
}

protected resetLiveStartWhenNotLoaded(level: number): boolean {
Expand Down

0 comments on commit a4dc9dd

Please sign in to comment.