Use macros to register boxed types thread safely
[platform/upstream/gstreamer.git] / gst / gstparse.c
index 839d08e..3e6714d 100644 (file)
@@ -31,7 +31,7 @@
  *
  * Please note that these functions take several measures to create
  * somewhat dynamic pipelines. Due to that such pipelines are not always
- * reuseable (set the state to NULL and back to PLAYING).
+ * reusable (set the state to NULL and back to PLAYING).
  */
 
 #include "gst_private.h"
 #include "parse/types.h"
 #endif
 
-static void
-_prepend_missing_element (gchar * element, GList ** list)
-{
-  *list = g_list_prepend (*list, g_strdup (element));
-}
-
 static GstParseContext *
 gst_parse_context_copy (const GstParseContext * context)
 {
@@ -58,27 +52,21 @@ gst_parse_context_copy (const GstParseContext * context)
 
   ret = gst_parse_context_new ();
   if (context) {
-    g_list_foreach (context->missing_elements, (GFunc) _prepend_missing_element,
-        &ret->missing_elements);
-    ret->missing_elements = g_list_reverse (ret->missing_elements);
+    GQueue missing_copy = G_QUEUE_INIT;
+    GList *l;
+
+    for (l = context->missing_elements; l != NULL; l = l->next)
+      g_queue_push_tail (&missing_copy, g_strdup ((const gchar *) l->data));
+
+    ret->missing_elements = missing_copy.head;
   }
 #endif
   return ret;
 }
 
-GType
-gst_parse_context_get_type (void)
-{
-  static GType type = 0;
-
-  if (G_UNLIKELY (type == 0)) {
-    type = g_boxed_type_register_static ("GstParseContext",
-        (GBoxedCopyFunc) gst_parse_context_copy,
-        (GBoxedFreeFunc) gst_parse_context_free);
-  }
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GstParseContext, gst_parse_context,
+    (GBoxedCopyFunc) gst_parse_context_copy,
+    (GBoxedFreeFunc) gst_parse_context_free);
 
 /**
  * gst_parse_error_quark:
@@ -292,7 +280,7 @@ gst_parse_launchv_full (const gchar ** argv, GstParseContext * context,
  * the @error is set. In this case there was a recoverable parsing error and you
  * can try to play the pipeline.
  *
- * Returns: (transfer full): a new element on success, %NULL on failure. If
+ * Returns: (transfer floating): a new element on success, %NULL on failure. If
  *    more than one toplevel element is specified by the @pipeline_description,
  *   all elements are put into a #GstPipeline, which than is returned.
  */
@@ -335,7 +323,7 @@ gst_parse_launch_full (const gchar * pipeline_description,
   GST_CAT_INFO (GST_CAT_PIPELINE, "parsing pipeline description '%s'",
       pipeline_description);
 
-  element = _gst_parse_launch (pipeline_description, error, context, flags);
+  element = priv_gst_parse_launch (pipeline_description, error, context, flags);
 
   /* don't return partially constructed pipeline if FATAL_ERRORS was given */
   if (G_UNLIKELY (error != NULL && *error != NULL && element != NULL)) {