diff options
author | sr55 <[email protected]> | 2015-01-17 19:39:49 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-01-17 19:39:49 +0000 |
commit | 34db38d676420cf1fc827f339f5c894d5b798762 (patch) | |
tree | 79573157c83eef41f0d66bb824258994219b88c2 /win/CS/HandBrake.ApplicationServices/Services/Encode | |
parent | 5a74ccf9554940ae69e097b1abd6b1c5a556b4bc (diff) |
WinGui:
- Numerous fixes to the JSON api code.
Live preview should now work again.
Possible fix for issue where queued jobs where stopping at a random point and not continuing.
- Fix Clear button on the audio tab.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6760 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services/Encode')
4 files changed, 43 insertions, 55 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs index a86f20978..65ef02ed3 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs @@ -338,10 +338,16 @@ namespace HandBrake.ApplicationServices.Services.Encode File.Delete(logFile2);
}
- this.fileWriter = new StreamWriter(logFile) { AutoFlush = true };
- this.fileWriter.WriteLine(this.header);
- this.fileWriter.WriteLine(string.Format("CLI Query: {0}", query));
- this.fileWriter.WriteLine();
+ lock (FileWriterLock)
+ {
+ this.fileWriter = new StreamWriter(logFile) { AutoFlush = true };
+ this.fileWriter.WriteLine(this.header);
+ if (!isLibhb)
+ {
+ this.fileWriter.WriteLine(string.Format("CLI Query: {0}", query));
+ }
+ this.fileWriter.WriteLine();
+ }
}
catch (Exception)
{
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs index 841e049de..2253d96e8 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs @@ -96,17 +96,14 @@ namespace HandBrake.ApplicationServices.Services.Encode this.IsEncoding = true;
this.currentTask = encodeQueueTask;
- if (encodeQueueTask.Configuration.IsLoggingEnabled)
+ try
{
- try
- {
- this.SetupLogging(this.currentTask, false);
- }
- catch (Exception)
- {
- this.IsEncoding = false;
- throw;
- }
+ this.SetupLogging(this.currentTask, false);
+ }
+ catch (Exception)
+ {
+ this.IsEncoding = false;
+ throw;
}
// Make sure the path exists, attempt to create it if it doesn't
@@ -126,7 +123,7 @@ namespace HandBrake.ApplicationServices.Services.Encode ProcessStartInfo cliStart = new ProcessStartInfo(handbrakeCLIPath, query)
{
RedirectStandardOutput = true,
- RedirectStandardError = encodeQueueTask.Configuration.IsLoggingEnabled,
+ RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
};
@@ -137,11 +134,8 @@ namespace HandBrake.ApplicationServices.Services.Encode this.startTime = DateTime.Now;
- if (encodeQueueTask.Configuration.IsLoggingEnabled)
- {
- this.HbProcess.ErrorDataReceived += this.HbProcErrorDataReceived;
- this.HbProcess.BeginErrorReadLine();
- }
+ this.HbProcess.ErrorDataReceived += this.HbProcErrorDataReceived;
+ this.HbProcess.BeginErrorReadLine();
this.HbProcess.OutputDataReceived += this.HbProcess_OutputDataReceived;
this.HbProcess.BeginOutputReadLine();
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs index 0da939e19..0fbc7dbfe 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs @@ -46,15 +46,13 @@ namespace HandBrake.ApplicationServices.Services.Encode private DateTime startTime;
/// <summary>
- /// A flag to indicate if logging is enabled or not.
- /// </summary>
- private bool loggingEnabled;
-
- /// <summary>
/// The Current Task
/// </summary>
private QueueTask currentTask;
+ /// <summary>
+ /// A local instance of the scanned source.
+ /// </summary>
private Source scannedSource;
#endregion
@@ -94,13 +92,11 @@ namespace HandBrake.ApplicationServices.Services.Encode {
// Setup
this.startTime = DateTime.Now;
- this.loggingEnabled = job.Configuration.IsLoggingEnabled;
this.currentTask = job;
// Create a new HandBrake instance
// Setup the HandBrake Instance
- this.instance = new HandBrakeInstance();
- this.instance.Initialize(1);
+ this.instance = HandBrakeInstanceManager.GetEncodeInstance(job.Configuration.Verbosity);
this.instance.EncodeCompleted += this.InstanceEncodeCompleted;
this.instance.EncodeProgress += this.InstanceEncodeProgress;
@@ -115,17 +111,14 @@ namespace HandBrake.ApplicationServices.Services.Encode this.IsEncoding = true;
// Enable logging if required.
- if (job.Configuration.IsLoggingEnabled)
+ try
+ {
+ this.SetupLogging(job, true);
+ }
+ catch (Exception)
{
- try
- {
- this.SetupLogging(job, true);
- }
- catch (Exception)
- {
- this.IsEncoding = false;
- throw;
- }
+ this.IsEncoding = false;
+ throw;
}
// Verify the Destination Path Exists, and if not, create it.
@@ -133,14 +126,15 @@ namespace HandBrake.ApplicationServices.Services.Encode // We have to scan the source again but only the title so the HandBrake instance is initialised correctly.
// Since the UI sends the crop params down, we don't have to do all the previews.
- this.instance.StartScan(job.Task.Source, job.Configuration.PreviewScanCount, job.Task.Title);
this.instance.ScanCompleted += delegate
- {
- // Process into internal structures.
- this.scannedSource = new Source { Titles = LibScan.ConvertTitles(this.instance.Titles, this.instance.FeatureTitle) }; // TODO work around the bad Internal API.
- this.ScanCompleted(job, this.instance);
- };
+ {
+ // Process into internal structures.
+ this.scannedSource = new Source { Titles = LibScan.ConvertTitles(this.instance.Titles, this.instance.FeatureTitle) }; // TODO work around the bad Internal API.
+ this.ScanCompleted(job, this.instance);
+ };
+
+ this.instance.StartScan(job.Task.Source, job.Configuration.PreviewScanCount, job.Task.Title);
}
catch (Exception exc)
{
@@ -268,12 +262,9 @@ namespace HandBrake.ApplicationServices.Services.Encode /// </param>
private void HandBrakeInstanceErrorLogged(object sender, MessageLoggedEventArgs e)
{
- if (this.loggingEnabled)
+ lock (LogLock)
{
- lock (LogLock)
- {
- this.ProcessLogMessage(e.Message);
- }
+ this.ProcessLogMessage(e.Message);
}
}
@@ -288,12 +279,9 @@ namespace HandBrake.ApplicationServices.Services.Encode /// </param>
private void HandBrakeInstanceMessageLogged(object sender, MessageLoggedEventArgs e)
{
- if (this.loggingEnabled)
+ lock (LogLock)
{
- lock (LogLock)
- {
- this.ProcessLogMessage(e.Message);
- }
+ this.ProcessLogMessage(e.Message);
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs index 991d60a76..86b0d06ec 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs @@ -555,7 +555,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model /// <summary>
/// Gets or sets PreviewEncodeStartAt.
/// </summary>
- public string PreviewEncodeStartAt { get; set; }
+ public int PreviewEncodeStartAt { get; set; }
/// <summary>
/// Gets or sets a value indicating whether advanced panel enabled.
|