Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/ui/Logic/VideoPlayers/Ffmpeg/FfmpegPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,22 @@ public void Dispose()
CloseFile();
}

private void Present(VideoFrame frame, VideoFrameQueue pool)
private void Present(VideoFrame frame, VideoFrameQueue pool, LoadCancellation cancellation)
{
VideoFrame? previous;
lock (_currentFrameLock)
lock (_loadLock)
{
previous = _currentFrame;
_currentFrame = frame;
if (_disposed || cancellation.IsCancelled || !ReferenceEquals(_loadCancellation, cancellation))
{
pool.Return(frame);
return;
}

lock (_currentFrameLock)
{
previous = _currentFrame;
_currentFrame = frame;
}
}

pool.Return(previous);
Expand Down Expand Up @@ -1779,7 +1788,7 @@ private void ShowFrame(VideoFrame frame)
// Timestamp after the serial so HasPlaybackRestartedSince never sees a new
// timestamp with an old serial.
Interlocked.Exchange(ref _lastRestartTimestamp, Stopwatch.GetTimestamp());
_owner.Present(frame, _videoFrames);
_owner.Present(frame, _videoFrames, _loadCancellation);
}

// ---------------------------------------------------------------- teardown
Expand Down
Loading