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

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

@ -476,6 +476,11 @@ protected:
// the state machine thread. Synchronised via decoder monitor. // the state machine thread. Synchronised via decoder monitor.
PRPackedBool mAudioCompleted; 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 // PR_TRUE if mDuration has a value obtained from an HTTP header, or from
// the media index/metadata. Accessed on the state machine thread. // the media index/metadata. Accessed on the state machine thread.
PRPackedBool mGotDurationFromMetaData; PRPackedBool mGotDurationFromMetaData;