tracerrecord: Be stricter while parsing record templates

It's not really possible for us to recover when someone uses the
gst_tracer_record_new() API incorrectly. Also, document a piece of
somewhat-obscure code.
This commit is contained in:
Nirbheek Chauhan 2019-06-21 10:43:18 +05:30 committed by Nirbheek Chauhan
parent bafa7a5ca7
commit aae5f58dd1

View file

@ -70,7 +70,7 @@ build_field_template (GQuark field_id, const GValue * value, gpointer user_data)
gboolean res;
if (G_VALUE_TYPE (value) != GST_TYPE_STRUCTURE) {
GST_WARNING ("expected field of type GstStructure, but %s is %s",
GST_ERROR ("expected field of type GstStructure, but %s is %s",
g_quark_to_string (field_id), G_VALUE_TYPE_NAME (value));
return FALSE;
}
@ -201,8 +201,11 @@ gst_tracer_record_new (const gchar * name, const gchar * firstfield, ...)
/* all fields passed here must be GstStructures which we take over */
if (type != GST_TYPE_STRUCTURE) {
GST_WARNING ("expected field of type GstStructure, but %s is %s",
GST_ERROR ("expected field of type GstStructure, but %s is %s",
firstfield, g_type_name (type));
va_end (varargs);
gst_structure_free (structure);
return NULL;
}
G_VALUE_COLLECT_INIT (&val, type, varargs, G_VALUE_NOCOPY_CONTENTS, &err);
@ -211,7 +214,9 @@ gst_tracer_record_new (const gchar * name, const gchar * firstfield, ...)
g_free (err);
break;
}
/* see boxed_proxy_collect_value */
/* give ownership of the GstStructure "value" collected from varargs
* to this structure by unsetting the NOCOPY_CONTENTS collect-flag.
* see boxed_proxy_collect_value in glib's gobject/gboxed.c */
val.data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
gst_structure_id_take_value (structure, id, &val);