Enable/disable scan_and_update_registry() based on commandline switch or environment variable. Fixes #520468.
Original commit message from CVS:
patch by: Jason Zhao <e3423c@motorola.com>
* docs/gst/running.xml:
* gst/gst.c:
Enable/disable scan_and_update_registry() based on commandline switch
or environment variable. Fixes #520468.
* ChangeLog:
Fix typo in my previous commit.
diff --git a/ChangeLog b/ChangeLog
index 8640143..c8ffe4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,19 @@
2008-04-24 Stefan Kost <ensonic@users.sf.net>
+ patch by: Jason Zhao <e3423c@motorola.com>
+
+ * docs/gst/running.xml:
+ * gst/gst.c:
+ Enable/disable scan_and_update_registry() based on commandline switch
+ or environment variable. Fixes #520468.
+
+ * ChangeLog:
+ Fix typo in my previous commit.
+
+2008-04-24 Stefan Kost <ensonic@users.sf.net>
+
* gst/gstregistrybinary.c:
- Add a warning of we hit unhandled factories when saving.
+ Add a warning if we hit unhandled factories when saving.
More debug logging detail, but move to LOG category.
2008-04-24 Stefan Kost <ensonic@users.sf.net>
diff --git a/docs/gst/running.xml b/docs/gst/running.xml
index 742279f..75655d7 100644
--- a/docs/gst/running.xml
+++ b/docs/gst/running.xml
@@ -204,6 +204,17 @@
</formalpara>
+<formalpara id="GST_REGISTRY_UPDATE">
+ <title><envar>GST_REGISTRY_UPDATE</envar></title>
+
+ <para>
+Set this environment variable to "no" to prevent GStreamer from updating the
+plugin registry. This is useful for embedded device which is not updating the
+plugins frequently, it will save time when doing gst_init().
+ </para>
+
+</formalpara>
+
</refsect2>
</refsect1>
diff --git a/gst/gst.c b/gst/gst.c
index e0ea74c..7c89abb 100644
--- a/gst/gst.c
+++ b/gst/gst.c
@@ -151,6 +151,9 @@
/* control the behaviour of registry rebuild */
static gboolean _gst_enable_registry_fork = DEFAULT_FORK;
+/*set to TRUE when registry needn't to be updated */
+static gboolean _gst_disable_registry_update = FALSE;
+
static void load_plugin_func (gpointer data, gpointer user_data);
static gboolean init_pre (GOptionContext * context, GOptionGroup * group,
gpointer data, GError ** error);
@@ -190,6 +193,7 @@
ARG_PLUGIN_PATH,
ARG_PLUGIN_LOAD,
ARG_SEGTRAP_DISABLE,
+ ARG_REGISTRY_UPDATE_DISABLE,
ARG_REGISTRY_FORK_DISABLE
};
@@ -340,6 +344,11 @@
(gpointer) parse_goption_arg,
N_("Disable trapping of segmentation faults during plugin loading"),
NULL},
+ {"gst-disable-registry-update", 0, G_OPTION_FLAG_NO_ARG,
+ G_OPTION_ARG_CALLBACK,
+ (gpointer) parse_goption_arg,
+ N_("Disable updating the registry"),
+ NULL},
{"gst-disable-registry-fork", 0, G_OPTION_FLAG_NO_ARG,
G_OPTION_ARG_CALLBACK,
(gpointer) parse_goption_arg,
@@ -754,12 +763,6 @@
const gchar * registry_file, GError ** error)
{
/* fork() not available */
- GST_INFO ("reading registry cache: %s", registry_file);
-#ifdef USE_BINARY_REGISTRY
- gst_registry_binary_read_cache (default_registry, registry_file);
-#else
- gst_registry_xml_read_cache (default_registry, registry_file);
-#endif
GST_DEBUG ("Updating registry cache in-process");
scan_and_update_registry (default_registry, registry_file, TRUE, error);
return TRUE;
@@ -787,13 +790,6 @@
return FALSE;
}
- GST_INFO ("reading registry cache: %s", registry_file);
-#ifdef USE_BINARY_REGISTRY
- gst_registry_binary_read_cache (default_registry, registry_file);
-#else
- gst_registry_xml_read_cache (default_registry, registry_file);
-#endif
-
pid = fork ();
if (pid == -1) {
GST_ERROR ("Failed to fork()");
@@ -882,10 +878,11 @@
static gboolean
ensure_current_registry (GError ** error)
{
- char *registry_file;
+ gchar *registry_file;
GstRegistry *default_registry;
- gboolean ret;
+ gboolean ret = TRUE;
gboolean do_fork;
+ gboolean do_update;
default_registry = gst_registry_get_default ();
registry_file = g_strdup (g_getenv ("GST_REGISTRY"));
@@ -899,30 +896,50 @@
#endif
}
- /* first see if forking is enabled */
- do_fork = _gst_enable_registry_fork;
- if (do_fork) {
- const gchar *fork_env;
+ GST_INFO ("reading registry cache: %s", registry_file);
+#ifdef USE_BINARY_REGISTRY
+ gst_registry_binary_read_cache (default_registry, registry_file);
+#else
+ gst_registry_xml_read_cache (default_registry, registry_file);
+#endif
- /* forking enabled, see if it is disabled with an env var */
- if ((fork_env = g_getenv ("GST_REGISTRY_FORK"))) {
- /* fork enabled for any value different from "no" */
- do_fork = strcmp (fork_env, "no") != 0;
+ do_update = !_gst_disable_registry_update;
+ if (do_update) {
+ const gchar *update_env;
+
+ if ((update_env = g_getenv ("GST_REGISTRY_UPDATE"))) {
+ /* do update for any value different from "no" */
+ do_update = (strcmp (update_env, "no") != 0);
}
}
- /* 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);
- } else {
- GST_DEBUG ("requested not to fork for registry rebuild");
- ret = ensure_current_registry_nonforking (default_registry, registry_file,
- error);
+ if (do_update) {
+ /* first see if forking is enabled */
+ do_fork = _gst_enable_registry_fork;
+ if (do_fork) {
+ const gchar *fork_env;
+
+ /* forking enabled, see if it is disabled with an env var */
+ if ((fork_env = g_getenv ("GST_REGISTRY_FORK"))) {
+ /* fork enabled for any value different from "no" */
+ do_fork = strcmp (fork_env, "no") != 0;
+ }
+ }
+
+ /* 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);
+ } else {
+ GST_DEBUG ("requested not to fork for registry rebuild");
+ ret = ensure_current_registry_nonforking (default_registry, registry_file,
+ error);
+ }
}
g_free (registry_file);
+ GST_INFO ("registry reading and updating done, result = %d", ret);
return ret;
}
@@ -1203,6 +1220,9 @@
case ARG_SEGTRAP_DISABLE:
_gst_disable_segtrap = TRUE;
break;
+ case ARG_REGISTRY_UPDATE_DISABLE:
+ _gst_disable_registry_update = TRUE;
+ break;
case ARG_REGISTRY_FORK_DISABLE:
_gst_enable_registry_fork = FALSE;
break;
@@ -1240,6 +1260,7 @@
"--gst-plugin-path", ARG_PLUGIN_PATH}, {
"--gst-plugin-load", ARG_PLUGIN_LOAD}, {
"--gst-disable-segtrap", ARG_SEGTRAP_DISABLE}, {
+ "--gst-disable-registry-update", ARG_REGISTRY_UPDATE_DISABLE}, {
"--gst-disable-registry-fork", ARG_REGISTRY_FORK_DISABLE}, {
NULL}
};