From 97c6b9c07b1811ea835f24b737f5a1d488a97665 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 18 May 2009 10:03:03 +1200 Subject: [PATCH] Bug 476973. Don't get confused by repeated seeks in the Ogg decoder. r=doublec --- content/media/video/src/nsOggDecoder.cpp | 22 +++++-- content/media/video/test/test_bug476973.html | 60 ++++++++++++++++++++ 2 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 content/media/video/test/test_bug476973.html diff --git a/content/media/video/src/nsOggDecoder.cpp b/content/media/video/src/nsOggDecoder.cpp index 8e5823cd8938..397e57c273d4 100644 --- a/content/media/video/src/nsOggDecoder.cpp +++ b/content/media/video/src/nsOggDecoder.cpp @@ -1103,6 +1103,10 @@ void nsOggDecodeStateMachine::Decode() void nsOggDecodeStateMachine::Seek(float aTime) { nsAutoMonitor mon(mDecoder->GetMonitor()); + // nsOggDecoder::mPlayState should be SEEKING while we seek, and + // in that case nsOggDecoder shouldn't be calling us. + NS_ASSERTION(mState != DECODER_STATE_SEEKING, + "We shouldn't already be seeking"); mSeekTime = aTime; LOG(PR_LOG_DEBUG, ("Changed state to SEEKING (to %f)", aTime)); mState = DECODER_STATE_SEEKING; @@ -1330,17 +1334,23 @@ nsresult nsOggDecodeStateMachine::Run() UpdatePlaybackPosition(frame->mDecodedFrameTime); PlayVideo(frame); } + + // Change state to DECODING now. SeekingStopped will call + // nsOggDecodeStateMachine::Seek to reset our state to SEEKING + // if we need to seek again. + LOG(PR_LOG_DEBUG, ("Changed state from SEEKING (to %f) to DECODING", seekTime)); + // mSeekTime should not have changed. While we seek, mPlayState + // should always be PLAY_STATE_SEEKING and no-one will call + // nsOggDecoderStateMachine::Seek. + NS_ASSERTION(seekTime == mSeekTime, "No-one should have changed mSeekTime"); + mState = DECODER_STATE_DECODING; + mon.NotifyAll(); + mon.Exit(); nsCOMPtr stopEvent = NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, SeekingStopped); NS_DispatchToMainThread(stopEvent, NS_DISPATCH_SYNC); mon.Enter(); - - if (mState == DECODER_STATE_SEEKING && mSeekTime == seekTime) { - LOG(PR_LOG_DEBUG, ("Changed state from SEEKING (to %f) to DECODING", seekTime)); - mState = DECODER_STATE_DECODING; - mon.NotifyAll(); - } } break; diff --git a/content/media/video/test/test_bug476973.html b/content/media/video/test/test_bug476973.html new file mode 100644 index 000000000000..68845650b274 --- /dev/null +++ b/content/media/video/test/test_bug476973.html @@ -0,0 +1,60 @@ + + + + + + Bug 476973 - multiple seeks to the same position shouldn't cause problems + + + + + +Mozilla Bug 476973 +
+
+
+ + +