From 29786be80f9bdfa45f30ff464d76c637db51c597 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Mon, 10 Aug 2015 19:06:16 +0100 Subject: [PATCH] examples: facedetect: only create variables when needed The variables to store face values are only needed if they will be used to control the volume. Which isn't the default to avoid potentially being very loud accidentally. Only create variables when needed. --- tests/examples/opencv/gstfacedetect_test.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/examples/opencv/gstfacedetect_test.c b/tests/examples/opencv/gstfacedetect_test.c index 1337c2fef9..138faf2133 100644 --- a/tests/examples/opencv/gstfacedetect_test.c +++ b/tests/examples/opencv/gstfacedetect_test.c @@ -36,10 +36,6 @@ bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * pipeline) { const GstStructure *structure; const GValue *value; - const GstStructure *faces_structure; - const GValue *faces_value; - gboolean have_mouth_x, have_mouth_y; - gboolean have_nose_x, have_nose_y; gchar *contents; gint i; guint size = 0; @@ -91,12 +87,17 @@ bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * pipeline) if (ctrlvol) { gdouble volume; - faces_value = gst_value_list_get_value (value, 0); - faces_structure = gst_value_get_structure (faces_value); - have_mouth_y = gst_structure_has_field (faces_structure, "mouth->y"); - have_mouth_x = gst_structure_has_field (faces_structure, "mouth->x"); - have_nose_y = gst_structure_has_field (faces_structure, "nose->y"); - have_nose_x = gst_structure_has_field (faces_structure, "nose->x"); + const GValue *faces_value = gst_value_list_get_value (value, 0); + const GstStructure *faces_structure = + gst_value_get_structure (faces_value); + gboolean have_mouth_y = + gst_structure_has_field (faces_structure, "mouth->y"); + gboolean have_mouth_x = + gst_structure_has_field (faces_structure, "mouth->x"); + gboolean have_nose_y = + gst_structure_has_field (faces_structure, "nose->y"); + gboolean have_nose_x = + gst_structure_has_field (faces_structure, "nose->x"); /* get the volume value */ g_object_get (G_OBJECT (playbin), "volume", &volume, NULL);