[chronojump] minor improvements on webcam start/stop
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] minor improvements on webcam start/stop
- Date: Fri, 12 Apr 2019 15:16:17 +0000 (UTC)
commit e003269949771ecc0a869e354740cb66576570bd
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Apr 12 17:15:50 2019 +0200
minor improvements on webcam start/stop
src/execute/event.cs | 1 +
src/gui/encoder.cs | 3 +--
src/gui/webcam.cs | 23 +++++++++++++++++------
src/webcam.cs | 10 +++++-----
4 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 3a2bb1ac..8a2836dc 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -615,6 +615,7 @@ public class EventExecute
private bool webcamStarting = false;
private bool checkWebcamFileStarted = false;
public bool WebcamStarting {
+ get { return webcamStarting; }
set { webcamStarting = value; }
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index c7608345..69d0386c 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -5739,8 +5739,7 @@ public partial class ChronoJumpWindow
if(action == encoderActions.CAPTURE)
{
webcamManage = new WebcamManage();
- bool camStarted = webcamStart (WebcamManage.GuiContactsEncoder.ENCODER, 1);
- if(camStarted)
+ if(webcamStart (WebcamManage.GuiContactsEncoder.ENCODER, 1))
webcamEncoderFileStarted = WebcamEncoderFileStarted.NEEDTOCHECK;
else
webcamEncoderFileStarted = WebcamEncoderFileStarted.NOCAMERA;
diff --git a/src/gui/webcam.cs b/src/gui/webcam.cs
index 812e5606..1c7ca5b8 100644
--- a/src/gui/webcam.cs
+++ b/src/gui/webcam.cs
@@ -107,16 +107,24 @@ public partial class ChronoJumpWindow
button_video_preview_visibile (guiContactsEncoder, false);
string errorMessage = "";
- if(ncams == 1 && webcamManage.RecordPrepare(preferences.videoDevice,
preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success)
+ if(ncams == 1)
{
- webcamManage.RecordStart(1);
- //label_video_feedback.Text = "Preparing camera";
+ if(! webcamManage.RecordPrepare(preferences.videoDevice,
preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success)
+ return false;
+
+ if(! webcamManage.RecordStart(1))
+ return false;
+
label_video_feedback_text (guiContactsEncoder, "Preparing camera");
}
- else if(ncams == 2 && webcamManage.RecordPrepare(preferences.videoDevice, "/dev/video1",
preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success)
+ else if(ncams == 2)
{
- webcamManage.RecordStart(2);
- //label_video_feedback.Text = "Preparing camera";
+ if(! webcamManage.RecordPrepare(preferences.videoDevice, "/dev/video1",
preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success)
+ return false;
+
+ if(! webcamManage.RecordStart(2))
+ return false;
+
label_video_feedback_text (guiContactsEncoder, "Preparing camera");
}
//TODO depending on errorMessage:
@@ -218,6 +226,9 @@ public partial class ChronoJumpWindow
//can pass a -1 uniqueID if test is cancelled
private void webcamEnd (Constants.TestTypes testType, int uniqueID)
{
+ if(! currentEventExecute.WebcamStarting) //no need to stop camera because it is not recording
+ return;
+
WebcamManage.GuiContactsEncoder guiContactsEncoder = WebcamManage.GuiContactsEncoder.CONTACTS;
if(testType == Constants.TestTypes.ENCODER)
{
diff --git a/src/webcam.cs b/src/webcam.cs
index 118cb60b..f3e6a01a 100644
--- a/src/webcam.cs
+++ b/src/webcam.cs
@@ -225,15 +225,15 @@ public class WebcamManage
return result;
}
- public void RecordStart (int ncams)
+ public bool RecordStart (int ncams)
{
- recordStartDo (ref webcam);
+ return recordStartDo (ref webcam);
if(ncams > 1)
- recordStartDo (ref webcam2);
+ return recordStartDo (ref webcam2);
}
- private void recordStartDo (ref Webcam webcam)
+ private bool recordStartDo (ref Webcam webcam)
{
- webcam.VideoCaptureStart();
+ return webcam.VideoCaptureStart().success;
}
public Webcam.Result RecordEnd(int ncam)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]