[vlc-commits] [Git][videolan/vlc][master] 2 commits: config: use libvlc_int_t directly
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Aug 22 05:19:02 UTC 2022
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
af21f6a7 by Steve Lhomme at 2022-08-22T05:03:46+00:00
config: use libvlc_int_t directly
There's no other object that can handle the configuration loading/saving.
We don't need to inherit the options, they can only be in the libvlc_int_t
object. var_GetNonEmptyString() is equivalent to var_InheritString() in that
case.
- - - - -
9e78bba8 by Steve Lhomme at 2022-08-22T05:03:46+00:00
core: modules: use libvlc_int_t directly
Only the base object should load all the modules descriptors.
- - - - -
10 changed files:
- include/vlc_configuration.h
- src/config/cmdline.c
- src/config/configuration.h
- src/config/core.c
- src/config/file.c
- src/config/help.c
- src/libvlc.c
- src/modules/bank.c
- src/modules/cache.c
- src/modules/modules.h
Changes:
=====================================
include/vlc_configuration.h
=====================================
@@ -228,8 +228,8 @@ VLC_API ssize_t config_GetIntChoices(const char *, int64_t **values,
VLC_API ssize_t config_GetPszChoices(const char *,
char ***values, char ***texts) VLC_USED;
-VLC_API int config_SaveConfigFile( vlc_object_t * );
-#define config_SaveConfigFile(a) config_SaveConfigFile(VLC_OBJECT(a))
+VLC_API int config_SaveConfigFile( libvlc_int_t * );
+#define config_SaveConfigFile(a) config_SaveConfigFile(vlc_object_instance(a))
/**
* Resets the configuration.
=====================================
src/config/cmdline.c
=====================================
@@ -40,7 +40,6 @@
#include <assert.h>
-#undef config_CmdLineEarlyScan
/**
* Perform early scan of arguments for a small subset of simple options.
*
@@ -95,7 +94,7 @@
* @param argc number of command line arguments
* @param argv command line arguments
*/
-void config_CmdLineEarlyScan( vlc_object_t *p_this, int argc, const char *argv[] )
+void config_CmdLineEarlyScan( libvlc_int_t *p_this, int argc, const char *argv[] )
{
#if !defined(HAVE_DYNAMIC_PLUGINS) && !defined(_WIN32)
VLC_UNUSED(p_this); VLC_UNUSED(argc); VLC_UNUSED(argv);
@@ -148,7 +147,6 @@ void config_CmdLineEarlyScan( vlc_object_t *p_this, int argc, const char *argv[]
#endif
}
-#undef config_LoadCmdLine
/**
* Parse command line for configuration options.
*
@@ -163,7 +161,7 @@ void config_CmdLineEarlyScan( vlc_object_t *p_this, int argc, const char *argv[]
* @param pindex index of the first non-option argument [OUT]
* @return 0 on success, -1 on error.
*/
-int config_LoadCmdLine( vlc_object_t *p_this, int i_argc,
+int config_LoadCmdLine( libvlc_int_t *p_this, int i_argc,
const char *ppsz_argv[], int *pindex )
{
int i_cmd, i_index, i_opts, i_shortopts, flag, i_verbose = 0;
=====================================
src/config/configuration.h
=====================================
@@ -50,18 +50,15 @@ struct vlc_param *vlc_param_Find(const char *name);
int vlc_param_SetString(struct vlc_param *param, const char *value);
-int config_AutoSaveConfigFile( vlc_object_t * );
+int config_AutoSaveConfigFile( libvlc_int_t * );
void config_Free(struct vlc_param *, size_t);
-void config_CmdLineEarlyScan( vlc_object_t *, int, const char *[] );
-#define config_CmdLineEarlyScan(a,b,c) config_CmdLineEarlyScan(VLC_OBJECT(a),b,c)
+void config_CmdLineEarlyScan( libvlc_int_t *, int, const char *[] );
-int config_LoadCmdLine ( vlc_object_t *, int, const char *[], int * );
-int config_LoadConfigFile( vlc_object_t * );
-#define config_LoadCmdLine(a,b,c,d) config_LoadCmdLine(VLC_OBJECT(a),b,c,d)
-#define config_LoadConfigFile(a) config_LoadConfigFile(VLC_OBJECT(a))
-bool config_PrintHelp (vlc_object_t *);
+int config_LoadCmdLine ( libvlc_int_t *, int, const char *[], int * );
+int config_LoadConfigFile( libvlc_int_t * );
+bool config_PrintHelp (libvlc_int_t *);
void config_Lock(void);
void config_Unlock(void);
=====================================
src/config/core.c
=====================================
@@ -528,7 +528,7 @@ void config_ResetAll(void)
}
-int config_AutoSaveConfigFile( vlc_object_t *p_this )
+int config_AutoSaveConfigFile( libvlc_int_t *p_this )
{
assert( p_this );
=====================================
src/config/file.c
=====================================
@@ -52,7 +52,7 @@
/**
* Get the user's configuration file
*/
-static char *config_GetConfigFile( vlc_object_t *obj )
+static char *config_GetConfigFile( libvlc_int_t *obj )
{
char *psz_file = var_InheritString( obj, "config" );
if( psz_file == NULL )
@@ -66,7 +66,7 @@ static char *config_GetConfigFile( vlc_object_t *obj )
return psz_file;
}
-static FILE *config_OpenConfigFile( vlc_object_t *p_obj )
+static FILE *config_OpenConfigFile( libvlc_int_t *p_obj )
{
char *psz_filename = config_GetConfigFile( p_obj );
if( psz_filename == NULL )
@@ -153,14 +153,13 @@ static int64_t vlc_strtoi (const char *str)
return l;
}
-#undef config_LoadConfigFile
/*****************************************************************************
* config_LoadConfigFile: loads the configuration file.
*****************************************************************************
* This function is called to load the config options stored in the config
* file.
*****************************************************************************/
-int config_LoadConfigFile( vlc_object_t *p_this )
+int config_LoadConfigFile( libvlc_int_t *p_this )
{
FILE *file;
@@ -274,7 +273,7 @@ int config_LoadConfigFile( vlc_object_t *p_this )
/*****************************************************************************
* config_CreateDir: Create configuration directory if it doesn't exist.
*****************************************************************************/
-static int config_CreateDir( vlc_object_t *p_this, char *psz_dirname )
+static int config_CreateDir( libvlc_int_t *p_this, char *psz_dirname )
{
if( !psz_dirname || !*psz_dirname ) return -1;
@@ -335,7 +334,7 @@ config_Write (FILE *file, const char *desc, const char *type,
}
-static int config_PrepareDir (vlc_object_t *obj)
+static int config_PrepareDir (libvlc_int_t *obj)
{
char *psz_configdir = config_GetUserDir (VLC_CONFIG_DIR);
if (psz_configdir == NULL)
@@ -346,12 +345,11 @@ static int config_PrepareDir (vlc_object_t *obj)
return ret;
}
-#undef config_SaveConfigFile
/**
* Saves the in-memory configuration into a file.
* @return 0 on success, -1 on error.
*/
-int config_SaveConfigFile (vlc_object_t *p_this)
+int (config_SaveConfigFile) (libvlc_int_t *p_this)
{
if( config_PrepareDir( p_this ) )
=====================================
src/config/help.c
=====================================
@@ -54,10 +54,10 @@ static void PauseConsole (void);
# define PauseConsole() (void)0
#endif
-static void Help (vlc_object_t *, const char *);
-static void Usage (vlc_object_t *, const char *);
+static void Help (libvlc_int_t *, const char *);
+static void Usage (libvlc_int_t *, const char *);
static void Version (void);
-static void ListModules (vlc_object_t *, bool);
+static void ListModules (libvlc_int_t *, bool);
/**
* Returns the console width or a best guess.
@@ -91,7 +91,7 @@ static unsigned ConsoleWidth(void)
* \return true if a command line options caused some help message to be
* printed, false otherwise.
*/
-bool config_PrintHelp (vlc_object_t *obj)
+bool config_PrintHelp (libvlc_int_t *obj)
{
char *str;
@@ -195,7 +195,7 @@ static const char vlc_usage[] = N_(
" vlc://quit Special item to quit VLC\n"
"\n");
-static void Help (vlc_object_t *p_this, char const *psz_help_name)
+static void Help (libvlc_int_t *p_this, char const *psz_help_name)
{
ShowConsole();
@@ -573,7 +573,7 @@ static bool plugin_show(const vlc_plugin_t *plugin)
return false;
}
-static void Usage (vlc_object_t *p_this, char const *psz_search)
+static void Usage (libvlc_int_t *p_this, char const *psz_search)
{
bool found = false;
bool strict = false;
@@ -641,7 +641,7 @@ static void Usage (vlc_object_t *p_this, char const *psz_search)
* Print a list of all available modules (builtins and plugins) and a short
* description for each one.
*****************************************************************************/
-static void ListModules (vlc_object_t *p_this, bool b_verbose)
+static void ListModules (libvlc_int_t *p_this, bool b_verbose)
{
bool color = false;
=====================================
src/libvlc.c
=====================================
@@ -195,7 +195,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
/*
* Handle info requests such as for help or version text.
*/
- if (config_PrintHelp (VLC_OBJECT(p_libvlc)))
+ if (config_PrintHelp (p_libvlc))
{
libvlc_InternalCleanup (p_libvlc);
exit(0);
@@ -391,7 +391,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
/* Save the configuration */
if( !var_InheritBool( p_libvlc, "ignore-config" ) )
- config_AutoSaveConfigFile( VLC_OBJECT(p_libvlc) );
+ config_AutoSaveConfigFile( p_libvlc );
vlc_LogDestroy(p_libvlc->obj.logger);
vlc_tracer_Destroy(p_libvlc);
=====================================
src/modules/bank.c
=====================================
@@ -254,10 +254,10 @@ error:
* \param fast whether to optimize loading for speed or safety
* (fast is used when the plug-in is registered but not used)
*/
-static vlc_plugin_t *module_InitDynamic(vlc_object_t *obj, const char *path,
+static vlc_plugin_t *module_InitDynamic(libvlc_int_t *obj, const char *path,
bool fast)
{
- void *handle = module_Open(obj->logger, path, fast);
+ void *handle = module_Open(vlc_object_logger(obj), path, fast);
if (handle == NULL)
return NULL;
@@ -295,7 +295,7 @@ typedef enum
typedef struct module_bank
{
- vlc_object_t *obj;
+ libvlc_int_t *obj;
const char *base;
cache_mode_t mode;
@@ -509,7 +509,7 @@ static void AllocatePluginDir (module_bank_t *bank, unsigned maxdepth,
* Scans for plug-ins within a file system hierarchy.
* \param path base directory to browse
*/
-static void AllocatePluginPath(vlc_object_t *obj, const char *path,
+static void AllocatePluginPath(libvlc_int_t *obj, const char *path,
cache_mode_t mode)
{
module_bank_t bank =
@@ -558,7 +558,7 @@ static void AllocatePluginPath(vlc_object_t *obj, const char *path,
* For performance reasons, a cache is normally used so that plug-in shared
* objects do not need to loaded and linked into the process.
*/
-static void AllocateAllPlugins (vlc_object_t *p_this)
+static void AllocateAllPlugins (libvlc_int_t *p_this)
{
char *paths;
cache_mode_t mode = 0;
@@ -785,14 +785,13 @@ void module_EndBank (bool b_plugins)
block_ChainRelease(caches);
}
-#undef module_LoadPlugins
/**
* Loads module descriptions for all available plugins.
* Fills the module bank structure with the plugin modules.
*
* \param p_this vlc object structure
*/
-void module_LoadPlugins(vlc_object_t *obj)
+void module_LoadPlugins(libvlc_int_t *obj)
{
/*vlc_mutex_assert (&modules.lock); not for static mutexes :( */
=====================================
src/modules/cache.c
=====================================
@@ -372,7 +372,7 @@ error:
* actually load the dynamically loadable module.
* This allows us to only fully load plugins when they are actually used.
*/
-vlc_plugin_t *vlc_cache_load(vlc_object_t *p_this, const char *dir,
+vlc_plugin_t *vlc_cache_load(libvlc_int_t *p_this, const char *dir,
block_t **backingp)
{
char *psz_filename;
@@ -655,7 +655,7 @@ error:
/**
* Saves a module cache to disk, and release cache data from memory.
*/
-void CacheSave(vlc_object_t *p_this, const char *dir,
+void CacheSave(libvlc_int_t *p_this, const char *dir,
vlc_plugin_t *const *entries, size_t n)
{
char *filename = NULL, *tmpname = NULL;
=====================================
src/modules/modules.h
=====================================
@@ -112,8 +112,7 @@ vlc_plugin_t *vlc_plugin_describe(vlc_plugin_cb);
int vlc_plugin_resolve(vlc_plugin_t *, vlc_plugin_cb);
void module_InitBank (void);
-void module_LoadPlugins(vlc_object_t *);
-#define module_LoadPlugins(a) module_LoadPlugins(VLC_OBJECT(a))
+void module_LoadPlugins(libvlc_int_t *);
void module_EndBank (bool);
int vlc_plugin_Map(struct vlc_logger *, vlc_plugin_t *);
void *vlc_plugin_Symbol(struct vlc_logger *, vlc_plugin_t *, const char *name);
@@ -181,9 +180,9 @@ void *vlc_dlsym(void *handle, const char *) VLC_USED;
char *vlc_dlerror(void) VLC_USED;
/* Plugins cache */
-vlc_plugin_t *vlc_cache_load(vlc_object_t *, const char *, block_t **);
+vlc_plugin_t *vlc_cache_load(libvlc_int_t *, const char *, block_t **);
vlc_plugin_t *vlc_cache_lookup(vlc_plugin_t **, const char *relpath);
-void CacheSave(vlc_object_t *, const char *, vlc_plugin_t *const *, size_t);
+void CacheSave(libvlc_int_t *, const char *, vlc_plugin_t *const *, size_t);
#endif /* !LIBVLC_MODULES_H */
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/490c04ad03a9626038444b5c594dfcbcbadeca51...9e78bba8855f1d953e49b982bcd12981d98f8f48
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/490c04ad03a9626038444b5c594dfcbcbadeca51...9e78bba8855f1d953e49b982bcd12981d98f8f48
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list