Skip to content

Commit

Permalink
refactor: filter fragments potentially evicted from buffer on BufferF…
Browse files Browse the repository at this point in the history
…lushed
  • Loading branch information
azu committed Feb 20, 2018
1 parent 2042289 commit faf1473
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/hls.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1528,8 +1528,8 @@ _checkBuffer() {
use mediaBuffered instead of media (so that we will check against video.buffered ranges in case of alt audio track)
*/
const media = this.mediaBuffer ? this.mediaBuffer : this.media;

this._bufferedFrags = this._bufferedFrags.filter(frag => {return BufferHelper.isBuffered(media,(frag.startPTS + frag.endPTS) / 2);});
// filter fragments potentially evicted from buffer. this is to avoid memleak on live streams
this.fragmentTracker.detectEvictedFragments(Fragment.ElementaryStreamTypes.VIDEO, media.buffered);

// move to IDLE once flush complete. this should trigger new fragment loading
this.state = State.IDLE;
Expand Down
2 changes: 1 addition & 1 deletion src/helper/fragment-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class FragmentTracker extends EventHandler {
* The browser will unload parts of the buffer to free up memory for new buffer data
* Fragments will need to be reloaded when the buffer is freed up, removing partial fragments will allow them to reload(since there might be parts that are still playable)
* @param {String} elementaryStream The elementaryStream of media this is (eg. video/audio)
* @param {Object} timeRange TimeRange object from a sourceBuffer
* @param {TimeRanges} timeRange TimeRange object from a sourceBuffer
*/
detectEvictedFragments(elementaryStream, timeRange) {
let fragmentTimes, time;
Expand Down

0 comments on commit faf1473

Please sign in to comment.