/** * Init bank * * Creates a module bank structure which will be filled later * on with all the modules found. */ void module_InitBank (void) { vlc_mutex_lock (&modules.lock); if (modules.usage == 0) { /* Fills the module bank structure with the main module infos. * This is very useful as it will allow us to consider the main * library just as another module, and for instance the configuration * options of main will be available in the module bank structure just * as for every other module. */ module_t *module = module_InitStatic (vlc_entry__main); if (likely(module != NULL)) module_StoreBank (module); config_SortConfig (); } modules.usage++; /* We do retain the module bank lock until the plugins are loaded as well. * This is ugly, this staged loading approach is needed: LibVLC gets * some configuration parameters relevant to loading the plugins from * the main (builtin) module. The module bank becomes shared read-only data * once it is ready, so we need to fully serialize initialization. * DO NOT UNCOMMENT the following line unless you managed to squeeze * module_LoadPlugins() before you unlock the mutex. */ /*vlc_mutex_unlock (&modules.lock);*/ }
static void module_InitStaticModules(void) { if (!vlc_static_modules) return; for (unsigned i = 0; vlc_static_modules[i]; i++) { module_t *module = module_InitStatic (vlc_static_modules[i]); if (likely(module != NULL)) module_StoreBank (module); } }
static void module_InitStaticModules(void) { if (!vlc_static_modules) return; for (unsigned i = 0; vlc_static_modules[i]; i++) { vlc_plugin_t *lib = module_InitStatic(vlc_static_modules[i]); if (likely(lib != NULL)) module_StoreBank(lib); } }
/** * Scans a plug-in from a file. */ static int AllocatePluginFile (module_bank_t *bank, const char *abspath, const char *relpath, const struct stat *st) { vlc_plugin_t *plugin = NULL; /* Check our plugins cache first then load plugin if needed */ if (bank->mode & CACHE_READ_FILE) { plugin = vlc_cache_lookup(&bank->cache, relpath); if (plugin != NULL && (plugin->mtime != (int64_t)st->st_mtime || plugin->size != (uint64_t)st->st_size)) { msg_Err(bank->obj, "stale plugins cache: modified %s", plugin->abspath); vlc_plugin_destroy(plugin); plugin = NULL; } } if (plugin == NULL) { plugin = module_InitDynamic(bank->obj, abspath, true); if (plugin != NULL) { plugin->path = xstrdup(relpath); plugin->mtime = st->st_mtime; plugin->size = st->st_size; } } if (plugin == NULL) return -1; module_StoreBank(plugin); if (bank->mode & CACHE_WRITE_FILE) /* Add entry to to-be-saved cache */ { bank->plugins = xrealloc(bank->plugins, (bank->size + 1) * sizeof (vlc_plugin_t *)); bank->plugins[bank->size] = plugin; bank->size++; } /* TODO: deal with errors */ return 0; }