Skip to content

Commit

Permalink
audio-stream-controller: ensure we buffer at least config.maxBufferLe…
Browse files Browse the repository at this point in the history
…ngth (default 30s)

once we reach that threshold, don't buffer more than video (mainBufferInfo.len)

related to video-dev#1342
  • Loading branch information
mangui committed Sep 13, 2017
1 parent 35a1a45 commit 97388a3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/controller/audio-stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,15 @@ class AudioStreamController extends EventHandler {
}
}
let media = this.mediaBuffer ? this.mediaBuffer : this.media,
videoBuffer = this.videoBuffer ? this.videoBuffer : this.media,
bufferInfo = BufferHelper.bufferInfo(media,pos,config.maxBufferHole),
mainBufferInfo = BufferHelper.bufferInfo(videoBuffer,pos,config.maxBufferHole),
bufferLen = bufferInfo.len,
bufferEnd = bufferInfo.end,
fragPrevious = this.fragPrevious,
maxBufLen = config.maxMaxBufferLength,
// ensure we buffer at least config.maxBufferLength (default 30s)
// once we reach that threshold, don't buffer more than video (mainBufferInfo.len)
maxBufLen = Math.max(config.maxBufferLength,mainBufferInfo.len),
audioSwitch = this.audioSwitch,
trackId = this.trackId;

Expand Down Expand Up @@ -450,7 +454,7 @@ class AudioStreamController extends EventHandler {
media.removeEventListener('ended', this.onvended);
this.onvseeking = this.onvseeked = this.onvended = null;
}
this.media = this.mediaBuffer = null;
this.media = this.mediaBuffer = this.videoBuffer = null;
this.loadedmetadata = false;
this.stopLoad();
}
Expand Down Expand Up @@ -758,6 +762,9 @@ class AudioStreamController extends EventHandler {
this.mediaBuffer = audioTrack.buffer;
this.loadedmetadata = true;
}
if (data.tracks.video) {
this.videoBuffer = data.tracks.video.buffer;
}
}

onBufferAppended(data) {
Expand Down

0 comments on commit 97388a3

Please sign in to comment.