[chronojump] Fixes to last commits



commit fa9d842ba8be47ae42eb137ccc5ffa300fbade62
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Feb 8 15:58:41 2019 +0100

    Fixes to last commits

 src/executeProcess.cs | 3 +++
 src/util.cs           | 3 +++
 src/webcamFfmpeg.cs   | 8 +++++++-
 3 files changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/src/executeProcess.cs b/src/executeProcess.cs
index 6d690e1c..1e0a16fb 100644
--- a/src/executeProcess.cs
+++ b/src/executeProcess.cs
@@ -327,6 +327,7 @@ class ExecuteProcess
 
        public static bool IsFileLocked(FileInfo finfo)
        {
+               LogB.Information("Checking file lock at IsFileLocked ...");
                //https://stackoverflow.com/a/937558
                FileStream stream = null;
 
@@ -338,6 +339,7 @@ class ExecuteProcess
                        //still being written to
                        //or being processed by another thread
                        //or does not exist (has already been processed)
+                       LogB.Information("Catched! at IsFileLocked: is locked!");
                        return true;
                }
                finally {
@@ -346,6 +348,7 @@ class ExecuteProcess
                }
 
                //file is not locked
+               LogB.Information("is NOT locked!");
                return false;
        }
 
diff --git a/src/util.cs b/src/util.cs
index f246cb97..b4157609 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1141,6 +1141,9 @@ public class Util
                                File.Move(origin, destination);
                        } catch {
                        */
+                               //check size before copyiing. To know if file has been copied while is not 
fully written
+                               LogB.Information("sizeOrigin: " + (new 
System.IO.FileInfo(origin).Length).ToString());
+
                                File.Copy(origin, destination, true); //can be overwritten
                        //}
                        return true;
diff --git a/src/webcamFfmpeg.cs b/src/webcamFfmpeg.cs
index e580004c..8f1a804f 100644
--- a/src/webcamFfmpeg.cs
+++ b/src/webcamFfmpeg.cs
@@ -91,7 +91,7 @@ public class WebcamFfmpeg : Webcam
                List<string> parameters = createParametersPlayFile (filename);
 
                process = new Process();
-               bool success = ExecuteProcess.RunAtBackground (ref process, executable, parameters, truee, 
false, false, false, false);
+               bool success = ExecuteProcess.RunAtBackground (ref process, executable, parameters, true, 
false, false, false, false);
                if(! success)
                {
                        process = null;
@@ -288,6 +288,12 @@ public class WebcamFfmpeg : Webcam
                 * above process.Close() will end the process
                 * without using this file copied from /tmp maybe is not finished, so a bad ended file is 
copied to .local/share/Chronojump/multimedia/video
                */
+
+               do {
+                       LogB.Information("waiting 100 ms to tmp capture file being unlocked");
+                       System.Threading.Thread.Sleep(100);
+               } while( ExecuteProcess.IsFileLocked(new System.IO.FileInfo(Util.GetVideoTempFileName())) );
+
                do {
                        LogB.Information("waiting 100 ms to end Ffmpeg");
                        System.Threading.Thread.Sleep(100);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]