summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs')
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs22
1 files changed, 13 insertions, 9 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
index caf1eff1d..111c91c6e 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
@@ -17,6 +17,7 @@ namespace HandBrakeWPF.Services.Encode
using HandBrake.ApplicationServices.Interop.Interfaces;
using HandBrake.ApplicationServices.Model;
+ using HandBrakeWPF.Exceptions;
using HandBrakeWPF.Services.Encode.Factories;
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
@@ -34,6 +35,7 @@ namespace HandBrakeWPF.Services.Encode
private DateTime startTime;
private EncodeTask currentTask;
private HBConfiguration currentConfiguration;
+ private bool isPreviewInstance;
#endregion
@@ -55,6 +57,12 @@ namespace HandBrakeWPF.Services.Encode
{
try
{
+ // Sanity Checking and Setup
+ if (this.IsEncoding)
+ {
+ throw new GeneralApplicationException("HandBrake is already encoding a file.", "Please stop the current encode. If the problem persists, please restart HandBrake.", null);
+ }
+
// Setup
this.startTime = DateTime.Now;
this.currentTask = task;
@@ -64,18 +72,14 @@ namespace HandBrakeWPF.Services.Encode
// Setup the HandBrake Instance
HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged;
HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged;
- this.instance = HandBrakeInstanceManager.GetEncodeInstance(configuration.Verbosity);
+ this.instance = task.IsPreviewEncode ? HandBrakeInstanceManager.GetPreviewInstance(configuration.Verbosity) : HandBrakeInstanceManager.GetEncodeInstance(configuration.Verbosity);
+
this.instance.EncodeCompleted += this.InstanceEncodeCompleted;
this.instance.EncodeProgress += this.InstanceEncodeProgress;
- // Sanity Checking and Setup
- if (this.IsEncoding)
- {
- throw new Exception("HandBrake is already encoding.");
- }
-
this.IsEncoding = true;
- this.SetupLogging();
+ this.isPreviewInstance = task.IsPreviewEncode;
+ this.SetupLogging(task.IsPreviewEncode);
// Verify the Destination Path Exists, and if not, create it.
this.VerifyEncodeDestinationPath(task);
@@ -246,7 +250,7 @@ namespace HandBrakeWPF.Services.Encode
HandBrakeUtils.ErrorLogged -= this.HandBrakeInstanceErrorLogged;
// Handling Log Data
- this.ProcessLogs(this.currentTask.Destination, this.currentConfiguration);
+ this.ProcessLogs(this.currentTask.Destination, this.isPreviewInstance, this.currentConfiguration);
// Cleanup
this.ShutdownFileWriter();