Skip to content

Commit

Permalink
mediaController: fix state machine blocked in APPENDING state
Browse files Browse the repository at this point in the history
when FRAG_PARSED event is received after successful appending of all segments
  • Loading branch information
mangui committed Feb 8, 2016
1 parent af89fa4 commit cb85afb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/controller/mse-media-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1302,28 +1302,28 @@ _checkBuffer() {
}

doAppending() {
var hls = this.hls;
if (this.sourceBuffer) {
var hls = this.hls, sourceBuffer = this.sourceBuffer, mp4segments = this.mp4segments;
if (sourceBuffer) {
if (this.media.error) {
logger.error('trying to append although a media error occured, switch to ERROR state');
this.state = State.ERROR;
return;
}
// if MP4 segment appending in progress nothing to do
else if ((this.sourceBuffer.audio && this.sourceBuffer.audio.updating) ||
(this.sourceBuffer.video && this.sourceBuffer.video.updating)) {
else if ((sourceBuffer.audio && sourceBuffer.audio.updating) ||
(sourceBuffer.video && sourceBuffer.video.updating)) {
//logger.log('sb append in progress');
// check if any MP4 segments left to append
} else if (this.mp4segments.length) {
var segment = this.mp4segments.shift();
} else if (mp4segments.length) {
var segment = mp4segments.shift();
try {
//logger.log(`appending ${segment.type} SB, size:${segment.data.length});
this.sourceBuffer[segment.type].appendBuffer(segment.data);
sourceBuffer[segment.type].appendBuffer(segment.data);
this.appendError = 0;
} catch(err) {
// in case any error occured while appending, put back segment in mp4segments table
logger.error(`error while trying to append buffer:${err.message},try appending later`);
this.mp4segments.unshift(segment);
mp4segments.unshift(segment);
// just discard QuotaExceededError for now, and wait for the natural browser buffer eviction
//http://www.w3.org/TR/html5/infrastructure.html#quotaexceedederror
if(err.code !== 22) {
Expand Down

0 comments on commit cb85afb

Please sign in to comment.