mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 23:06:49 +00:00
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.
This commit is contained in:
parent
c7acfbaf43
commit
d9c9c264e2
3 changed files with 77 additions and 33 deletions
14
ChangeLog
14
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>
|
2008-04-24 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
* gst/gstregistrybinary.c:
|
* 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.
|
More debug logging detail, but move to LOG category.
|
||||||
|
|
||||||
2008-04-24 Stefan Kost <ensonic@users.sf.net>
|
2008-04-24 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
|
@ -204,6 +204,17 @@ application.
|
||||||
|
|
||||||
</formalpara>
|
</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>
|
</refsect2>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
85
gst/gst.c
85
gst/gst.c
|
@ -151,6 +151,9 @@ static gboolean _gst_disable_segtrap = FALSE;
|
||||||
/* control the behaviour of registry rebuild */
|
/* control the behaviour of registry rebuild */
|
||||||
static gboolean _gst_enable_registry_fork = DEFAULT_FORK;
|
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 void load_plugin_func (gpointer data, gpointer user_data);
|
||||||
static gboolean init_pre (GOptionContext * context, GOptionGroup * group,
|
static gboolean init_pre (GOptionContext * context, GOptionGroup * group,
|
||||||
gpointer data, GError ** error);
|
gpointer data, GError ** error);
|
||||||
|
@ -190,6 +193,7 @@ enum
|
||||||
ARG_PLUGIN_PATH,
|
ARG_PLUGIN_PATH,
|
||||||
ARG_PLUGIN_LOAD,
|
ARG_PLUGIN_LOAD,
|
||||||
ARG_SEGTRAP_DISABLE,
|
ARG_SEGTRAP_DISABLE,
|
||||||
|
ARG_REGISTRY_UPDATE_DISABLE,
|
||||||
ARG_REGISTRY_FORK_DISABLE
|
ARG_REGISTRY_FORK_DISABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -340,6 +344,11 @@ gst_init_get_option_group (void)
|
||||||
(gpointer) parse_goption_arg,
|
(gpointer) parse_goption_arg,
|
||||||
N_("Disable trapping of segmentation faults during plugin loading"),
|
N_("Disable trapping of segmentation faults during plugin loading"),
|
||||||
NULL},
|
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,
|
{"gst-disable-registry-fork", 0, G_OPTION_FLAG_NO_ARG,
|
||||||
G_OPTION_ARG_CALLBACK,
|
G_OPTION_ARG_CALLBACK,
|
||||||
(gpointer) parse_goption_arg,
|
(gpointer) parse_goption_arg,
|
||||||
|
@ -754,12 +763,6 @@ ensure_current_registry_nonforking (GstRegistry * default_registry,
|
||||||
const gchar * registry_file, GError ** error)
|
const gchar * registry_file, GError ** error)
|
||||||
{
|
{
|
||||||
/* fork() not available */
|
/* 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");
|
GST_DEBUG ("Updating registry cache in-process");
|
||||||
scan_and_update_registry (default_registry, registry_file, TRUE, error);
|
scan_and_update_registry (default_registry, registry_file, TRUE, error);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -787,13 +790,6 @@ ensure_current_registry_forking (GstRegistry * default_registry,
|
||||||
return FALSE;
|
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 ();
|
pid = fork ();
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
GST_ERROR ("Failed to fork()");
|
GST_ERROR ("Failed to fork()");
|
||||||
|
@ -882,10 +878,11 @@ ensure_current_registry_forking (GstRegistry * default_registry,
|
||||||
static gboolean
|
static gboolean
|
||||||
ensure_current_registry (GError ** error)
|
ensure_current_registry (GError ** error)
|
||||||
{
|
{
|
||||||
char *registry_file;
|
gchar *registry_file;
|
||||||
GstRegistry *default_registry;
|
GstRegistry *default_registry;
|
||||||
gboolean ret;
|
gboolean ret = TRUE;
|
||||||
gboolean do_fork;
|
gboolean do_fork;
|
||||||
|
gboolean do_update;
|
||||||
|
|
||||||
default_registry = gst_registry_get_default ();
|
default_registry = gst_registry_get_default ();
|
||||||
registry_file = g_strdup (g_getenv ("GST_REGISTRY"));
|
registry_file = g_strdup (g_getenv ("GST_REGISTRY"));
|
||||||
|
@ -899,30 +896,50 @@ ensure_current_registry (GError ** error)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* first see if forking is enabled */
|
GST_INFO ("reading registry cache: %s", registry_file);
|
||||||
do_fork = _gst_enable_registry_fork;
|
#ifdef USE_BINARY_REGISTRY
|
||||||
if (do_fork) {
|
gst_registry_binary_read_cache (default_registry, registry_file);
|
||||||
const gchar *fork_env;
|
#else
|
||||||
|
gst_registry_xml_read_cache (default_registry, registry_file);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* forking enabled, see if it is disabled with an env var */
|
do_update = !_gst_disable_registry_update;
|
||||||
if ((fork_env = g_getenv ("GST_REGISTRY_FORK"))) {
|
if (do_update) {
|
||||||
/* fork enabled for any value different from "no" */
|
const gchar *update_env;
|
||||||
do_fork = strcmp (fork_env, "no") != 0;
|
|
||||||
|
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_update) {
|
||||||
if (do_fork) {
|
/* first see if forking is enabled */
|
||||||
GST_DEBUG ("forking for registry rebuild");
|
do_fork = _gst_enable_registry_fork;
|
||||||
ret = ensure_current_registry_forking (default_registry, registry_file,
|
if (do_fork) {
|
||||||
error);
|
const gchar *fork_env;
|
||||||
} else {
|
|
||||||
GST_DEBUG ("requested not to fork for registry rebuild");
|
/* forking enabled, see if it is disabled with an env var */
|
||||||
ret = ensure_current_registry_nonforking (default_registry, registry_file,
|
if ((fork_env = g_getenv ("GST_REGISTRY_FORK"))) {
|
||||||
error);
|
/* 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);
|
g_free (registry_file);
|
||||||
|
GST_INFO ("registry reading and updating done, result = %d", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1203,6 +1220,9 @@ parse_one_option (gint opt, const gchar * arg, GError ** err)
|
||||||
case ARG_SEGTRAP_DISABLE:
|
case ARG_SEGTRAP_DISABLE:
|
||||||
_gst_disable_segtrap = TRUE;
|
_gst_disable_segtrap = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case ARG_REGISTRY_UPDATE_DISABLE:
|
||||||
|
_gst_disable_registry_update = TRUE;
|
||||||
|
break;
|
||||||
case ARG_REGISTRY_FORK_DISABLE:
|
case ARG_REGISTRY_FORK_DISABLE:
|
||||||
_gst_enable_registry_fork = FALSE;
|
_gst_enable_registry_fork = FALSE;
|
||||||
break;
|
break;
|
||||||
|
@ -1240,6 +1260,7 @@ parse_goption_arg (const gchar * opt,
|
||||||
"--gst-plugin-path", ARG_PLUGIN_PATH}, {
|
"--gst-plugin-path", ARG_PLUGIN_PATH}, {
|
||||||
"--gst-plugin-load", ARG_PLUGIN_LOAD}, {
|
"--gst-plugin-load", ARG_PLUGIN_LOAD}, {
|
||||||
"--gst-disable-segtrap", ARG_SEGTRAP_DISABLE}, {
|
"--gst-disable-segtrap", ARG_SEGTRAP_DISABLE}, {
|
||||||
|
"--gst-disable-registry-update", ARG_REGISTRY_UPDATE_DISABLE}, {
|
||||||
"--gst-disable-registry-fork", ARG_REGISTRY_FORK_DISABLE}, {
|
"--gst-disable-registry-fork", ARG_REGISTRY_FORK_DISABLE}, {
|
||||||
NULL}
|
NULL}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue