デバイス消失の検知をCOM例外にも広げる

このコミットが含まれているのは:
routersys committed 2026-09-21 12:10:02 +09:00
1 親 e6f3bc6557
コミット e2e8caf836
1ファイル変更
+9 -3
+9 -3
ファイルの表示
@@ -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)
{