From 34480653548b7ddc9c92fdff52c100e3eeca7033 Mon Sep 17 00:00:00 2001 From: indigo-san Date: Mon, 28 Aug 2023 20:42:36 +0900 Subject: [PATCH] =?UTF-8?q?=E6=8F=8F=E7=94=BB=E4=B8=AD=E3=81=AB=E4=BE=8B?= =?UTF-8?q?=E5=A4=96=E5=87=A6=E7=90=86=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Beutl.Engine/Rendering/Renderer.cs | 68 ++++++++++++++++---------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/src/Beutl.Engine/Rendering/Renderer.cs b/src/Beutl.Engine/Rendering/Renderer.cs index 19b539838..40d9d4dd8 100644 --- a/src/Beutl.Engine/Rendering/Renderer.cs +++ b/src/Beutl.Engine/Rendering/Renderer.cs @@ -80,16 +80,22 @@ public IRenderer.RenderResult RenderGraphics(TimeSpan timeSpan) RenderThread.Dispatcher.VerifyAccess(); if (!IsGraphicsRendering) { - IsGraphicsRendering = true; - _instanceClock.CurrentTime = timeSpan; - RenderScene.Clear(); - using (_fpsText.StartRender(_immediateCanvas)) + try { - RenderGraphicsCore(); + IsGraphicsRendering = true; + _instanceClock.CurrentTime = timeSpan; + RenderScene.Clear(); + using (_fpsText.StartRender(_immediateCanvas)) + { + RenderGraphicsCore(); + } + + return new IRenderer.RenderResult(_immediateCanvas.GetBitmap()); + } + finally + { + IsGraphicsRendering = false; } - - IsGraphicsRendering = false; - return new IRenderer.RenderResult(_immediateCanvas.GetBitmap()); } else { @@ -111,12 +117,18 @@ public IRenderer.RenderResult RenderAudio(TimeSpan timeSpan) { if (!IsAudioRendering) { - IsAudioRendering = true; - _instanceClock.AudioStartTime = timeSpan; - RenderAudioCore(); + try + { + IsAudioRendering = true; + _instanceClock.AudioStartTime = timeSpan; + RenderAudioCore(); - IsAudioRendering = false; - return new IRenderer.RenderResult(Audio: _audio.GetPcm()); + return new IRenderer.RenderResult(Audio: _audio.GetPcm()); + } + finally + { + IsAudioRendering = false; + } } else { @@ -129,20 +141,26 @@ public IRenderer.RenderResult Render(TimeSpan timeSpan) RenderThread.Dispatcher.VerifyAccess(); if (!IsGraphicsRendering && !IsAudioRendering) { - IsGraphicsRendering = true; - IsAudioRendering = true; - _instanceClock.CurrentTime = timeSpan; - _instanceClock.AudioStartTime = timeSpan; - RenderScene.Clear(); - using (_fpsText.StartRender(_immediateCanvas)) + try { - RenderGraphicsCore(); - RenderAudioCore(); + IsGraphicsRendering = true; + IsAudioRendering = true; + _instanceClock.CurrentTime = timeSpan; + _instanceClock.AudioStartTime = timeSpan; + RenderScene.Clear(); + using (_fpsText.StartRender(_immediateCanvas)) + { + RenderGraphicsCore(); + RenderAudioCore(); + } + + return new IRenderer.RenderResult(_immediateCanvas.GetBitmap(), _audio.GetPcm()); + } + finally + { + IsGraphicsRendering = false; + IsAudioRendering = false; } - - IsGraphicsRendering = false; - IsAudioRendering = false; - return new IRenderer.RenderResult(_immediateCanvas.GetBitmap(), _audio.GetPcm()); } else {