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.
This commit is contained in:
Luis de Bethencourt 2015-08-10 19:06:16 +01:00
parent 53a9374eb5
commit 29786be80f

View file

@ -36,10 +36,6 @@ bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
{ {
const GstStructure *structure; const GstStructure *structure;
const GValue *value; 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; gchar *contents;
gint i; gint i;
guint size = 0; guint size = 0;
@ -91,12 +87,17 @@ bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
if (ctrlvol) { if (ctrlvol) {
gdouble volume; gdouble volume;
faces_value = gst_value_list_get_value (value, 0); const GValue *faces_value = gst_value_list_get_value (value, 0);
faces_structure = gst_value_get_structure (faces_value); const GstStructure *faces_structure =
have_mouth_y = gst_structure_has_field (faces_structure, "mouth->y"); gst_value_get_structure (faces_value);
have_mouth_x = gst_structure_has_field (faces_structure, "mouth->x"); gboolean have_mouth_y =
have_nose_y = gst_structure_has_field (faces_structure, "nose->y"); gst_structure_has_field (faces_structure, "mouth->y");
have_nose_x = gst_structure_has_field (faces_structure, "nose->x"); 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 */ /* get the volume value */
g_object_get (G_OBJECT (playbin), "volume", &volume, NULL); g_object_get (G_OBJECT (playbin), "volume", &volume, NULL);