From 13c4169d9d63928b2e758bfe7618f3d431056081 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Fri, 28 Apr 2006 20:47:23 +0000 Subject: [PATCH] gst/: only write out registry if it has changed, fixes #338339 Original commit message from CVS: * gst/gst.c: * gst/gstregistry.c: (gst_registry_scan_path_level), (gst_registry_scan_path): * gst/gstregistry.h: only write out registry if it has changed, fixes #338339 --- ChangeLog | 3 ++- gst/gst.c | 14 +++++++++----- gst/gstregistry.c | 29 ++++++++++++++++++++++------- gst/gstregistry.h | 2 +- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb888c1b84..1bd46da223 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,7 +29,8 @@ * libs/gst/base/gstbasesink.c: (gst_base_sink_event): * libs/gst/base/gstcollectpads.c: (gst_collect_pads_base_init), (gst_collect_pads_is_collected), (gst_collect_pads_event): - more detailed debug and formatting cleanup + more detailed debug and formatting cleanup, + forward newsegments to src-pad (so that e.g. adder not eats them) 2006-04-28 Stefan Kost diff --git a/gst/gst.c b/gst/gst.c index 1661f5001c..ee8fe3f5d5 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -602,6 +602,7 @@ init_post (void) char *registry_file; const char *plugin_path; GstRegistry *default_registry; + gboolean changed = FALSE; default_registry = gst_registry_get_default (); registry_file = g_strdup (g_getenv ("GST_REGISTRY")); @@ -622,7 +623,7 @@ init_post (void) GST_DEBUG ("GST_PLUGIN_PATH set to %s", plugin_path); list = g_strsplit (plugin_path, G_SEARCHPATH_SEPARATOR_S, 0); for (i = 0; list[i]; i++) { - gst_registry_scan_path (default_registry, list[i]); + changed |= gst_registry_scan_path (default_registry, list[i]); } g_strfreev (list); } else { @@ -642,11 +643,11 @@ init_post (void) * system-installed ones */ home_plugins = g_build_filename (g_get_home_dir (), ".gstreamer-" GST_MAJORMINOR, "plugins", NULL); - gst_registry_scan_path (default_registry, home_plugins); + changed |= gst_registry_scan_path (default_registry, home_plugins); g_free (home_plugins); /* add the main (installed) library path */ - gst_registry_scan_path (default_registry, PLUGINDIR); + changed |= gst_registry_scan_path (default_registry, PLUGINDIR); } else { char **list; int i; @@ -654,12 +655,15 @@ init_post (void) GST_DEBUG ("GST_PLUGIN_SYSTEM_PATH set to %s", plugin_path); list = g_strsplit (plugin_path, G_SEARCHPATH_SEPARATOR_S, 0); for (i = 0; list[i]; i++) { - gst_registry_scan_path (default_registry, list[i]); + changed |= gst_registry_scan_path (default_registry, list[i]); } g_strfreev (list); } - gst_registry_xml_write_cache (default_registry, registry_file); + if (changed) { + GST_DEBUG ("writing registry cache"); + gst_registry_xml_write_cache (default_registry, registry_file); + } _gst_registry_remove_cache_plugins (default_registry); diff --git a/gst/gstregistry.c b/gst/gstregistry.c index a0c02a195d..0d791c0a81 100644 --- a/gst/gstregistry.c +++ b/gst/gstregistry.c @@ -736,7 +736,7 @@ gst_registry_lookup (GstRegistry * registry, const char *filename) return plugin; } -static void +static gboolean gst_registry_scan_path_level (GstRegistry * registry, const gchar * path, int level) { @@ -745,10 +745,11 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path, gchar *filename; GstPlugin *plugin; GstPlugin *newplugin; + gboolean changed = FALSE; dir = g_dir_open (path, 0, NULL); if (!dir) - return; + return FALSE; while ((dirent = g_dir_read_name (dir))) { filename = g_strjoin ("/", path, dirent, NULL); @@ -758,7 +759,7 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path, if (g_file_test (filename, G_FILE_TEST_IS_DIR)) { if (level > 0) { GST_LOG_OBJECT (registry, "found directory, recursing"); - gst_registry_scan_path_level (registry, filename, level - 1); + changed |= gst_registry_scan_path_level (registry, filename, level - 1); } else { GST_LOG_OBJECT (registry, "found directory, but recursion level is too deep"); @@ -819,6 +820,7 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path, newplugin->registered = TRUE; gst_object_unref (newplugin); } + changed = TRUE; } gst_object_unref (plugin); @@ -828,6 +830,7 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path, if (newplugin) { newplugin->registered = TRUE; gst_object_unref (newplugin); + changed = TRUE; } } @@ -835,6 +838,10 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path, } g_dir_close (dir); + + GST_DEBUG_OBJECT (registry, "registry changed? %d", changed); + + return changed; } /** @@ -845,15 +852,23 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path, * Add the given path to the registry. The syntax of the * path is specific to the registry. If the path has already been * added, do nothing. + * + * Returns: %TRUE if registry changed */ -void +gboolean gst_registry_scan_path (GstRegistry * registry, const gchar * path) { - g_return_if_fail (GST_IS_REGISTRY (registry)); - g_return_if_fail (path != NULL); + gboolean changed; + + g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE); + g_return_val_if_fail (path != NULL, FALSE); GST_DEBUG_OBJECT (registry, "scanning path %s", path); - gst_registry_scan_path_level (registry, path, 10); + changed = gst_registry_scan_path_level (registry, path, 10); + + GST_DEBUG_OBJECT (registry, "registry changed? %d", changed); + + return changed; } void diff --git a/gst/gstregistry.h b/gst/gstregistry.h index b24271e48f..9ac1f03d84 100644 --- a/gst/gstregistry.h +++ b/gst/gstregistry.h @@ -78,7 +78,7 @@ GType gst_registry_get_type (void); GstRegistry * gst_registry_get_default (void); -void gst_registry_scan_path (GstRegistry *registry, const gchar *path); +gboolean gst_registry_scan_path (GstRegistry *registry, const gchar *path); GList* gst_registry_get_path_list (GstRegistry *registry); gboolean gst_registry_add_plugin (GstRegistry *registry, GstPlugin *plugin);