From e2e8caf8362512bbd345ac2f2331673e7f2d11be Mon Sep 17 00:00:00 2001 From: routersys Date: Mon, 21 Sep 2026 12:10:02 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=87=E3=83=90=E3=82=A4=E3=82=B9=E6=B6=88?= =?UTF-8?q?=E5=A4=B1=E3=81=AE=E6=A4=9C=E7=9F=A5=E3=82=92COM=E4=BE=8B?= =?UTF-8?q?=E5=A4=96=E3=81=AB=E3=82=82=E5=BA=83=E3=81=92=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProxyForge/Encoding/ProxyEncoder.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ProxyForge/Encoding/ProxyEncoder.cs b/ProxyForge/Encoding/ProxyEncoder.cs index 000bf27..3002e81 100644 --- a/ProxyForge/Encoding/ProxyEncoder.cs +++ b/ProxyForge/Encoding/ProxyEncoder.cs @@ -100,7 +100,7 @@ internal sealed class ProxyEncoder(FFmpegExecutables executables, VideoSourceFac renderer = null; return session; } - catch (SharpGen.Runtime.SharpGenException exception) when (IsDeviceLost(exception.ResultCode)) + catch (Exception exception) when (IsDeviceLost(exception)) { if (attempt >= DeviceLostMaxAttempts) throw new ProxyEncodeException(ProxyEncodeFailure.GraphicsDeviceLost, "The GPU device was removed, hung, or reset."); @@ -119,8 +119,14 @@ internal sealed class ProxyEncoder(FFmpegExecutables executables, VideoSourceFac } } - static bool IsDeviceLost(SharpGen.Runtime.Result result) - => result == ResultCode.DeviceRemoved || result == ResultCode.DeviceHung || result == ResultCode.DeviceReset; + static bool IsDeviceLost(Exception exception) + { + if (exception is not (SharpGen.Runtime.SharpGenException or System.Runtime.InteropServices.COMException)) + return false; + + SharpGen.Runtime.Result result = exception.HResult; + return result == ResultCode.DeviceRemoved || result == ResultCode.DeviceHung || result == ResultCode.DeviceReset; + } static void TryDelete(string path) {