mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 12:10:37 +00:00
level-example. avoid taking the arrays again for each channel for clarity
Also introduce some blank lines for better readability and update the comments.
This commit is contained in:
parent
682e49a752
commit
02956d7778
1 changed files with 19 additions and 16 deletions
|
@ -40,34 +40,37 @@ message_handler (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
gdouble rms;
|
gdouble rms;
|
||||||
const GValue *array_val;
|
const GValue *array_val;
|
||||||
const GValue *value;
|
const GValue *value;
|
||||||
GValueArray *arr;
|
GValueArray *rms_arr, *peak_arr, *decay_arr;
|
||||||
|
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
if (!gst_structure_get_clock_time (s, "endtime", &endtime))
|
if (!gst_structure_get_clock_time (s, "endtime", &endtime))
|
||||||
g_warning ("Could not parse endtime");
|
g_warning ("Could not parse endtime");
|
||||||
/* we can get the number of channels as the length of any of the value
|
|
||||||
* lists */
|
|
||||||
array_val = gst_structure_get_value (s, "rms");
|
|
||||||
arr = (GValueArray *) g_value_get_boxed (array_val);
|
|
||||||
channels = arr->n_values;
|
|
||||||
|
|
||||||
|
/* the values are packed into GValueArrays with the value per channel */
|
||||||
|
array_val = gst_structure_get_value (s, "rms");
|
||||||
|
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",
|
g_print ("endtime: %" GST_TIME_FORMAT ", channels: %d\n",
|
||||||
GST_TIME_ARGS (endtime), channels);
|
GST_TIME_ARGS (endtime), channels);
|
||||||
for (i = 0; i < channels; ++i) {
|
for (i = 0; i < channels; ++i) {
|
||||||
|
|
||||||
g_print ("channel %d\n", i);
|
g_print ("channel %d\n", i);
|
||||||
array_val = gst_structure_get_value (s, "rms");
|
value = g_value_array_get_nth (rms_arr, i);
|
||||||
arr = (GValueArray *) g_value_get_boxed (array_val);
|
|
||||||
value = g_value_array_get_nth (arr, i);
|
|
||||||
rms_dB = g_value_get_double (value);
|
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 (peak_arr, i);
|
||||||
value = g_value_array_get_nth (arr, i);
|
|
||||||
peak_dB = g_value_get_double (value);
|
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 (decay_arr, i);
|
||||||
value = g_value_array_get_nth (arr, i);
|
|
||||||
decay_dB = g_value_get_double (value);
|
decay_dB = g_value_get_double (value);
|
||||||
g_print (" RMS: %f dB, peak: %f dB, decay: %f dB\n",
|
g_print (" RMS: %f dB, peak: %f dB, decay: %f dB\n",
|
||||||
rms_dB, peak_dB, decay_dB);
|
rms_dB, peak_dB, decay_dB);
|
||||||
|
|
Loading…
Reference in a new issue