diff options
author | sr55 <[email protected]> | 2018-12-09 21:15:40 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2018-12-09 21:15:56 +0000 |
commit | 6dde7dab7f8585d98cdbeba4b8408f0d94c15663 (patch) | |
tree | 3b91cfbb1cbc1ea3bf568e190b23d0bb356275aa /win/CS/HandBrakeWPF | |
parent | f1cc52aae69360bb4d415391453434e12320b0b3 (diff) |
WinGui: Some further tidyup of HandBrake.Interop. Remove the instance manager. The consumers should manage this themselves.
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r-- | win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs | 55 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Scan/LibScan.cs | 1 |
3 files changed, 57 insertions, 1 deletions
diff --git a/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs b/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs index 3fcf00e8f..d841dfab5 100644 --- a/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs +++ b/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs @@ -20,6 +20,8 @@ namespace HandBrakeWPF.Instance public static class HandBrakeInstanceManager { private static IEncodeInstance encodeInstance; + private static HandBrakeInstance scanInstance; + private static HandBrakeInstance previewInstance; /// <summary> /// Initializes static members of the <see cref="HandBrakeInstanceManager"/> class. @@ -74,5 +76,58 @@ namespace HandBrakeWPF.Instance return encodeInstance; } + + /// <summary> + /// Gets the scanInstance. + /// </summary> + /// <param name="verbosity"> + /// The verbosity. + /// </param> + /// <returns> + /// The <see cref="IHandBrakeInstance"/>. + /// </returns> + public static IHandBrakeInstance GetScanInstance(int verbosity) + { + if (scanInstance != null) + { + scanInstance.Dispose(); + scanInstance = null; + } + + HandBrakeInstance newInstance = new HandBrakeInstance(); + newInstance.Initialize(verbosity); + scanInstance = newInstance; + + return scanInstance; + } + + /// <summary> + /// The get encode instance. + /// </summary> + /// <param name="verbosity"> + /// The verbosity. + /// </param> + /// <param name="configuration"> + /// The configuration. + /// </param> + /// <returns> + /// The <see cref="IHandBrakeInstance"/>. + /// </returns> + public static IHandBrakeInstance GetPreviewInstance(int verbosity, HBConfiguration configuration) + { + if (previewInstance != null) + { + previewInstance.Dispose(); + previewInstance = null; + } + + HandBrakeInstance newInstance = new HandBrakeInstance(); + newInstance.Initialize(verbosity); + previewInstance = newInstance; + + HandBrakeUtils.SetDvdNav(!configuration.IsDvdNavDisabled); + + return previewInstance; + } } } diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs index 5c37dc4dd..382dd7cf9 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs @@ -80,7 +80,7 @@ namespace HandBrakeWPF.Services.Encode this.log.Reset(); // Reset so we have a clean log for the start of the encode. this.ServiceLogMessage("Starting Encode ..."); - this.instance = task.IsPreviewEncode ? HandBrake.Interop.Interop.HandBrakeInstanceManager.GetPreviewInstance(configuration.Verbosity, configuration) : HandBrakeInstanceManager.GetEncodeInstance(configuration.Verbosity, configuration); + this.instance = task.IsPreviewEncode ? HandBrakeInstanceManager.GetPreviewInstance(configuration.Verbosity, configuration) : HandBrakeInstanceManager.GetEncodeInstance(configuration.Verbosity, configuration); this.instance.EncodeCompleted += this.InstanceEncodeCompleted; this.instance.EncodeProgress += this.InstanceEncodeProgress; diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs index e3148866a..40823f3f7 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs @@ -23,6 +23,7 @@ namespace HandBrakeWPF.Services.Scan using HandBrake.Interop.Interop.Model.Preview; using HandBrake.Interop.Model; + using HandBrakeWPF.Instance; using HandBrakeWPF.Services.Encode.Model; using HandBrakeWPF.Services.Encode.Model.Models; using HandBrakeWPF.Services.Scan.EventArgs; |