SHA256
Fix Cancelled Render Encoding Remaining Queued Frames
This commit is contained in:
1 file changed
+5
-2
@@ -764,12 +764,15 @@ internal class RenderManager : MonoBehaviour
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Takes frames from ImageQueue in passCount order and sends each one to the encoder, followed by the audio
|
/// Takes frames from ImageQueue in passCount order and sends each one to the encoder, followed by the audio
|
||||||
/// samples of that frame. Waits on FrameAvailableEvent (50ms) while no frame is ready.
|
/// samples of that frame. Waits on FrameAvailableEvent (50ms) while no frame is ready.
|
||||||
/// Returns when the render is aborted or all requested frames have been sent after endRequested.
|
/// Returns when the render is aborted (checked before every frame, frames left in ImageQueue are released
|
||||||
|
/// by the cleanup after the thread ends) or all requested frames have been sent after endRequested.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void EncodeQueuedFrames(FFmpegNativeEncoder videoFFmpeg)
|
private void EncodeQueuedFrames(FFmpegNativeEncoder videoFFmpeg)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
if (IsRenderAborted) return;
|
||||||
|
|
||||||
if (TryDequeueNextFrame(out var frame))
|
if (TryDequeueNextFrame(out var frame))
|
||||||
{
|
{
|
||||||
SendVideoFrame(videoFFmpeg, frame);
|
SendVideoFrame(videoFFmpeg, frame);
|
||||||
@@ -914,7 +917,7 @@ internal class RenderManager : MonoBehaviour
|
|||||||
var reason = IsRenderFailed ? $"FAILED ({_failureReason})" : "CANCELLED";
|
var reason = IsRenderFailed ? $"FAILED ({_failureReason})" : "CANCELLED";
|
||||||
Melon<RenderMod>.Logger.Error($"Rendering {reason}. Safely cleaning up state and resources.");
|
Melon<RenderMod>.Logger.Error($"Rendering {reason}. Safely cleaning up state and resources.");
|
||||||
|
|
||||||
// 1. Wait for render background thread to finish processing remaining queued frames and terminate
|
// 1. Wait (up to 2s) for the render background thread to see the abort flag and terminate
|
||||||
if (RenderThread is { IsAlive: true })
|
if (RenderThread is { IsAlive: true })
|
||||||
{
|
{
|
||||||
RenderThread.Join(2000);
|
RenderThread.Join(2000);
|
||||||
|
|||||||
Reference in new issue
Block a user