Skip to content

Commit

Permalink
buffer-controller: don't concurrently append data in multiple sourceb…
Browse files Browse the repository at this point in the history
…uffers

use this.appending boolean to ensure that one append is performed at a time
avoid missing notifications received in *stream-controller and fragLoopLoadingError/stuck stream controller

related to #30
  • Loading branch information
mangui committed May 10, 2016
1 parent 7216369 commit 42da52d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/controller/buffer-controller.js
Expand Up @@ -135,7 +135,7 @@ class BufferController extends EventHandler {
if (this._needsEos) {
this.onBufferEos();
}

this.appending = false;
this.hls.trigger(Event.BUFFER_APPENDED, { parent : this.parent});

this.doAppending();
Expand Down Expand Up @@ -282,11 +282,9 @@ class BufferController extends EventHandler {
logger.error('trying to append although a media error occured, flush segment and abort');
return;
}
for (var type in sourceBuffer) {
if (sourceBuffer[type].updating) {
//logger.log('sb update in progress');
return;
}
if (this.appending) {
//logger.log(`sb appending in progress`);
return;
}
if (segments && segments.length) {
var segment = segments.shift();
Expand All @@ -297,6 +295,7 @@ class BufferController extends EventHandler {
sourceBuffer[segment.type].appendBuffer(segment.data);
this.appendError = 0;
this.appended++;
this.appending = true;
} else {
// in case we don't have any source buffer matching with this segment type,
// it means that Mediasource fails to create sourcebuffer
Expand Down

0 comments on commit 42da52d

Please sign in to comment.