summaryrefslogtreecommitdiff
path: root/tests/examples/camerabin2
diff options
context:
space:
mode:
authorRobert Swain <robert.swain@collabora.co.uk>2011-03-23 15:49:18 +0100
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2011-03-23 16:50:12 -0300
commit4b18a73332498074d4addc57865758332df44801 (patch)
treec1ec6083c0ab9fbaccb532b0334ee825570f0416 /tests/examples/camerabin2
parentd2e1f1bdc691bbc8231122a016fc733f153d4936 (diff)
gst-camerabin2-test: Fix premature shutdown
We must wait for camerabin2's stop-capture procedures to finish before quitting the main loop or firing off the next capture. If we get stuck waiting for camerabin2 to become idle, this is a bug that needs fixing.
Diffstat (limited to 'tests/examples/camerabin2')
-rw-r--r--tests/examples/camerabin2/gst-camerabin2-test.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/tests/examples/camerabin2/gst-camerabin2-test.c b/tests/examples/camerabin2/gst-camerabin2-test.c
index d018afbef..49974d1b5 100644
--- a/tests/examples/camerabin2/gst-camerabin2-test.c
+++ b/tests/examples/camerabin2/gst-camerabin2-test.c
@@ -135,6 +135,7 @@ static gint zoom = 100;
static gint capture_time = 10;
static gint capture_count = 0;
static gint capture_total = 1;
+static gulong stop_capture_cb_id = 0;
/* photography interface command line options */
#define EV_COMPENSATION_NONE -G_MAXFLOAT
@@ -569,15 +570,30 @@ error:
return FALSE;
}
+static void
+stop_capture_cb (GObject * self, GParamSpec * pspec, gpointer user_data)
+{
+ gboolean idle = FALSE;
+
+ g_object_get (camerabin, "idle", &idle, NULL);
+
+ if (idle) {
+ if (capture_count < capture_total) {
+ g_idle_add ((GSourceFunc) run_pipeline, NULL);
+ } else {
+ g_main_loop_quit (loop);
+ }
+ }
+
+ g_signal_handler_disconnect (camerabin, stop_capture_cb_id);
+}
+
static gboolean
stop_capture (gpointer user_data)
{
+ stop_capture_cb_id = g_signal_connect (camerabin, "notify::idle",
+ (GCallback) stop_capture_cb, camerabin);
g_signal_emit_by_name (camerabin, "stop-capture", 0);
- if (capture_count < capture_total) {
- g_idle_add ((GSourceFunc) run_pipeline, NULL);
- } else {
- g_main_loop_quit (loop);
- }
return FALSE;
}