summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/ActiveJob.cs2
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs123
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs15
3 files changed, 92 insertions, 48 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Queue/ActiveJob.cs b/win/CS/HandBrakeWPF/Services/Queue/ActiveJob.cs
index 3658a4120..8d79a8a0c 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/ActiveJob.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/ActiveJob.cs
@@ -102,10 +102,12 @@ namespace HandBrakeWPF.Services.Queue
this.IsPaused = false;
this.job.Status = !e.Successful ? QueueItemStatus.Error : QueueItemStatus.Completed;
+ this.job?.JobProgress.Update(e);
this.job.Statistics.EndTime = DateTime.Now;
this.job.Statistics.CompletedActivityLogPath = e.ActivityLogPath;
this.job.Statistics.FinalFileSize = e.FinalFilesizeInBytes;
+
this.job.JobProgress.ClearStatusDisplay();
this.encodeService.EncodeStatusChanged -= this.EncodeStatusChanged;
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs
index 5ed36d5b9..e3dbba559 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs
@@ -18,6 +18,8 @@ namespace HandBrakeWPF.Services.Queue.Model
public class QueueProgressStatus : PropertyChangedBase
{
+ private readonly object lockObj = new object();
+
private string jobStatus;
private bool intermediateProgress;
private double progressValue;
@@ -26,6 +28,7 @@ namespace HandBrakeWPF.Services.Queue.Model
public QueueProgressStatus()
{
+ this.JobStatus = "Waiting";
}
public string JobStatus
@@ -47,7 +50,11 @@ namespace HandBrakeWPF.Services.Queue.Model
get => this.intermediateProgress;
set
{
- if (value == this.intermediateProgress) return;
+ if (value == this.intermediateProgress)
+ {
+ return;
+ }
+
this.intermediateProgress = value;
this.NotifyOfPropertyChange(() => this.IntermediateProgress);
}
@@ -58,7 +65,11 @@ namespace HandBrakeWPF.Services.Queue.Model
get => this.progressValue;
set
{
- if (value == this.progressValue) return;
+ if (value == this.progressValue)
+ {
+ return;
+ }
+
this.progressValue = value;
this.NotifyOfPropertyChange(() => this.ProgressValue);
}
@@ -72,50 +83,91 @@ namespace HandBrakeWPF.Services.Queue.Model
public void Update(EncodeProgressEventArgs e)
{
- progressEventArgs = e;
- this.IntermediateProgress = false;
+ lock (lockObj)
+ {
+ progressEventArgs = e;
+ this.IntermediateProgress = false;
- string totalHrsLeft = e.EstimatedTimeLeft.Days >= 1 ? string.Format(@"{0:d\:hh\:mm\:ss}", e.EstimatedTimeLeft) : string.Format(@"{0:hh\:mm\:ss}", e.EstimatedTimeLeft);
- string elapsedTimeHrs = e.ElapsedTime.Days >= 1 ? string.Format(@"{0:d\:hh\:mm\:ss}", e.ElapsedTime) : string.Format(@"{0:hh\:mm\:ss}", e.ElapsedTime);
+ string totalHrsLeft = e.EstimatedTimeLeft.Days >= 1 ? string.Format(@"{0:d\:hh\:mm\:ss}", e.EstimatedTimeLeft) : string.Format(@"{0:hh\:mm\:ss}", e.EstimatedTimeLeft);
+ string elapsedTimeHrs = e.ElapsedTime.Days >= 1 ? string.Format(@"{0:d\:hh\:mm\:ss}", e.ElapsedTime) : string.Format(@"{0:hh\:mm\:ss}", e.ElapsedTime);
- if (e.IsSubtitleScan)
- {
- this.JobStatus = string.Format(Resources.MainViewModel_EncodeStatusChanged_SubScan_StatusLabel,
- e.Task,
- e.TaskCount,
- e.PercentComplete,
- totalHrsLeft,
- elapsedTimeHrs,
- null);
-
- this.ProgressValue = e.PercentComplete;
- }
- else if (e.IsMuxing)
- {
- this.JobStatus = Resources.MainView_Muxing;
- this.IntermediateProgress = true;
- }
- else if (e.IsSearching)
- {
- this.JobStatus = string.Format(Resources.MainView_ProgressStatusWithTask, Resources.MainView_Searching, e.PercentComplete, e.EstimatedTimeLeft, null);
- this.ProgressValue = e.PercentComplete;
- }
- else
- {
- this.JobStatus =
- string.Format(Resources.QueueViewModel_EncodeStatusChanged_StatusLabel,
+ if (e.IsSubtitleScan)
+ {
+ this.JobStatus = string.Format(Resources.MainViewModel_EncodeStatusChanged_SubScan_StatusLabel,
e.Task,
e.TaskCount,
e.PercentComplete,
- e.CurrentFrameRate,
- e.AverageFrameRate,
totalHrsLeft,
elapsedTimeHrs,
null);
- this.ProgressValue = e.PercentComplete;
+
+ this.ProgressValue = e.PercentComplete;
+ }
+ else if (e.IsMuxing)
+ {
+ this.JobStatus = Resources.MainView_Muxing;
+ this.IntermediateProgress = true;
+ }
+ else if (e.IsSearching)
+ {
+ this.JobStatus = string.Format(Resources.MainView_ProgressStatusWithTask, Resources.MainView_Searching, e.PercentComplete, e.EstimatedTimeLeft, null);
+ this.ProgressValue = e.PercentComplete;
+ }
+ else
+ {
+ this.JobStatus =
+ string.Format(Resources.QueueViewModel_EncodeStatusChanged_StatusLabel,
+ e.Task,
+ e.TaskCount,
+ e.PercentComplete,
+ e.CurrentFrameRate,
+ e.AverageFrameRate,
+ totalHrsLeft,
+ elapsedTimeHrs,
+ null);
+ this.ProgressValue = e.PercentComplete;
+ }
}
}
+ public void Update(EncodeCompletedEventArgs e)
+ {
+ lock (lockObj)
+ {
+ if (e.Successful)
+ {
+ this.JobStatus = Resources.QueueView_JobStatus_Complete;
+ }
+ else
+ {
+ switch (e.ErrorInformation)
+ {
+ case "1": // HB_ERROR_CANCELED
+ this.JobStatus = Resources.QueueView_JobStatus_Cancelled;
+ break;
+ case "2": // HB_ERROR_WRONG_INPUT
+ this.JobStatus = Resources.QueueView_JobStatus_InvalidInput;
+ break;
+ case "3": // HB_ERROR_INIT
+ this.JobStatus = Resources.QueueView_JobStatus_InitFailed;
+ break;
+ case "4": // HB_ERROR_UNKNOWN
+ this.JobStatus = Resources.QueueView_JobStatus_Unknown;
+ break;
+ case "5": // HB_ERROR_READ
+ this.JobStatus = Resources.QueueView_JobStatus_ReadError;
+ break;
+ case "-11": // Worker Crash
+ this.JobStatus = Resources.QueueView_JobStatus_WorkerCrash;
+ break;
+ default:
+ this.JobStatus = Resources.QueueView_JobStatus_NoErrorCode;
+ break;
+ }
+ }
+ }
+ }
+
public void SetPaused()
{
this.ClearStatusDisplay();
@@ -124,7 +176,6 @@ namespace HandBrakeWPF.Services.Queue.Model
public void ClearStatusDisplay()
{
- this.JobStatus = string.Empty;
this.ProgressValue = 0;
this.IntermediateProgress = false;
}
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs
index 0ed2a33a9..ee98535fd 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs
@@ -19,7 +19,7 @@ namespace HandBrakeWPF.Services.Queue.Model
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.Utilities;
- using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
+ using EncodeTask = Encode.Model.EncodeTask;
public class QueueTask : PropertyChangedBase
{
@@ -71,10 +71,7 @@ namespace HandBrakeWPF.Services.Queue.Model
public QueueItemStatus Status
{
- get
- {
- return this.status;
- }
+ get => this.status;
set
{
@@ -98,13 +95,7 @@ namespace HandBrakeWPF.Services.Queue.Model
public bool IsJobStatusVisible => this.Status == QueueItemStatus.InProgress;
[JsonIgnore]
- public string SelectedPresetKey
- {
- get
- {
- return this.presetKey;
- }
- }
+ public string SelectedPresetKey => this.presetKey;
[JsonIgnore]
public bool ShowEncodeProgress => this.Status == QueueItemStatus.InProgress && SystemInfo.IsWindows10();