WinGui: Adding additional logging around LibHB scan / encode to track down why it...
authorsr55 <sr55.hb@outlook.com>
Mon, 19 Jan 2015 21:00:04 +0000 (21:00 +0000)
committersr55 <sr55.hb@outlook.com>
Mon, 19 Jan 2015 21:00:04 +0000 (21:00 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6774 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs

index 65ef02ed3da3be4fcf5ebd647357df47b1d4c051..3c78835aeeb41e54aee587448a1dda102a512c54 100644 (file)
@@ -361,6 +361,17 @@ namespace HandBrake.ApplicationServices.Services.Encode
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// The service log message.\r
+        /// </summary>\r
+        /// <param name="message">\r
+        /// The message.\r
+        /// </param>\r
+        protected void ServiceLogMessage(string message)\r
+        {\r
+            this.ProcessLogMessage(string.Format("# {0}", message));\r
+        }\r
+\r
         /// <summary>\r
         /// Process an Incomming Log Message.\r
         /// </summary>\r
index 215b05e021671a247f1d16584f1db55d32ddafcd..516be893260540c9fe0e129036eef8d9ac2bdc62 100644 (file)
@@ -136,10 +136,12 @@ namespace HandBrake.ApplicationServices.Services.Encode
 \r
                 HandBrakeUtils.SetDvdNav(!job.Configuration.IsDvdNavDisabled);\r
 \r
+                ServiceLogMessage("Scanning title for encoding ... ");\r
                 this.instance.StartScan(job.Task.Source, job.Configuration.PreviewScanCount, job.Task.Title);\r
             }\r
             catch (Exception exc)\r
             {\r
+                ServiceLogMessage("Scan Failed ... " + Environment.NewLine + exc);\r
                 this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "An Error has occured.", this.currentTask.Task.Destination));\r
             }\r
         }\r
@@ -152,6 +154,7 @@ namespace HandBrake.ApplicationServices.Services.Encode
             if (this.instance != null)\r
             {\r
                 this.instance.PauseEncode();\r
+                ServiceLogMessage("Encode Paused");\r
                 this.IsPasued = true;\r
             }\r
         }\r
@@ -164,6 +167,7 @@ namespace HandBrake.ApplicationServices.Services.Encode
             if (this.instance != null)\r
             {\r
                 this.instance.ResumeEncode();\r
+                ServiceLogMessage("Encode Resumed");\r
                 this.IsPasued = false;\r
             }\r
         }\r
@@ -177,6 +181,7 @@ namespace HandBrake.ApplicationServices.Services.Encode
             {\r
                 this.IsEncoding = false;\r
                 this.instance.StopEncode();\r
+                ServiceLogMessage("Encode Stopped");\r
             }\r
             catch (Exception)\r
             {\r
@@ -203,6 +208,8 @@ namespace HandBrake.ApplicationServices.Services.Encode
         /// </param>\r
         private void ScanCompleted(QueueTask job, IHandBrakeInstance instance)\r
         {\r
+            ServiceLogMessage("Scan Completed. Setting up the job for encoding ...");\r
+\r
             // Get an EncodeJob object for the Interop Library\r
             EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job);\r
 \r
@@ -210,6 +217,7 @@ namespace HandBrake.ApplicationServices.Services.Encode
             Title title = this.scannedSource.Titles.FirstOrDefault(t => t.TitleNumber == job.Task.Title);\r
             if (title == null)\r
             {\r
+                ServiceLogMessage("Title not found.");\r
                 throw new Exception("Unable to get title for encoding. Encode Failed.");\r
             }\r
 \r
@@ -222,7 +230,16 @@ namespace HandBrake.ApplicationServices.Services.Encode
                                                         };\r
             \r
             // TODO fix this tempory hack to pass in the required title information into the factory.\r
-            instance.StartEncode(encodeJob, scannedTitle, job.Configuration.PreviewScanCount);\r
+            try\r
+            {\r
+                ServiceLogMessage("Starting Encode ...");\r
+                instance.StartEncode(encodeJob, scannedTitle, job.Configuration.PreviewScanCount);\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                ServiceLogMessage("Failed to start encoding ..." + Environment.NewLine + exc);\r
+                this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "Unable to start encoding", job.Task.Source));\r
+            }\r
 \r
             // Fire the Encode Started Event\r
             this.InvokeEncodeStarted(System.EventArgs.Empty);\r
@@ -323,6 +340,7 @@ namespace HandBrake.ApplicationServices.Services.Encode
         private void InstanceEncodeCompleted(object sender, EncodeCompletedEventArgs e)\r
         {\r
             this.IsEncoding = false;\r
+            ServiceLogMessage("Encode Completed ...");\r
 \r
             this.InvokeEncodeCompleted(\r
                 e.Error\r
index 650b075165d1233d1d7b10c7c5c17ea52ee5abe7..796ef5db506528866d1da9455e5f833b74118dfe 100644 (file)
@@ -239,6 +239,7 @@ namespace HandBrake.ApplicationServices.Services.Scan
         /// </summary>\r
         public void Stop()\r
         {\r
+            ServiceLogMessage("Stopping Scan.");\r
             this.instance.StopScan();\r
 \r
             try\r
@@ -331,10 +332,12 @@ namespace HandBrake.ApplicationServices.Services.Scan
 \r
                 HandBrakeUtils.SetDvdNav(!configuraiton.IsDvdNavDisabled);\r
 \r
+                this.ServiceLogMessage("Starting Scan ...");\r
                 this.instance.StartScan(sourcePath.ToString(), previewCount, minDuration, title != 0 ? title : 0);\r
             }\r
             catch (Exception exc)\r
             {\r
+                this.ServiceLogMessage("Scan Failed ..." + Environment.NewLine + exc);\r
                 this.Stop();\r
 \r
                 if (this.ScanCompleted != null)\r
@@ -356,6 +359,8 @@ namespace HandBrake.ApplicationServices.Services.Scan
         /// </param>\r
         private void InstanceScanCompleted(object sender, System.EventArgs e)\r
         {\r
+            this.ServiceLogMessage("Starting Completed ...");\r
+\r
             // Write the log file out before we start processing incase we crash.\r
             try\r
             {\r
@@ -427,15 +432,7 @@ namespace HandBrake.ApplicationServices.Services.Scan
         /// </param>\r
         private void HandBrakeInstanceErrorLogged(object sender, MessageLoggedEventArgs e)\r
         {\r
-            lock (LogLock)\r
-            {\r
-                if (this.scanLog != null)\r
-                {\r
-                    this.scanLog.WriteLine(e.Message);\r
-                }\r
-\r
-                this.logging.AppendLine(e.Message);\r
-            }\r
+            this.LogMessage(e.Message);\r
         }\r
 \r
         /// <summary>\r
@@ -449,15 +446,7 @@ namespace HandBrake.ApplicationServices.Services.Scan
         /// </param>\r
         private void HandBrakeInstanceMessageLogged(object sender, MessageLoggedEventArgs e)\r
         {\r
-            lock (LogLock)\r
-            {\r
-                if (this.scanLog != null)\r
-                {\r
-                    this.scanLog.WriteLine(e.Message);\r
-                }\r
-\r
-                this.logging.AppendLine(e.Message);\r
-            }\r
+            this.LogMessage(e.Message);\r
         }\r
 \r
         /// <summary>\r
@@ -544,6 +533,36 @@ namespace HandBrake.ApplicationServices.Services.Scan
 \r
             return titleList;\r
         }\r
+\r
+        /// <summary>\r
+        /// The log message.\r
+        /// </summary>\r
+        /// <param name="message">\r
+        /// The message.\r
+        /// </param>\r
+        private void LogMessage(string message)\r
+        {\r
+            lock (LogLock)\r
+            {\r
+                if (this.scanLog != null)\r
+                {\r
+                    this.scanLog.WriteLine(message);\r
+                }\r
+\r
+                this.logging.AppendLine(message);\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// The service log message.\r
+        /// </summary>\r
+        /// <param name="message">\r
+        /// The message.\r
+        /// </param>\r
+        protected void ServiceLogMessage(string message)\r
+        {\r
+            this.LogMessage(string.Format("# {0}", message));\r
+        }\r
         #endregion\r
     }\r
 }
\ No newline at end of file