diff options
author | David Rickard <[email protected]> | 2021-03-26 23:29:17 -0700 |
---|---|---|
committer | Scott <[email protected]> | 2021-03-28 17:25:54 +0100 |
commit | 16b8a512241d5515ae02251e9f59eead2cac8a97 (patch) | |
tree | 74a7cc0f8cd36b9139ee14556de3ff067f1725d0 /win | |
parent | 2b18fe2d65b2146b96a9da0e599b1fb372087497 (diff) |
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.
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs | 29 |
1 files changed, 21 insertions, 8 deletions
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. /// </summary> private static bool globalInitialized; - - private static bool initSuccess = false; +
+ /// <summary>
+ /// True if we initialized without hardware support.
+ /// </summary> private static bool initNoHardware = false; /// <summary> @@ -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)); } - +
+ /// <summary>
+ /// Returns true if we have successfully run global initialization.
+ /// </summary>
+ /// <returns>True if we have successfully run global initialization.</returns> public static bool IsInitialised() { - return initSuccess; + return globalInitialized; } - +
+ /// <summary>
+ /// Returns true if we initialized without hardware support.
+ /// </summary>
+ /// <returns>True if we initialized without hardware support.</returns> public static bool IsInitNoHardware() { return initNoHardware; |