diff options
author | sr55 <[email protected]> | 2013-03-07 22:11:11 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-03-07 22:11:11 +0000 |
commit | 0058e66974b545911342f72078469653384b509d (patch) | |
tree | 91ee17656180a2065deb72c33abeb31a88a14ecc /win/CS/HandBrake.ApplicationServices/Services | |
parent | abb517d43f2d80b030fed462107bbfa67385673f (diff) |
WinGui: Some Threading, Performance and Log window fixes.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5308 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services')
4 files changed, 51 insertions, 98 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs index 866edb794..555b004f2 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs @@ -15,8 +15,6 @@ namespace HandBrake.ApplicationServices.Services.Base using System.Text;
using System.Text.RegularExpressions;
- using Caliburn.Micro;
-
using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
@@ -41,11 +39,6 @@ namespace HandBrake.ApplicationServices.Services.Base private readonly IUserSettingService userSettingService;
/// <summary>
- /// Windows 7 API Pack wrapper
- /// </summary>
- private readonly Win7 windowsSeven = new Win7();
-
- /// <summary>
/// The Log File Header
/// </summary>
private readonly StringBuilder header;
@@ -76,6 +69,8 @@ namespace HandBrake.ApplicationServices.Services.Base GeneralUtilities.CreateCliLogHeader(
userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion),
userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild));
+
+ this.LogIndex = 0;
}
#region Events
@@ -119,24 +114,18 @@ namespace HandBrake.ApplicationServices.Services.Base }
/// <summary>
- /// Gets LogBuffer.
+ /// Gets the log index.
/// </summary>
- public StringBuilder LogBuffer
- {
- get
- {
- return this.logBuffer;
- }
- }
+ public int LogIndex { get; private set; }
/// <summary>
- /// Gets WindowsSeven.
+ /// Gets LogBuffer.
/// </summary>
- public Win7 WindowsSeven
+ public StringBuilder LogBuffer
{
get
{
- return this.windowsSeven;
+ return this.logBuffer;
}
}
@@ -152,15 +141,11 @@ namespace HandBrake.ApplicationServices.Services.Base /// </param>
public void InvokeEncodeStatusChanged(EncodeProgressEventArgs e)
{
- Execute.OnUIThread(
- () =>
- {
- EncodeProgessStatus handler = this.EncodeStatusChanged;
- if (handler != null)
- {
- handler(this, e);
- }
- });
+ EncodeProgessStatus handler = this.EncodeStatusChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
}
/// <summary>
@@ -171,15 +156,13 @@ namespace HandBrake.ApplicationServices.Services.Base /// </param>
public void InvokeEncodeCompleted(EncodeCompletedEventArgs e)
{
- Execute.OnUIThread(
- () =>
- {
- EncodeCompletedStatus handler = this.EncodeCompleted;
- if (handler != null)
- {
- handler(this, e);
- }
- });
+ EncodeCompletedStatus handler = this.EncodeCompleted;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+
+ this.LogIndex = 0; // Reset
}
/// <summary>
@@ -190,14 +173,11 @@ namespace HandBrake.ApplicationServices.Services.Base /// </param>
public void InvokeEncodeStarted(EventArgs e)
{
- Execute.OnUIThread(() =>
- {
- EventHandler handler = this.EncodeStarted;
- if (handler != null)
- {
- handler(this, e);
- }
- });
+ EventHandler handler = this.EncodeStarted;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
}
#endregion
@@ -261,7 +241,6 @@ namespace HandBrake.ApplicationServices.Services.Base }
}
-
/// <summary>
/// Pase the CLI status output (from standard output)
/// </summary>
@@ -393,6 +372,8 @@ namespace HandBrake.ApplicationServices.Services.Base {
try
{
+ this.LogIndex = this.LogIndex + 1;
+
lock (this.LogBuffer)
{
this.LogBuffer.AppendLine(message);
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs index 577067050..b4f572521 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs @@ -11,7 +11,6 @@ namespace HandBrake.ApplicationServices.Services {
using System;
using System.Diagnostics;
- using System.Globalization;
using System.IO;
using System.Windows.Forms;
@@ -66,7 +65,7 @@ namespace HandBrake.ApplicationServices.Services public Encode(IUserSettingService userSettingService)
: base(userSettingService)
{
- this.userSettingService = userSettingService;
+ this.userSettingService = userSettingService;
}
#region Properties
@@ -135,7 +134,7 @@ namespace HandBrake.ApplicationServices.Services userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount),
userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity),
userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav))
- : QueryGeneratorUtility.GenerateQuery(new EncodeTask(this.currentTask.Task),
+ : QueryGeneratorUtility.GenerateQuery(new EncodeTask(this.currentTask.Task),
userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount),
userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity),
userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav));
@@ -263,21 +262,16 @@ namespace HandBrake.ApplicationServices.Services }
Execute.OnUIThread(() =>
+ {
+ if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))
{
- if (this.WindowsSeven.IsWindowsSeven)
- {
- this.WindowsSeven.SetTaskBarProgressToNoProgress();
- }
-
- if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))
- {
- Win32.AllowSleep();
- }
+ Win32.AllowSleep();
+ }
+ });
- this.currentTask.Status = QueueItemStatus.Completed;
- this.IsEncoding = false;
- this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(true, null, string.Empty));
- });
+ this.currentTask.Status = QueueItemStatus.Completed;
+ this.IsEncoding = false;
+ this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(true, null, string.Empty));
}
/// <summary>
@@ -296,14 +290,14 @@ namespace HandBrake.ApplicationServices.Services {
if (!String.IsNullOrEmpty(e.Data))
{
- if (initShutdown && this.LogBuffer.Length < 25000000)
+ if (initShutdown && this.LogBuffer.Length < 25000000)
{
initShutdown = false; // Reset this flag.
}
if (this.LogBuffer.Length > 25000000 && !initShutdown) // Approx 23.8MB and make sure it's only printed once
{
- this.ProcessLogMessage("ERROR: Initiating automatic shutdown of encode process. The size of the log file inidcates that there is an error! ");
+ this.ProcessLogMessage("ERROR: Initiating automatic shutdown of encode process. The size of the log file indicates that there is an error! ");
initShutdown = true;
this.Stop();
}
@@ -328,28 +322,14 @@ namespace HandBrake.ApplicationServices.Services EncodeProgressEventArgs eventArgs = this.ReadEncodeStatus(e.Data, this.startTime);
if (eventArgs != null)
{
- Execute.OnUIThread(
- () =>
- {
- if (!this.IsEncoding)
- {
- // We can get events out of order since the CLI progress is monitored on a background thread.
- // So make sure we don't send a status update after an encode complete event.
- return;
- }
-
- this.InvokeEncodeStatusChanged(eventArgs);
-
- if (this.WindowsSeven.IsWindowsSeven)
- {
- int percent;
- int.TryParse(
- Math.Round(eventArgs.PercentComplete).ToString(CultureInfo.InvariantCulture),
- out percent);
-
- this.WindowsSeven.SetTaskBarProgress(percent);
- }
- });
+ if (!this.IsEncoding)
+ {
+ // We can get events out of order since the CLI progress is monitored on a background thread.
+ // So make sure we don't send a status update after an encode complete event.
+ return;
+ }
+
+ this.InvokeEncodeStatusChanged(eventArgs);
}
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs index 915d66788..fbb59ec2b 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs @@ -67,6 +67,11 @@ namespace HandBrake.ApplicationServices.Services.Interfaces string ActivityLog { get; }
/// <summary>
+ /// Gets the log index. The current log row counter.
+ /// </summary>
+ int LogIndex { get; }
+
+ /// <summary>
/// Start with a LibHb EncodeJob Object
/// </summary>
/// <param name="job">
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs index 0d1998a59..33453dad8 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs @@ -254,14 +254,6 @@ namespace HandBrake.ApplicationServices.Services };
this.InvokeEncodeStatusChanged(args);
-
- if (this.WindowsSeven.IsWindowsSeven)
- {
- int percent;
- int.TryParse(Math.Round(e.FractionComplete).ToString(CultureInfo.InvariantCulture), out percent);
-
- this.WindowsSeven.SetTaskBarProgress(percent);
- }
}
/// <summary>
@@ -282,11 +274,6 @@ namespace HandBrake.ApplicationServices.Services ? new EncodeCompletedEventArgs(false, null, string.Empty)
: new EncodeCompletedEventArgs(true, null, string.Empty));
- if (this.WindowsSeven.IsWindowsSeven)
- {
- this.WindowsSeven.SetTaskBarProgressToNoProgress();
- }
-
if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))
{
Win32.AllowSleep();
|