registry.c
static gboolean
ensure_current_registry (GError ** error)
{
gchar *registry_file;
GstRegistry *default_registry;
gboolean ret = TRUE;
gboolean do_update = TRUE;
gboolean have_cache = TRUE;
default_registry = gst_registry_get ();
registry_file = g_strdup (g_getenv ("GST_REGISTRY_1_0"));
if (registry_file == NULL)
registry_file = g_strdup (g_getenv ("GST_REGISTRY"));
if (registry_file == NULL) {
registry_file = g_build_filename (g_get_user_cache_dir (),
"gstreamer-" GST_API_VERSION, "registry." TARGET_CPU ".bin", NULL);
}
if (!_gst_disable_registry_cache) {
GST_INFO ("reading registry cache: %s", registry_file);
have_cache = priv_gst_registry_binary_read_cache (default_registry,
registry_file);
/* Only ever read the registry cache once, then disable it for
* subsequent updates during the program lifetime */
_gst_disable_registry_cache = TRUE;
}
if (have_cache) {
do_update = !_priv_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);
}
}
}
if (do_update) {
const gchar *reuse_env;
if ((reuse_env = g_getenv ("GST_REGISTRY_REUSE_PLUGIN_SCANNER"))) {
/* do reuse for any value different from "no" */
__registry_reuse_plugin_scanner = (strcmp (reuse_env, "no") != 0);
}
/* now check registry */
GST_DEBUG ("Updating registry cache");
scan_and_update_registry (default_registry, registry_file, TRUE, error);
} else {
GST_DEBUG ("Not updating registry cache (disabled)");
}
g_free (registry_file);
GST_INFO ("registry reading and updating done, result = %d", ret);
return ret;
}
1.依次从GST_REGISTRY_1_0 GST_REGISTRY g_get_user_cache_dir ()/ "gstreamer-" GST_API_VERSION/ "registry." TARGET_CPU ".bin"中读取resister_file
2.如果不禁用cache,priv_gst_registry_binary_read_cache就从resister_file中读取cache到default_registry中,j同时禁用cache后续不用再读取cache,如果成功hava_cache=true
3.如果没有禁用update,而且环境变量GST_REGISTRY_UPDATE的值不是no,do_update=true,
4.如果do_update为真,__registry_reuse_plugin_scanner 的值设为环境变量GST_REGISTRY_REUSE_PLUGIN_SCANNER的值,开始更新scan_and_update_registry