mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Don't write intermediate frames to the backbuffer if catching up or seeking
There's no need to lock a mutex twice and copy the entire frame if we know we'll just discard the data anyway.
This commit is contained in:
@@ -213,6 +213,9 @@ void TheoraVideoStream::threadedFillBackBuffer(double dt)
|
|||||||
if (position < lastFrame)
|
if (position < lastFrame)
|
||||||
seekDecoder(position);
|
seekDecoder(position);
|
||||||
|
|
||||||
|
th_ycbcr_buffer bufferinfo;
|
||||||
|
bool hasFrame = false;
|
||||||
|
|
||||||
// Until we are at the end of the stream, or we are displaying the right frame
|
// Until we are at the end of the stream, or we are displaying the right frame
|
||||||
unsigned int framesBehind = 0;
|
unsigned int framesBehind = 0;
|
||||||
bool failedSeek = false;
|
bool failedSeek = false;
|
||||||
@@ -226,8 +229,8 @@ void TheoraVideoStream::threadedFillBackBuffer(double dt)
|
|||||||
failedSeek = true;
|
failedSeek = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
th_ycbcr_buffer bufferinfo;
|
|
||||||
th_decode_ycbcr_out(decoder, bufferinfo);
|
th_decode_ycbcr_out(decoder, bufferinfo);
|
||||||
|
hasFrame = true;
|
||||||
|
|
||||||
ogg_int64_t granulePosition;
|
ogg_int64_t granulePosition;
|
||||||
do
|
do
|
||||||
@@ -237,7 +240,11 @@ void TheoraVideoStream::threadedFillBackBuffer(double dt)
|
|||||||
} while (th_decode_packetin(decoder, &packet, &granulePosition) != 0);
|
} while (th_decode_packetin(decoder, &packet, &granulePosition) != 0);
|
||||||
lastFrame = nextFrame;
|
lastFrame = nextFrame;
|
||||||
nextFrame = th_granule_time(decoder, granulePosition);
|
nextFrame = th_granule_time(decoder, granulePosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only swap once, even if we read many frames to get here
|
||||||
|
if (hasFrame)
|
||||||
|
{
|
||||||
// Don't swap whilst we're writing to the backbuffer
|
// Don't swap whilst we're writing to the backbuffer
|
||||||
{
|
{
|
||||||
love::thread::Lock l(bufferMutex);
|
love::thread::Lock l(bufferMutex);
|
||||||
|
|||||||
Reference in New Issue
Block a user