Skip to content

Commit

Permalink
fix: Avoid a race when clearing buffered content
Browse files Browse the repository at this point in the history
This changes the order of operations in clearing buffered content in
StreamingEngine.  Now we clear the media states (synchronously) right
before we clear the actual buffered content (asynchronously).

This fixes a test failure in "StreamingEngine VOD can handle
unbuffered seeks" with Firefox on Windows.

Fixes b/162752568

Change-Id: I27f98fa0e14d4e9e1f1a24da4f5fda85c457bd1d
  • Loading branch information
joeyparrish committed Sep 26, 2020
1 parent 7941703 commit d4d014b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,8 @@ shaka.media.StreamingEngine = class {
mediaState.waitingToFlushBuffer = false;
mediaState.clearBufferSafeMargin = 0;
mediaState.clearingBuffer = true;
mediaState.lastStream = null;
mediaState.lastSegmentReference = null;

shaka.log.debug(logPrefix, 'clearing buffer');

Expand All @@ -1772,8 +1774,6 @@ shaka.media.StreamingEngine = class {
this.destroyer_.ensureNotDestroyed();

shaka.log.debug(logPrefix, 'cleared buffer');
mediaState.lastStream = null;
mediaState.lastSegmentReference = null;
mediaState.clearingBuffer = false;
mediaState.endOfStream = false;
this.scheduleUpdate_(mediaState, 0);
Expand Down

0 comments on commit d4d014b

Please sign in to comment.