Backed out changeset 00382c4a8b22 a=backout

This commit is contained in:
Chris Pearce 2010-10-13 20:10:37 +13:00
Родитель 700f990b78
Коммит d1db22de53
2 изменённых файлов: 26 добавлений и 7 удалений

Просмотреть файл

@ -151,6 +151,7 @@ nsBuiltinDecoderStateMachine::nsBuiltinDecoderStateMachine(nsBuiltinDecoder* aDe
mSeekable(PR_TRUE),
mPositionChangeQueued(PR_FALSE),
mAudioCompleted(PR_FALSE),
mBufferExhausted(PR_FALSE),
mGotDurationFromMetaData(PR_FALSE),
mStopDecodeThreads(PR_TRUE),
mEventManager(aDecoder)
@ -274,6 +275,10 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
if (videoPlaying && !videoWait) {
videoPlaying = mReader->DecodeVideoFrame(skipToNextKeyframe, currentTime);
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
mBufferExhausted = mDecoder->mDecoderPosition > initialDownloadPosition;
}
}
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
@ -284,6 +289,10 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
if (audioPlaying && !audioWait) {
audioPlaying = mReader->DecodeAudioData();
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
mBufferExhausted = mDecoder->mDecoderPosition > initialDownloadPosition;
}
}
{
@ -305,6 +314,9 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
{
// All active bitstreams' decode is well ahead of the playback
// position, we may as well wait for the playback to catch up.
// Set mBufferExhausted to PR_FALSE, as we'll receive more data
// while we wait.
mBufferExhausted = PR_FALSE;
mon.Wait();
}
}
@ -847,14 +859,13 @@ PRInt64 nsBuiltinDecoderStateMachine::AudioDecodedMs() const
PRBool nsBuiltinDecoderStateMachine::HasLowDecodedData() const
{
return ((HasAudio() &&
!mReader->mAudioQueue.IsFinished() &&
AudioDecodedMs() < LOW_AUDIO_MS)
||
// We consider ourselves low on decoded data if we're low on audio, or
// if we're only playing video and we're low on video frames.
return (HasAudio() && AudioDecodedMs() < LOW_AUDIO_MS)
||
(!HasAudio() &&
HasVideo() &&
!mReader->mVideoQueue.IsFinished() &&
(PRUint32)mReader->mVideoQueue.GetSize() < LOW_VIDEO_FRAMES));
(PRUint32)mReader->mVideoQueue.GetSize() < LOW_VIDEO_FRAMES);
}
PRBool nsBuiltinDecoderStateMachine::HasAmpleDecodedData() const
@ -957,7 +968,8 @@ nsresult nsBuiltinDecoderStateMachine::Run()
if (mState != DECODER_STATE_DECODING)
continue;
if (HasLowDecodedData() &&
if (mBufferExhausted &&
HasLowDecodedData() &&
mDecoder->GetState() == nsBuiltinDecoder::PLAY_STATE_PLAYING &&
!stream->IsDataCachedToEndOfStream(mDecoder->mDecoderPosition) &&
!stream->IsSuspended())
@ -1061,6 +1073,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
stopEvent = NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::SeekingStopped);
mState = DECODER_STATE_DECODING;
}
mBufferExhausted = PR_FALSE;
mDecoder->GetMonitor().NotifyAll();
{
@ -1423,6 +1436,7 @@ void nsBuiltinDecoderStateMachine::LoadMetadata()
void nsBuiltinDecoderStateMachine::StartBuffering()
{
mDecoder->GetMonitor().AssertCurrentThreadIn();
mBufferExhausted = PR_TRUE;
if (IsPlaying()) {
StopPlayback(AUDIO_PAUSE);
mDecoder->GetMonitor().NotifyAll();

Просмотреть файл

@ -476,6 +476,11 @@ protected:
// the state machine thread. Synchronised via decoder monitor.
PRPackedBool mAudioCompleted;
// PR_TRUE if the decode thread has indicated that we need to buffer.
// Accessed by the decode thread and the state machine thread.
// Synchronised via the decoder monitor.
PRPackedBool mBufferExhausted;
// PR_TRUE if mDuration has a value obtained from an HTTP header, or from
// the media index/metadata. Accessed on the state machine thread.
PRPackedBool mGotDurationFromMetaData;