summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2013-02-05 08:26:14 +0100
committerStefan Sauer <ensonic@users.sf.net>2013-02-05 18:47:59 +0100
commit02956d77786e36418d152ffd256be130e32f4087 (patch)
tree3415503033ae80cd58cc77bf870bacca783a97f6
parent682e49a752fbe71e459f64dfcf12eab127f26516 (diff)
level-example. avoid taking the arrays again for each channel for clarity
Also introduce some blank lines for better readability and update the comments.
-rw-r--r--tests/examples/level/level-example.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/tests/examples/level/level-example.c b/tests/examples/level/level-example.c
index d42e10996..cc7478832 100644
--- a/tests/examples/level/level-example.c
+++ b/tests/examples/level/level-example.c
@@ -40,34 +40,37 @@ message_handler (GstBus * bus, GstMessage * message, gpointer data)
gdouble rms;
const GValue *array_val;
const GValue *value;
- GValueArray *arr;
-
+ GValueArray *rms_arr, *peak_arr, *decay_arr;
gint i;
if (!gst_structure_get_clock_time (s, "endtime", &endtime))
g_warning ("Could not parse endtime");
- /* we can get the number of channels as the length of any of the value
- * lists */
+
+ /* the values are packed into GValueArrays with the value per channel */
array_val = gst_structure_get_value (s, "rms");
- arr = (GValueArray *) g_value_get_boxed (array_val);
- channels = arr->n_values;
+ rms_arr = (GValueArray *) g_value_get_boxed (array_val);
+
+ array_val = gst_structure_get_value (s, "peak");
+ peak_arr = (GValueArray *) g_value_get_boxed (array_val);
+ array_val = gst_structure_get_value (s, "decay");
+ decay_arr = (GValueArray *) g_value_get_boxed (array_val);
+
+ /* we can get the number of channels as the length of any of the value
+ * arrays */
+ channels = rms_arr->n_values;
g_print ("endtime: %" GST_TIME_FORMAT ", channels: %d\n",
GST_TIME_ARGS (endtime), channels);
for (i = 0; i < channels; ++i) {
g_print ("channel %d\n", i);
- array_val = gst_structure_get_value (s, "rms");
- arr = (GValueArray *) g_value_get_boxed (array_val);
- value = g_value_array_get_nth (arr, i);
+ value = g_value_array_get_nth (rms_arr, i);
rms_dB = g_value_get_double (value);
- array_val = gst_structure_get_value (s, "peak");
- arr = (GValueArray *) g_value_get_boxed (array_val);
- value = g_value_array_get_nth (arr, i);
+
+ value = g_value_array_get_nth (peak_arr, i);
peak_dB = g_value_get_double (value);
- array_val = gst_structure_get_value (s, "decay");
- arr = (GValueArray *) g_value_get_boxed (array_val);
- value = g_value_array_get_nth (arr, i);
+
+ value = g_value_array_get_nth (decay_arr, i);
decay_dB = g_value_get_double (value);
g_print (" RMS: %f dB, peak: %f dB, decay: %f dB\n",
rms_dB, peak_dB, decay_dB);