fix "frames still decode when m_Rate == 0"
This commit is contained in:
@@ -774,7 +774,10 @@ float MovieTexture_FFMpeg::CheckFrameTime()
|
|||||||
{
|
{
|
||||||
ASSERT_M( m_ImageWaiting == FRAME_DECODED, ssprintf("%i", m_ImageWaiting) );
|
ASSERT_M( m_ImageWaiting == FRAME_DECODED, ssprintf("%i", m_ImageWaiting) );
|
||||||
|
|
||||||
const float Offset = decoder->GetTimestamp() - m_Clock;
|
if( m_Rate == 0 )
|
||||||
|
return 1; // "a long time until the next frame"
|
||||||
|
|
||||||
|
const float Offset = (decoder->GetTimestamp() - m_Clock) / m_Rate;
|
||||||
|
|
||||||
/* If we're ahead, we're decoding too fast; delay. */
|
/* If we're ahead, we're decoding too fast; delay. */
|
||||||
if( Offset > 0 )
|
if( Offset > 0 )
|
||||||
@@ -844,7 +847,9 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
|
|
||||||
if( m_State == PAUSE_DECODER )
|
if( m_State == PAUSE_DECODER )
|
||||||
{
|
{
|
||||||
/* We aren't feeding frames, so we aren't waiting; don't chew CPU. */
|
/* We aren't feeding frames, so we aren't waiting; don't chew CPU.
|
||||||
|
* This needs to be relatively short so that we wake up quickly
|
||||||
|
* from being paused or for changes in m_Rate. */
|
||||||
usleep( 10000 );
|
usleep( 10000 );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -856,15 +861,18 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
const float fTime = CheckFrameTime();
|
const float fTime = CheckFrameTime();
|
||||||
if( fTime == -1 )
|
if( fTime == -1 ) // skip frame
|
||||||
{
|
{
|
||||||
DiscardFrame();
|
DiscardFrame();
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else if( fTime > 0 ) // not time to decode a new frame yet
|
||||||
if( fTime > 0 )
|
{
|
||||||
usleep( int(1000000*fTime) );
|
/* This needs to be relatively short so that we wake up quickly
|
||||||
|
* from being paused or for changes in m_Rate. */
|
||||||
|
usleep( 10000 );
|
||||||
|
}
|
||||||
|
else // fTime == 0
|
||||||
|
{
|
||||||
{
|
{
|
||||||
/* The only reason m_BufferFinished might be non-zero right now (before
|
/* The only reason m_BufferFinished might be non-zero right now (before
|
||||||
* ConvertFrame()) is if we're quitting. */
|
* ConvertFrame()) is if we're quitting. */
|
||||||
@@ -880,6 +888,7 @@ void MovieTexture_FFMpeg::DecoderThread()
|
|||||||
/* If the frame wasn't used, then we must be shutting down. */
|
/* If the frame wasn't used, then we must be shutting down. */
|
||||||
ASSERT_M( m_ImageWaiting == FRAME_NONE || m_State == DECODER_QUIT, ssprintf("%i, %i", m_ImageWaiting, m_State) );
|
ASSERT_M( m_ImageWaiting == FRAME_NONE || m_State == DECODER_QUIT, ssprintf("%i, %i", m_ImageWaiting, m_State) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user