From 16b8a512241d5515ae02251e9f59eead2cac8a97 Mon Sep 17 00:00:00 2001 From: David Rickard Date: Fri, 26 Mar 2021 23:29:17 -0700 Subject: Fixed issue where HandBrakeEncoderHelpers threw exceptions after falling back to no hardware mode. It was checking initSuccess which had not been set to true. Changed initSuccess to a local variable and changed to check globalInitialized instead. Also properly set initNoHardware flag when we do auto fallback to no hardware mode. --- win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'win/CS') diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs index 653cbcd64..2b5418212 100644 --- a/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs @@ -41,8 +41,10 @@ namespace HandBrake.Interop.Interop /// True if the global initialize function has been called. /// private static bool globalInitialized; - - private static bool initSuccess = false; + + /// + /// True if we initialized without hardware support. + /// private static bool initNoHardware = false; /// @@ -64,7 +66,8 @@ namespace HandBrake.Interop.Interop public static void EnsureGlobalInit(bool initNoHardwareMode) { if (!globalInitialized) - { + { + bool initSuccess; try { if (initNoHardwareMode) @@ -89,11 +92,13 @@ namespace HandBrake.Interop.Interop // Try without Hardware support. Bad drivers can sometimes cause issues. if (!initSuccess) - { + { if (HBFunctions.hb_global_init_no_hardware() == -1) { throw new InvalidOperationException("HB global init failed."); - } + } + + initNoHardware = true; } globalInitialized = true; @@ -345,12 +350,20 @@ namespace HandBrake.Interop.Interop { ErrorLogged?.Invoke(null, new MessageLoggedEventArgs(message)); } - + + /// + /// Returns true if we have successfully run global initialization. + /// + /// True if we have successfully run global initialization. public static bool IsInitialised() { - return initSuccess; + return globalInitialized; } - + + /// + /// Returns true if we initialized without hardware support. + /// + /// True if we initialized without hardware support. public static bool IsInitNoHardware() { return initNoHardware; -- cgit v1.2.3