Bug 794747 - add a pref for the default size of the VideoQueue. r=kinetik

This commit is contained in:
Nicolas Silva 2012-09-28 13:34:03 -04:00
parent 139fb7bd45
commit 59e94ffc9c
3 changed files with 26 additions and 15 deletions

View File

@ -60,19 +60,6 @@ const uint32_t SILENCE_BYTES_CHUNK = 32 * 1024;
// which is at or after the current playback position.
static const uint32_t LOW_VIDEO_FRAMES = 1;
// If we've got more than AMPLE_VIDEO_FRAMES decoded video frames waiting in
// the video queue, we will not decode any more video frames until some have
// been consumed by the play state machine thread.
#ifdef MOZ_WIDGET_GONK
// On B2G this is decided by a similar value which varies for each OMX decoder
// |OMX_PARAM_PORTDEFINITIONTYPE::nBufferCountMin|. This number must be less
// than the OMX equivalent or gecko will think it is chronically starved of
// video frames. All decoders seen so far have a value of at least 4.
static const uint32_t AMPLE_VIDEO_FRAMES = 3;
#else
static const uint32_t AMPLE_VIDEO_FRAMES = 10;
#endif
// Arbitrary "frame duration" when playing only audio.
static const int AUDIO_DURATION_USECS = 40000;
@ -430,6 +417,22 @@ nsBuiltinDecoderStateMachine::nsBuiltinDecoderStateMachine(nsBuiltinDecoder* aDe
mBufferingWait = mRealTime ? 0 : BUFFERING_WAIT_S;
mLowDataThresholdUsecs = mRealTime ? 0 : LOW_DATA_THRESHOLD_USECS;
// If we've got more than mAmpleVideoFrames decoded video frames waiting in
// the video queue, we will not decode any more video frames until some have
// been consumed by the play state machine thread.
#ifdef MOZ_WIDGET_GONK
// On B2G this is decided by a similar value which varies for each OMX decoder
// |OMX_PARAM_PORTDEFINITIONTYPE::nBufferCountMin|. This number must be less
// than the OMX equivalent or gecko will think it is chronically starved of
// video frames. All decoders seen so far have a value of at least 4.
mAmpleVideoFrames = Preferences::GetUint("media.video-queue.default-size", 3);
#else
mAmpleVideoFrames = Preferences::GetUint("media.video-queue.default-size", 10);
#endif
if (mAmpleVideoFrames < 2) {
mAmpleVideoFrames = 2;
}
}
nsBuiltinDecoderStateMachine::~nsBuiltinDecoderStateMachine()
@ -750,7 +753,7 @@ bool nsBuiltinDecoderStateMachine::HaveEnoughDecodedVideo()
{
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
if (static_cast<uint32_t>(mReader->VideoQueue().GetSize()) < AMPLE_VIDEO_FRAMES) {
if (static_cast<uint32_t>(mReader->VideoQueue().GetSize()) < mAmpleVideoFrames) {
return false;
}
@ -786,7 +789,7 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
// Once we've decoded more than videoPumpThreshold video frames, we'll
// no longer be considered to be "pumping video".
const unsigned videoPumpThreshold = mRealTime ? 0 : AMPLE_VIDEO_FRAMES / 2;
const unsigned videoPumpThreshold = mRealTime ? 0 : mAmpleVideoFrames / 2;
// After the audio decode fills with more than audioPumpThreshold usecs
// of decoded audio, we'll start to check whether the audio or video decode

View File

@ -605,6 +605,10 @@ protected:
uint32_t mBufferingWait;
int64_t mLowDataThresholdUsecs;
// If we've got more than mAmpleVideoFrames decoded video frames waiting in
// the video queue, we will not decode any more video frames until some have
// been consumed by the play state machine thread.
uint32_t mAmpleVideoFrames;
// True if we shouldn't play our audio (but still write it to any capturing
// streams).
bool mAudioCaptured;

View File

@ -182,6 +182,10 @@ pref("media.webaudio.enabled", false);
// Whether to autostart a media element with an |autoplay| attribute
pref("media.autoplay.enabled", true);
// The default number of decoded video frames that are enqueued in
// nsBuiltinDecoderReader's mVideoQueue.
pref("media.video-queue.default-size", 10);
// 0 = Off, 1 = Full, 2 = Tagged Images Only.
// See eCMSMode in gfx/thebes/gfxPlatform.h
pref("gfx.color_management.mode", 2);