diff options
author | sr55 <[email protected]> | 2013-08-24 13:48:41 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-08-24 13:48:41 +0000 |
commit | 2526f515e8221cf8a955a3ea2dd405806d3aa259 (patch) | |
tree | cdeb33824e9de969fd114b2bedd63e7cf683693d /win/CS/HandBrake.ApplicationServices | |
parent | 978227b1fa4e68005048b7ce3e4b81c432a2915d (diff) |
WinGui: Fixes around libhb scanning. (Progress % was not shown and the scan logs was not written to disc)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5744 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs | 13 | ||||
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Services/LibScan.cs | 86 |
2 files changed, 65 insertions, 34 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs index 59213e5d0..785728582 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs @@ -93,18 +93,5 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// Kill the scan
/// </summary>
void Stop();
-
- /// <summary>
- /// Take a Scan Log file, and process it as if it were from the CLI.
- /// </summary>
- /// <param name="path">
- /// The path to the log file.
- /// </param>
- void DebugScanLog(string path);
-
- /// <summary>
- /// Shutdown the service.
- /// </summary>
- void Shutdown();
}
}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs index cc48ea3f4..a082bd2a4 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs @@ -11,6 +11,7 @@ namespace HandBrake.ApplicationServices.Services {
using System;
using System.Collections.Generic;
+ using System.IO;
using System.Text;
using System.Threading;
@@ -66,6 +67,21 @@ namespace HandBrake.ApplicationServices.Services /// </summary>
private string currentSourceScanPath;
+ /// <summary>
+ /// The log dir.
+ /// </summary>
+ private static string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
+
+ /// <summary>
+ /// The dvd info path.
+ /// </summary>
+ private string dvdInfoPath = Path.Combine(logDir, string.Format("last_scan_log{0}.txt", GeneralUtilities.ProcessId));
+
+ /// <summary>
+ /// The scan log.
+ /// </summary>
+ private StreamWriter scanLog;
+
#endregion
/// <summary>
@@ -154,6 +170,9 @@ namespace HandBrake.ApplicationServices.Services /// </param>
public void Scan(string sourcePath, int title, int previewCount, Action<bool> postAction)
{
+ this.logging.Clear();
+ scanLog = new StreamWriter(dvdInfoPath);
+
Thread t = new Thread(unused => this.ScanSource(sourcePath, title, previewCount));
t.Start();
}
@@ -163,21 +182,20 @@ namespace HandBrake.ApplicationServices.Services /// </summary>
public void Stop()
{
- instance.StopScan();
- }
+ try
+ {
+ if (this.scanLog != null)
+ {
+ this.scanLog.Close();
+ this.scanLog.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ // Do Nothing.
+ }
- /// <summary>
- /// Debug a Scan Log (Only Available for CLI Mode, not LIBHB)
- /// </summary>
- /// <param name="path">
- /// The path.
- /// </param>
- /// <exception cref="NotImplementedException">
- /// (Only Available for CLI Mode, not LIBHB)
- /// </exception>
- public void DebugScanLog(string path)
- {
- throw new NotImplementedException("Only Available when using the CLI mode. Not LibHB");
+ instance.StopScan();
}
/// <summary>
@@ -246,6 +264,20 @@ namespace HandBrake.ApplicationServices.Services /// </param>
private void InstanceScanCompleted(object sender, EventArgs e)
{
+ // Write the log file out before we start processing incase we crash.
+ try
+ {
+ if (this.scanLog != null)
+ {
+ this.scanLog.Close();
+ this.scanLog.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ // Do Nothing.
+ }
+
// TODO -> Might be a better place to fix this.
string path = currentSourceScanPath;
if (currentSourceScanPath.Contains("\""))
@@ -253,6 +285,7 @@ namespace HandBrake.ApplicationServices.Services path = currentSourceScanPath.Trim('\"');
}
+ // Process into internal structures.
this.SouceData = new Source { Titles = ConvertTitles(this.instance.Titles), ScanPath = path };
IsScanning = false;
@@ -278,7 +311,8 @@ namespace HandBrake.ApplicationServices.Services new ApplicationServices.EventArgs.ScanProgressEventArgs
{
CurrentTitle = e.CurrentTitle,
- Titles = e.Titles
+ Titles = e.Titles,
+ Percentage = Math.Round((decimal)e.Progress * 100, 0)
};
this.ScanStatusChanged(this, eventArgs);
@@ -298,6 +332,11 @@ namespace HandBrake.ApplicationServices.Services {
lock (LogLock)
{
+ if (this.scanLog != null)
+ {
+ this.scanLog.WriteLine(e.Message);
+ }
+
this.logging.AppendLine(e.Message);
}
}
@@ -315,6 +354,11 @@ namespace HandBrake.ApplicationServices.Services {
lock (LogLock)
{
+ if (this.scanLog != null)
+ {
+ this.scanLog.WriteLine(e.Message);
+ }
+
this.logging.AppendLine(e.Message);
}
}
@@ -335,12 +379,12 @@ namespace HandBrake.ApplicationServices.Services {
Title converted = new Title
{
- TitleNumber = title.TitleNumber,
- Duration = title.Duration,
- Resolution = new Size(title.Resolution.Width, title.Resolution.Height),
- AspectRatio = title.AspectRatio,
- AngleCount = title.AngleCount,
- ParVal = new Size(title.ParVal.Width, title.ParVal.Height),
+ TitleNumber = title.TitleNumber,
+ Duration = title.Duration,
+ Resolution = new Size(title.Resolution.Width, title.Resolution.Height),
+ AspectRatio = title.AspectRatio,
+ AngleCount = title.AngleCount,
+ ParVal = new Size(title.ParVal.Width, title.ParVal.Height),
AutoCropDimensions = title.AutoCropDimensions,
Fps = title.Framerate
};
|