Skip to content

Commit

Permalink
Fix for a rounding error not allowing BUFFERING_COMPLETED to get fired (
Browse files Browse the repository at this point in the history
Dash-Industry-Forum#3985)

* Fix for a rounding error not allowing BUFFERING_COMPLETED to get fired

* Try to fix periodBuffered rounding error using a threshold instead of rounding

* Undo commented out code
  • Loading branch information
jensenn authored Jul 12, 2022
1 parent 53c418d commit 5b1127e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/streaming/controllers/BufferController.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@ function BufferController(config) {

function _checkIfBufferingCompleted() {
const isLastIdxAppended = maxAppendedIndex >= maximumIndex - 1; // Handles 0 and non 0 based request index
const periodBuffered = playbackController.getTimeToStreamEnd(streamInfo) - bufferLevel <= 0;

// To avoid rounding error when comparing, the stream time and buffer level only must be within 5 decimal places
const periodBuffered = playbackController.getTimeToStreamEnd(streamInfo) - bufferLevel < 0.00001;
if ((isLastIdxAppended || periodBuffered) && !isBufferingCompleted) {
setIsBufferingCompleted(true);
logger.debug(`checkIfBufferingCompleted trigger BUFFERING_COMPLETED for stream id ${streamInfo.id} and type ${type}`);
Expand Down

0 comments on commit 5b1127e

Please sign in to comment.