static gboolean _gst_enable_registry_fork = DEFAULT_FORK;
static void load_plugin_func (gpointer data, gpointer user_data);
-static gboolean init_pre (GOptionContext * context, GOptionGroup * group,
- gpointer data, GError ** error);
-static gboolean init_post (GOptionContext * context, GOptionGroup * group,
- gpointer data, GError ** error);
+static gboolean init_pre (void);
+static gboolean init_post (void);
static gboolean parse_goption_arg (const gchar * s_opt,
const gchar * arg, gpointer data, GError ** err);
/* we have no fail cases yet, but maybe in the future */
static gboolean
-init_pre (GOptionContext * context, GOptionGroup * group, gpointer data,
- GError ** error)
+init_pre (void)
{
/* GStreamer was built against a GLib >= 2.8 and is therefore not doing
* the refcount hack. Check that it isn't being run against an older GLib */
*/
static gboolean
scan_and_update_registry (GstRegistry * default_registry,
- const gchar * registry_file, gboolean write_changes, GError ** error)
+ const gchar * registry_file, gboolean write_changes)
{
const gchar *plugin_path;
gboolean changed = FALSE;
g_strfreev (list);
}
- /* Remove cached plugins so stale info is cleared. */
- changed |= _priv_gst_registry_remove_cache_plugins (default_registry);
-
if (!changed) {
- GST_INFO ("Registry cache has not changed");
+ GST_DEBUG ("registry cache has not changed");
return TRUE;
}
if (!write_changes) {
- GST_INFO ("Registry cached changed, but writing is disabled. Not writing.");
+ GST_DEBUG ("not trying to write registry cache changes to file");
return TRUE;
}
- GST_INFO ("Registry cache changed. Writing new registry cache");
+ GST_DEBUG ("writing registry cache");
if (!gst_registry_xml_write_cache (default_registry, registry_file)) {
- g_set_error (error, GST_CORE_ERROR, GST_CORE_ERROR_FAILED,
- _("Error writing registry cache to %s: %s"),
- registry_file, g_strerror (errno));
+ g_warning ("Problem writing registry cache to %s: %s", registry_file,
+ g_strerror (errno));
return FALSE;
}
- GST_INFO ("Registry cache written successfully");
+ GST_DEBUG ("registry cache written successfully");
return TRUE;
}
static gboolean
ensure_current_registry_nonforking (GstRegistry * default_registry,
- const gchar * registry_file, GError ** error)
+ const gchar * registry_file)
{
/* fork() not available */
- GST_DEBUG ("Updating registry cache in-process");
- scan_and_update_registry (default_registry, registry_file, TRUE, error);
+ GST_DEBUG ("updating registry cache");
+ scan_and_update_registry (default_registry, registry_file, TRUE);
return TRUE;
}
* TRUE immediatly */
static gboolean
ensure_current_registry_forking (GstRegistry * default_registry,
- const gchar * registry_file, GError ** error)
+ const gchar * registry_file)
{
#ifdef HAVE_FORK
pid_t pid;
/* We fork here, and let the child read and possibly rebuild the registry.
* After that, the parent will re-read the freshly generated registry. */
- GST_DEBUG ("forking to update registry");
+ GST_DEBUG ("forking");
pid = fork ();
if (pid == -1) {
GST_ERROR ("Failed to fork()");
/* this is the child */
GST_DEBUG ("child reading registry cache");
- res =
- scan_and_update_registry (default_registry, registry_file, TRUE, NULL);
+ res = scan_and_update_registry (default_registry, registry_file, TRUE);
+ _gst_registry_remove_cache_plugins (default_registry);
/* need to use _exit, so that any exit handlers registered don't
* bring down the main program */
GST_DEBUG ("parent done waiting on child");
if (ret == -1) {
GST_ERROR ("error during waitpid: %s", g_strerror (errno));
- g_set_error (error, GST_CORE_ERROR, GST_CORE_ERROR_FAILED,
- _("Error re-scanning registry %s: %s"),
- ", waitpid returned error", g_strerror (errno));
return FALSE;
}
if (WIFSIGNALED (status)) {
GST_ERROR ("child did not exit normally, terminated by signal %d",
WTERMSIG (status));
- g_set_error (error, GST_CORE_ERROR, GST_CORE_ERROR_FAILED,
- _("Error re-scanning registry %s: %d"),
- ", child terminated by signal", WTERMSIG (status));
} else {
GST_ERROR ("child did not exit normally, status: %d", status);
- g_set_error (error, GST_CORE_ERROR, GST_CORE_ERROR_FAILED,
- _("Error re-scanning registry %s: %d"),
- ", child did not exit normally, status", status);
}
return FALSE;
}
GST_DEBUG ("parent reading registry cache");
gst_registry_xml_read_cache (default_registry, registry_file);
} else {
- GST_DEBUG ("parent re-scanning registry. Ignoring errors.");
- scan_and_update_registry (default_registry, registry_file, FALSE, NULL);
+ GST_DEBUG ("parent re-scanning registry");
+ scan_and_update_registry (default_registry, registry_file, FALSE);
}
}
#endif /* HAVE_FORK */
}
static gboolean
-ensure_current_registry (GError ** error)
+ensure_current_registry (void)
{
char *registry_file;
GstRegistry *default_registry;
/* now check registry with or without forking */
if (do_fork) {
GST_DEBUG ("forking for registry rebuild");
- ret = ensure_current_registry_forking (default_registry, registry_file,
- error);
+ ret = ensure_current_registry_forking (default_registry, registry_file);
} else {
GST_DEBUG ("requested not to fork for registry rebuild");
- ret = ensure_current_registry_nonforking (default_registry, registry_file,
- error);
+ ret = ensure_current_registry_nonforking (default_registry, registry_file);
}
g_free (registry_file);
* we might and then it's nice to be able to return that
*/
static gboolean
-init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
- GError ** error)
+init_post (void)
{
GLogLevelFlags llf;
gst_initialized = TRUE;
#ifndef GST_DISABLE_REGISTRY
- if (!ensure_current_registry (error))
+ if (!ensure_current_registry ())
return FALSE;
#endif /* GST_DISABLE_REGISTRY */
GSList *list, *walk;
GList *list2, *g;
- /* Need to ensure the registry is loaded to get debug categories */
- if (!init_post (NULL, NULL, NULL, NULL))
+ if (!init_post ())
exit (1);
list2 = gst_registry_plugin_filter (gst_registry_get_default (),
gst_object_unref (clock);
gst_object_unref (clock);
- _priv_gst_registry_cleanup ();
+ _gst_registry_cleanup ();
gst_initialized = FALSE;
GST_INFO ("deinitialized GStreamer");
if (plugin) {
GST_DEBUG_OBJECT (registry, "removing plugin %s",
gst_plugin_get_name (plugin));
- gst_object_unref (plugin);
+ gst_registry_remove_plugin (registry, plugin);
}
p = g_list_next (p);
}
GstPluginFeature *feature = f->data;
if (feature) {
- GST_DEBUG_OBJECT (registry, "removing feature %p (%s)",
- feature, gst_plugin_feature_get_name (feature));
- gst_object_unref (feature);
+ gst_registry_remove_feature (registry, feature);
}
f = g_list_next (f);
}
return TRUE;
}
-static void
-gst_registry_remove_features_for_plugin_unlocked (GstRegistry * registry,
- GstPlugin * plugin)
-{
- GList *f;
-
- g_return_if_fail (GST_IS_REGISTRY (registry));
- g_return_if_fail (GST_IS_PLUGIN (plugin));
-
- /* Remove all features for this plugin */
- f = registry->features;
- while (f != NULL) {
- GList *next = g_list_next (f);
- GstPluginFeature *feature = f->data;
-
- if (feature && !strcmp (feature->plugin_name, gst_plugin_get_name (plugin))) {
- GST_DEBUG_OBJECT (registry, "removing feature %p (%s) for plugin %s",
- feature, gst_plugin_feature_get_name (feature),
- gst_plugin_get_name (plugin));
-
- registry->features = g_list_delete_link (registry->features, f);
- gst_object_unref (feature);
- }
- f = next;
- }
-}
-
/**
* gst_registry_remove_plugin:
* @registry: the registry to remove the plugin from
g_return_if_fail (GST_IS_REGISTRY (registry));
g_return_if_fail (GST_IS_PLUGIN (plugin));
- GST_DEBUG_OBJECT (registry, "removing plugin %p (%s)",
- plugin, gst_plugin_get_name (plugin));
-
GST_OBJECT_LOCK (registry);
registry->plugins = g_list_remove (registry->plugins, plugin);
- gst_registry_remove_features_for_plugin_unlocked (registry, plugin);
GST_OBJECT_UNLOCK (registry);
gst_object_unref (plugin);
}
g_dir_close (dir);
+ GST_DEBUG_OBJECT (registry, "registry changed? %d", changed);
+
return changed;
}
GST_DEBUG_OBJECT (registry, "scanning path %s", path);
changed = gst_registry_scan_path_level (registry, path, 10);
- GST_DEBUG_OBJECT (registry, "registry changed in path %s: %d", path, changed);
+ GST_DEBUG_OBJECT (registry, "registry changed? %d", changed);
return changed;
}
-/* Unref all plugins marked 'cached', to clear old plugins that no
- * longer exist. Returns TRUE if any plugins were removed */
-gboolean
-_priv_gst_registry_remove_cache_plugins (GstRegistry * registry)
+void
+_gst_registry_remove_cache_plugins (GstRegistry * registry)
{
GList *g;
GList *g_next;
GstPlugin *plugin;
- gboolean changed = FALSE;
- g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
+ g_return_if_fail (GST_IS_REGISTRY (registry));
GST_OBJECT_LOCK (registry);
if (plugin->flags & GST_PLUGIN_FLAG_CACHED) {
GST_DEBUG_OBJECT (registry, "removing cached plugin \"%s\"",
GST_STR_NULL (plugin->filename));
- registry->plugins = g_list_delete_link (registry->plugins, g);
+ /* seems it would be sufficient just to do a delete_link for o(1) deletion
+ * -- we have to traverse the whole list anyway, and dup entries (if
+ * possible) should have dup refcounts */
+ registry->plugins = g_list_remove (registry->plugins, plugin);
gst_object_unref (plugin);
- changed = TRUE;
}
g = g_next;
}
GST_OBJECT_UNLOCK (registry);
-
- return changed;
}
_gst_plugin_feature_filter_plugin_name, FALSE, (gpointer) name);
}
-/* Unref and delete the default registry */
void
-_priv_gst_registry_cleanup ()
+_gst_registry_cleanup ()
{
GstRegistry *registry;