Bug 984698 - Reduce the amount of audio prerolled when we are not also decoding video in the same file. r=padenot
This commit is contained in:
@@ -74,6 +74,13 @@ static const uint32_t LOW_AUDIO_USECS = 300000;
|
||||
// less than the low audio threshold.
|
||||
const int64_t AMPLE_AUDIO_USECS = 1000000;
|
||||
|
||||
// When we're only playing audio and we don't have a video stream, we divide
|
||||
// AMPLE_AUDIO_USECS and LOW_AUDIO_USECS by the following value. This reduces
|
||||
// the amount of decoded audio we buffer, reducing our memory usage. We only
|
||||
// need to decode far ahead when we're decoding video using software decoding,
|
||||
// as otherwise a long video decode could cause an audio underrun.
|
||||
const int64_t NO_VIDEO_AMPLE_AUDIO_DIVISOR = 8;
|
||||
|
||||
// Maximum number of bytes we'll allocate and write at once to the audio
|
||||
// hardware when the audio stream contains missing frames and we're
|
||||
// writing silence in order to fill the gap. We limit our silence-writes
|
||||
@@ -1856,6 +1863,14 @@ nsresult MediaDecoderStateMachine::DecodeMetadata()
|
||||
mDecoder.get(), mStartTime, mEndTime, GetDuration(),
|
||||
mTransportSeekable, mMediaSeekable));
|
||||
|
||||
if (HasAudio() && !HasVideo()) {
|
||||
// We're playing audio only. We don't need to worry about slow video
|
||||
// decodes causing audio underruns, so don't buffer so much audio in
|
||||
// order to reduce memory usage.
|
||||
mAmpleAudioThresholdUsecs /= NO_VIDEO_AMPLE_AUDIO_DIVISOR;
|
||||
mLowAudioThresholdUsecs /= NO_VIDEO_AMPLE_AUDIO_DIVISOR;
|
||||
}
|
||||
|
||||
// Inform the element that we've loaded the metadata and the first frame,
|
||||
// setting the default framebuffer size for audioavailable events. Also,
|
||||
// if there is audio, let the MozAudioAvailable event manager know about
|
||||
|
||||
Reference in New Issue
Block a user