summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices/Services
diff options
context:
space:
mode:
authorsr55 <[email protected]>2015-02-07 17:01:36 +0000
committersr55 <[email protected]>2015-02-07 17:01:36 +0000
commitcd089d45e8b6a7f60699f493ee250707b1485007 (patch)
treea849b86e15f6677386d6a6e88ee33ed9cc20cd77 /win/CS/HandBrake.ApplicationServices/Services
parent753beb7d5c3b4de3d237d9e43b00e3e237bc8b36 (diff)
WinGui: Some improvements to Exception Handling, Debug information etc in the new LibHB code.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6879 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs10
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs55
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs32
3 files changed, 51 insertions, 46 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
index 9c5c9f7bd..9b817069b 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
@@ -228,9 +228,9 @@ namespace HandBrake.ApplicationServices.Services.Encode
tempLogFile, Path.Combine(configuration.SaveLogCopyDirectory, encodeLogFile));
}
}
- catch (Exception)
+ catch (Exception exc)
{
- // This exception doesn't warrent user interaction, but it should be logged (TODO)
+ Debug.WriteLine(exc); // This exception doesn't warrent user interaction, but it should be logged
}
}
@@ -375,7 +375,7 @@ namespace HandBrake.ApplicationServices.Services.Encode
/// </param>
protected void ProcessLogMessage(string message)
{
- if (!String.IsNullOrEmpty(message))
+ if (!string.IsNullOrEmpty(message))
{
try
{
@@ -394,9 +394,9 @@ namespace HandBrake.ApplicationServices.Services.Encode
}
}
}
- catch (Exception)
+ catch (Exception exc)
{
- // Do Nothing.
+ Debug.WriteLine(exc); // This exception doesn't warrent user interaction, but it should be logged
}
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
index 82bb4b1a7..483b88e7e 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
@@ -225,43 +225,44 @@ namespace HandBrake.ApplicationServices.Services.Encode
FramerateNumerator = title.FramerateNumerator,
};
- // TODO fix this tempory hack to pass in the required title information into the factory.
try
{
ServiceLogMessage("Starting Encode ...");
instance.StartEncode(encodeJob, scannedTitle);
+
+ // Fire the Encode Started Event
+ this.InvokeEncodeStarted(System.EventArgs.Empty);
+
+ // Set the Process Priority
+ switch (job.Configuration.ProcessPriority)
+ {
+ case "Realtime":
+ Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
+ break;
+ case "High":
+ Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
+ break;
+ case "Above Normal":
+ Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
+ break;
+ case "Normal":
+ Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
+ break;
+ case "Low":
+ Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
+ break;
+ default:
+ Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
+ break;
+ }
}
catch (Exception exc)
{
+ this.IsEncoding = false;
+
ServiceLogMessage("Failed to start encoding ..." + Environment.NewLine + exc);
this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "Unable to start encoding", job.Task.Source));
}
-
- // Fire the Encode Started Event
- this.InvokeEncodeStarted(System.EventArgs.Empty);
-
- // Set the Process Priority
- switch (job.Configuration.ProcessPriority)
- {
- case "Realtime":
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
- break;
- case "High":
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
- break;
- case "Above Normal":
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
- break;
- case "Normal":
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
- break;
- case "Low":
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
- break;
- default:
- Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
- break;
- }
}
#region HandBrakeInstance Event Handlers.
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
index bc9304f8e..d17de41b1 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
@@ -11,6 +11,7 @@ namespace HandBrake.ApplicationServices.Services.Scan
{
using System;
using System.Collections.Generic;
+ using System.Diagnostics;
using System.IO;
using System.Text;
using System.Windows.Media.Imaging;
@@ -194,9 +195,9 @@ namespace HandBrake.ApplicationServices.Services.Scan
File.Delete(this.dvdInfoPath);
}
}
- catch (Exception)
+ catch (Exception exc)
{
- // Do nothing.
+ Debug.WriteLine(exc);
}
if (!Directory.Exists(Path.GetDirectoryName(this.dvdInfoPath)))
@@ -223,11 +224,12 @@ namespace HandBrake.ApplicationServices.Services.Scan
/// </summary>
public void Stop()
{
- ServiceLogMessage("Stopping Scan.");
- this.instance.StopScan();
-
try
{
+ ServiceLogMessage("Stopping Scan.");
+ this.IsScanning = false;
+ this.instance.StopScan();
+
if (this.scanLog != null)
{
this.scanLog.Close();
@@ -307,17 +309,16 @@ namespace HandBrake.ApplicationServices.Services.Scan
this.currentSourceScanPath = source;
this.IsScanning = true;
- if (this.ScanStared != null)
- this.ScanStared(this, System.EventArgs.Empty);
- TimeSpan minDuration =
- TimeSpan.FromSeconds(
- configuraiton.MinScanDuration);
+ TimeSpan minDuration = TimeSpan.FromSeconds(configuraiton.MinScanDuration);
HandBrakeUtils.SetDvdNav(!configuraiton.IsDvdNavDisabled);
this.ServiceLogMessage("Starting Scan ...");
this.instance.StartScan(sourcePath.ToString(), previewCount, minDuration, title != 0 ? title : 0);
+
+ if (this.ScanStared != null)
+ this.ScanStared(this, System.EventArgs.Empty);
}
catch (Exception exc)
{
@@ -343,7 +344,7 @@ namespace HandBrake.ApplicationServices.Services.Scan
/// </param>
private void InstanceScanCompleted(object sender, System.EventArgs e)
{
- this.ServiceLogMessage("Starting Completed ...");
+ this.ServiceLogMessage("Scan Finished ...");
// Write the log file out before we start processing incase we crash.
try
@@ -353,9 +354,9 @@ namespace HandBrake.ApplicationServices.Services.Scan
this.scanLog.Flush();
}
}
- catch (Exception)
+ catch (Exception exc)
{
- // Do Nothing.
+ Debug.WriteLine(exc);
}
HandBrakeUtils.MessageLogged -= this.HandBrakeInstanceMessageLogged;
@@ -369,7 +370,10 @@ namespace HandBrake.ApplicationServices.Services.Scan
}
// Process into internal structures.
- this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles, this.instance.FeatureTitle), ScanPath = path };
+ if (this.instance != null && this.instance.Titles != null)
+ {
+ this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles, this.instance.FeatureTitle), ScanPath = path };
+ }
this.IsScanning = false;