gst: Don't intercept --help in gst_init()
[platform/upstream/gstreamer.git] / gst / gst.c
index c56bd50..950fc18 100644 (file)
--- a/gst/gst.c
+++ b/gst/gst.c
@@ -16,8 +16,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 /**
@@ -71,9 +71,6 @@
  *       N_("Output tags (also known as metadata)"), NULL},
  *   {NULL}
  *  };
- *  // must initialise the threading system before using any other GLib funtion
- *  if (!g_thread_supported ())
- *    g_thread_init (NULL);
  *  ctx = g_option_context_new ("[ADDITIONAL ARGUMENTS]");
  *  g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
  *  g_option_context_add_group (ctx, gst_init_get_option_group ());
@@ -139,7 +136,7 @@ extern gboolean _priv_gst_disable_registry_update;
 #endif
 
 #ifndef GST_DISABLE_GST_DEBUG
-extern const gchar *priv_gst_dump_dot_dir;
+const gchar *priv_gst_dump_dot_dir;
 #endif
 
 /* defaults */
@@ -195,82 +192,6 @@ enum
  * val ::= [0-5]
  */
 
-#ifndef NUL
-#define NUL '\0'
-#endif
-
-#ifndef GST_DISABLE_GST_DEBUG
-static gboolean
-parse_debug_category (gchar * str, const gchar ** category)
-{
-  if (!str)
-    return FALSE;
-
-  /* works in place */
-  g_strstrip (str);
-
-  if (str[0] != NUL) {
-    *category = str;
-    return TRUE;
-  }
-
-  return FALSE;
-}
-
-static gboolean
-parse_debug_level (gchar * str, GstDebugLevel * level)
-{
-  if (!str)
-    return FALSE;
-
-  /* works in place */
-  g_strstrip (str);
-
-  if (str[0] != NUL && str[1] == NUL
-      && str[0] >= '0' && str[0] < '0' + GST_LEVEL_COUNT) {
-    *level = (GstDebugLevel) (str[0] - '0');
-    return TRUE;
-  }
-
-  return FALSE;
-}
-
-static void
-parse_debug_list (const gchar * list)
-{
-  gchar **split;
-  gchar **walk;
-
-  g_assert (list);
-
-  split = g_strsplit (list, ",", 0);
-
-  for (walk = split; *walk; walk++) {
-    if (strchr (*walk, ':')) {
-      gchar **values = g_strsplit (*walk, ":", 2);
-
-      if (values[0] && values[1]) {
-        GstDebugLevel level;
-        const gchar *category;
-
-        if (parse_debug_category (values[0], &category)
-            && parse_debug_level (values[1], &level))
-          gst_debug_set_threshold_for_name (category, level);
-      }
-
-      g_strfreev (values);
-    } else {
-      GstDebugLevel level;
-
-      if (parse_debug_level (*walk, &level))
-        gst_debug_set_default_threshold (level);
-    }
-  }
-
-  g_strfreev (split);
-}
-#endif
-
 #ifdef G_OS_WIN32
 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
 BOOL WINAPI
@@ -388,10 +309,6 @@ gst_init_get_option_group (void)
  * for some reason.  If you want your program to fail fatally,
  * use gst_init() instead.
  *
- * This function should be called before calling any other GLib functions. If
- * this is not an option, your program must initialise the GLib thread system
- * using g_thread_init() before any other GLib functions are called.
- *
  * Returns: %TRUE if GStreamer could be initialized.
  */
 gboolean
@@ -410,6 +327,7 @@ gst_init_check (int *argc, char **argv[], GError ** err)
 #ifndef GST_DISABLE_OPTION_PARSING
   ctx = g_option_context_new ("- GStreamer initialization");
   g_option_context_set_ignore_unknown_options (ctx, TRUE);
+  g_option_context_set_help_enabled (ctx, FALSE);
   group = gst_init_get_option_group ();
   g_option_context_add_group (ctx, group);
   res = g_option_context_parse (ctx, argc, argv, err);
@@ -446,10 +364,6 @@ gst_init_check (int *argc, char **argv[], GError ** err)
  * <link linkend="gst-running">Running GStreamer Applications</link>
  * for how to disable automatic registry updates.
  *
- * This function should be called before calling any other GLib functions. If
- * this is not an option, your program must initialise the GLib thread system
- * using g_thread_init() before any other GLib functions are called.
- *
  * <note><para>
  * This function will terminate your program if it was unable to initialize
  * GStreamer for some reason.  If you want your program to fall back,
@@ -483,8 +397,6 @@ gst_init (int *argc, char **argv[])
  * or gst_init_check().
  *
  * Returns: TRUE if initialization has been done, FALSE otherwise.
- *
- * Since: 0.10.31
  */
 gboolean
 gst_is_initialized (void)
@@ -547,15 +459,15 @@ init_pre (GOptionContext * context, GOptionGroup * group, gpointer data,
     GST_DEBUG ("already initialized");
     return TRUE;
   }
-
+#if !GLIB_CHECK_VERSION(2, 35, 0)
   g_type_init ();
+#endif
 
 #ifndef GST_DISABLE_GST_DEBUG
   _priv_gst_debug_init ();
 #endif
 
 #ifdef ENABLE_NLS
-  setlocale (LC_ALL, "");
   bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 #endif /* ENABLE_NLS */
@@ -569,7 +481,7 @@ init_pre (GOptionContext * context, GOptionGroup * group, gpointer data,
 
     debug_list = g_getenv ("GST_DEBUG");
     if (debug_list) {
-      parse_debug_list (debug_list);
+      gst_debug_set_threshold_from_string (debug_list, FALSE);
     }
   }
 
@@ -593,6 +505,11 @@ init_pre (GOptionContext * context, GOptionGroup * group, gpointer data,
   }
 #endif
 
+#ifndef G_ATOMIC_LOCK_FREE
+  GST_CAT_WARNING (GST_CAT_PERFORMANCE, "GLib atomic operations are NOT "
+      "implemented using real hardware atomic operations!");
+#endif
+
   return TRUE;
 }
 
@@ -635,7 +552,9 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
   llf = G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL;
   g_log_set_handler (g_log_domain_gstreamer, llf, debug_log_handler, NULL);
 
+#ifndef GST_DISABLE_TRACE
   _priv_gst_alloc_trace_initialize ();
+#endif
 
   _priv_gst_mini_object_initialize ();
   _priv_gst_quarks_initialize ();
@@ -644,6 +563,7 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
   _priv_gst_query_initialize ();
   _priv_gst_structure_initialize ();
   _priv_gst_caps_initialize ();
+  _priv_gst_caps_features_initialize ();
   _priv_gst_meta_initialize ();
 
   g_type_class_ref (gst_object_get_type ());
@@ -682,7 +602,6 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
   g_type_class_ref (gst_event_type_get_type ());
   g_type_class_ref (gst_seek_type_get_type ());
   g_type_class_ref (gst_seek_flags_get_type ());
-  g_type_class_ref (gst_stream_config_flags_get_type ());
   g_type_class_ref (gst_qos_type_get_type ());
   g_type_class_ref (gst_format_get_type ());
   g_type_class_ref (gst_debug_level_get_type ());
@@ -711,6 +630,7 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
   g_type_class_ref (gst_structure_change_type_get_type ());
   g_type_class_ref (gst_tag_merge_mode_get_type ());
   g_type_class_ref (gst_tag_flag_get_type ());
+  g_type_class_ref (gst_tag_scope_get_type ());
   g_type_class_ref (gst_task_pool_get_type ());
   g_type_class_ref (gst_task_state_get_type ());
   g_type_class_ref (gst_toc_entry_type_get_type ());
@@ -731,9 +651,12 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
   g_type_class_ref (gst_scheduling_flags_get_type ());
   g_type_class_ref (gst_meta_flags_get_type ());
   g_type_class_ref (gst_toc_entry_type_get_type ());
-
+  g_type_class_ref (gst_toc_scope_get_type ());
   g_type_class_ref (gst_control_binding_get_type ());
   g_type_class_ref (gst_control_source_get_type ());
+  g_type_class_ref (gst_lock_flags_get_type ());
+  g_type_class_ref (gst_allocator_flags_get_type ());
+  g_type_class_ref (gst_stream_flags_get_type ());
 
   _priv_gst_event_initialize ();
   _priv_gst_buffer_initialize ();
@@ -741,10 +664,10 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
   _priv_gst_buffer_list_initialize ();
   _priv_gst_sample_initialize ();
   _priv_gst_value_initialize ();
+  _priv_gst_context_initialize ();
 
   g_type_class_ref (gst_param_spec_fraction_get_type ());
   _priv_gst_tag_initialize ();
-  _priv_gst_toc_initialize ();
   gst_parse_context_get_type ();
 
   _priv_gst_plugin_initialize ();
@@ -887,7 +810,7 @@ parse_one_option (gint opt, const gchar * arg, GError ** err)
       break;
     }
     case ARG_DEBUG:
-      parse_debug_list (arg);
+      gst_debug_set_threshold_from_string (arg, FALSE);
       break;
     case ARG_DEBUG_NO_COLOR:
       gst_debug_set_colored (FALSE);
@@ -1011,7 +934,9 @@ gst_deinit (void)
 
   _priv_gst_registry_cleanup ();
 
+#ifndef GST_DISABLE_TRACE
   _priv_gst_alloc_trace_deinit ();
+#endif
 
   g_type_class_unref (g_type_class_peek (gst_object_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_pad_get_type ()));
@@ -1044,7 +969,6 @@ gst_deinit (void)
   g_type_class_unref (g_type_class_peek (gst_parse_flags_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_resource_error_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_search_mode_get_type ()));
-  g_type_class_unref (g_type_class_peek (gst_stream_config_flags_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_stream_error_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_stream_status_type_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_structure_change_type_get_type
@@ -1079,8 +1003,10 @@ gst_deinit (void)
   g_type_class_unref (g_type_class_peek (gst_buffering_mode_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_tag_merge_mode_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_tag_flag_get_type ()));
+  g_type_class_unref (g_type_class_peek (gst_tag_scope_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_task_state_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_toc_entry_type_get_type ()));
+  g_type_class_unref (g_type_class_peek (gst_toc_scope_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_type_find_probability_get_type
           ()));
   g_type_class_unref (g_type_class_peek (gst_uri_type_get_type ()));
@@ -1101,6 +1027,10 @@ gst_deinit (void)
   g_type_class_unref (g_type_class_peek (gst_control_binding_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_control_source_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_toc_entry_type_get_type ()));
+  g_type_class_unref (g_type_class_peek (gst_lock_flags_get_type ()));
+  g_type_class_unref (g_type_class_peek (gst_allocator_flags_get_type ()));
+  g_type_class_unref (g_type_class_peek (gst_stream_flags_get_type ()));
+
 
   gst_deinitialized = TRUE;
   GST_INFO ("deinitialized GStreamer");
@@ -1166,8 +1096,6 @@ gst_version_string (void)
  * wants to install its own handler without GStreamer interfering.
  *
  * Returns: %TRUE if GStreamer is allowed to install a custom SIGSEGV handler.
- *
- * Since: 0.10.10
  */
 gboolean
 gst_segtrap_is_enabled (void)
@@ -1182,8 +1110,6 @@ gst_segtrap_is_enabled (void)
  *
  * Applications might want to disable/enable the SIGSEGV handling of
  * the GStreamer core. See gst_segtrap_is_enabled() for more information.
- *
- * Since: 0.10.10
  */
 void
 gst_segtrap_set_enabled (gboolean enabled)