diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp index 52573879d8..8aab163020 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp @@ -703,16 +703,6 @@ void MovieTexture_FFMpeg::CreateTexture() m_uTexHandle = DISPLAY->CreateTexture( pixfmt, m_img, false ); } -void MovieTexture_FFMpeg::UpdateTimer() -{ - /* Always update the timer, so we don't skip ahead when coming out of pause. */ - const float fDeltaTime = m_Timer.GetDeltaTime(); - - /* If we're playing, update the clock. */ - if( m_State == PLAYING ) - m_Clock += fDeltaTime * m_Rate; -} - /* Handle decoding for a frame. Return true if a frame was decoded, false if not * (due to pause, EOF, etc). If true is returned, we'll be in FRAME_DECODED. */ bool MovieTexture_FFMpeg::DecodeFrame() @@ -844,8 +834,6 @@ void MovieTexture_FFMpeg::DecoderThread() while( m_State != DECODER_QUIT ) { - UpdateTimer(); - if( m_State == PAUSE_DECODER ) { /* We aren't feeding frames, so we aren't waiting; don't chew CPU. @@ -899,8 +887,6 @@ void MovieTexture_FFMpeg::Update(float fDeltaTime) { if( !m_bThreaded ) { - UpdateTimer(); - /* If we don't have a frame decoded, decode one. */ if( m_ImageWaiting == FRAME_NONE ) DecodeFrame(); @@ -1015,6 +1001,21 @@ void MovieTexture_FFMpeg::SetPosition( float fSeconds ) m_bWantRewind = true; } +/* This is used to decode data. */ +void MovieTexture_FFMpeg::DecodeSeconds( float fSeconds ) +{ + /* If we're paused, then ignore time passing. */ + if( m_State != PLAYING ) + return; + + m_Clock += fSeconds * m_Rate; + + /* If we're not threaded, we want to be sure to decode any new frames now, + * and not on the next frame. Update() may have already been called for this + * frame; call it again to be sure. */ + Update(0); +} + /* * (c) 2003-2004 Glenn Maynard * All rights reserved. diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.h b/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.h index c476510f83..7caa7dbc90 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.h +++ b/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.h @@ -29,6 +29,7 @@ public: virtual void Play(); virtual void Pause(); virtual void SetPosition( float fSeconds ); + virtual void DecodeSeconds( float fSeconds ); virtual void SetPlaybackRate( float fRate ) { m_Rate=fRate; } virtual bool IsPlaying() const { return m_State == PLAYING; } void SetLooping(bool looping=true) { m_bLoop = looping; } @@ -86,7 +87,6 @@ private: void StartThread(); void StopThread(); - void UpdateTimer(); bool DecodeFrame(); float CheckFrameTime(); void DiscardFrame();