/** * gst_init_check: * @argc: (inout) (allow-none): pointer to application's argc * @argv: (inout) (array length=argc) (allow-none): pointer to application's argv * @err: pointer to a #GError to which a message will be posted on error * * Initializes the GStreamer library, setting up internal path lists, * registering built-in elements, and loading standard plugins. * * This function will return %FALSE if GStreamer could not be initialized * 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 gst_init_check (int *argc, char **argv[], GError ** err) { #ifndef GST_DISABLE_OPTION_PARSING GOptionGroup *group; GOptionContext *ctx; #endif gboolean res; if (!g_thread_get_initialized ()) g_thread_init (NULL); if (gst_initialized) { GST_DEBUG ("already initialized gst"); return TRUE; } #ifndef GST_DISABLE_OPTION_PARSING ctx = g_option_context_new ("- GStreamer initialization"); g_option_context_set_ignore_unknown_options (ctx, TRUE); group = gst_init_get_option_group (); g_option_context_add_group (ctx, group); res = g_option_context_parse (ctx, argc, argv, err); g_option_context_free (ctx); #else init_pre (NULL, NULL, NULL, NULL); init_post (NULL, NULL, NULL, NULL); res = TRUE; #endif gst_initialized = res; if (res) { GST_INFO ("initialized GStreamer successfully"); } else { GST_INFO ("failed to initialize GStreamer"); } return res; }
/** * gst_init_check: * @argc: (inout) (allow-none): pointer to application's argc * @argv: (inout) (array length=argc) (allow-none): pointer to application's argv * @err: pointer to a #GError to which a message will be posted on error * * Initializes the GStreamer library, setting up internal path lists, * registering built-in elements, and loading standard plugins. * * This function will return %FALSE if GStreamer could not be initialized * for some reason. If you want your program to fail fatally, * use gst_init() instead. * * Returns: %TRUE if GStreamer could be initialized. */ gboolean gst_init_check (int *argc, char **argv[], GError ** err) { static GMutex init_lock; #ifndef GST_DISABLE_OPTION_PARSING GOptionGroup *group; GOptionContext *ctx; #endif gboolean res; g_mutex_lock (&init_lock); if (gst_initialized) { GST_DEBUG ("already initialized gst"); g_mutex_unlock (&init_lock); return TRUE; } #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); g_option_context_free (ctx); #else init_pre (NULL, NULL, NULL, NULL); init_post (NULL, NULL, NULL, NULL); res = TRUE; #endif gst_initialized = res; g_mutex_unlock (&init_lock); return res; }