[vlc-commits] vlm: read vlm-conf variable just once
Rémi Denis-Courmont
git at videolan.org
Thu May 31 21:03:45 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 31 22:00:34 2018 +0300| [8d46058e2ec570fc25b1324c5923a311d665fda2] | committer: Rémi Denis-Courmont
vlm: read vlm-conf variable just once
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8d46058e2ec570fc25b1324c5923a311d665fda2
---
include/vlc_vlm.h | 4 ++--
lib/vlm.c | 2 +-
modules/gui/qt/dialogs/vlm.cpp | 2 +-
modules/lua/libs/vlm.c | 2 +-
src/input/vlm.c | 11 ++++-------
src/libvlc.c | 6 +++---
src/missing.c | 3 ++-
7 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/include/vlc_vlm.h b/include/vlc_vlm.h
index c5fddf0adc..ad323038af 100644
--- a/include/vlc_vlm.h
+++ b/include/vlc_vlm.h
@@ -184,8 +184,8 @@ struct vlm_message_t
extern "C" {
#endif
-VLC_API vlm_t * vlm_New( vlc_object_t * );
-#define vlm_New( a ) vlm_New( VLC_OBJECT(a) )
+VLC_API vlm_t * vlm_New( vlc_object_t *, const char *path );
+#define vlm_New( a, p ) vlm_New( VLC_OBJECT(a), p )
VLC_API void vlm_Delete( vlm_t * );
VLC_API int vlm_ExecuteCommand( vlm_t *, const char *, vlm_message_t ** );
VLC_API int vlm_Control( vlm_t *p_vlm, int i_query, ... );
diff --git a/lib/vlm.c b/lib/vlm.c
index 980499f0ce..1f66058efa 100644
--- a/lib/vlm.c
+++ b/lib/vlm.c
@@ -139,7 +139,7 @@ static int libvlc_vlm_init( libvlc_instance_t *p_instance )
if( !p_instance->vlm->p_vlm )
{
- p_instance->vlm->p_vlm = vlm_New( p_instance->p_libvlc_int );
+ p_instance->vlm->p_vlm = vlm_New( p_instance->p_libvlc_int, NULL );
if( !p_instance->vlm->p_vlm )
{
libvlc_printerr( "VLM not supported or out of memory" );
diff --git a/modules/gui/qt/dialogs/vlm.cpp b/modules/gui/qt/dialogs/vlm.cpp
index e88cc63caa..0c90f0ce78 100644
--- a/modules/gui/qt/dialogs/vlm.cpp
+++ b/modules/gui/qt/dialogs/vlm.cpp
@@ -55,7 +55,7 @@
VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{
- vlm_t *p_vlm = vlm_New( p_intf );
+ vlm_t *p_vlm = vlm_New( p_intf, NULL );
if( !p_vlm )
{
diff --git a/modules/lua/libs/vlm.c b/modules/lua/libs/vlm.c
index 7b2b708306..7b1350cb40 100644
--- a/modules/lua/libs/vlm.c
+++ b/modules/lua/libs/vlm.c
@@ -53,7 +53,7 @@ static const luaL_Reg vlclua_vlm_reg[] = {
static int vlclua_vlm_new( lua_State *L )
{
vlc_object_t *p_this = vlclua_get_this( L );
- vlm_t *p_vlm = vlm_New( p_this );
+ vlm_t *p_vlm = vlm_New( p_this, NULL );
if( !p_vlm )
return luaL_error( L, "Cannot start VLM." );
diff --git a/src/input/vlm.c b/src/input/vlm.c
index d8cfa46b52..492fca6288 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -115,10 +115,9 @@ static vlc_mutex_t vlm_mutex = VLC_STATIC_MUTEX;
/*****************************************************************************
* vlm_New:
*****************************************************************************/
-vlm_t *vlm_New ( vlc_object_t *p_this )
+vlm_t *vlm_New ( vlc_object_t *p_this, const char *psz_vlmconf )
{
vlm_t *p_vlm = NULL, **pp_vlm = &(libvlc_priv (p_this->obj.libvlc)->p_vlm);
- char *psz_vlmconf;
/* Avoid multiple creation */
vlc_mutex_lock( &vlm_mutex );
@@ -167,9 +166,10 @@ vlm_t *vlm_New ( vlc_object_t *p_this )
*pp_vlm = p_vlm; /* for future reference */
+ vlc_mutex_unlock( &vlm_mutex );
+
/* Load our configuration file */
- psz_vlmconf = var_CreateGetString( p_vlm, "vlm-conf" );
- if( psz_vlmconf && *psz_vlmconf )
+ if( psz_vlmconf != NULL )
{
vlm_message_t *p_message = NULL;
char *psz_buffer = NULL;
@@ -185,9 +185,6 @@ vlm_t *vlm_New ( vlc_object_t *p_this )
free( psz_buffer );
}
}
- free( psz_vlmconf );
-
- vlc_mutex_unlock( &vlm_mutex );
return p_vlm;
}
diff --git a/src/libvlc.c b/src/libvlc.c
index e526b9d85d..99073da504 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -258,14 +258,14 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
#ifdef ENABLE_VLM
/* Initialize VLM if vlm-conf is specified */
- psz_parser = var_CreateGetNonEmptyString( p_libvlc, "vlm-conf" );
+ psz_parser = var_InheritString( p_libvlc, "vlm-conf" );
if( psz_parser )
{
- priv->p_vlm = vlm_New( p_libvlc );
+ priv->p_vlm = vlm_New( p_libvlc, psz_parser );
if( !priv->p_vlm )
msg_Err( p_libvlc, "VLM initialization failed" );
+ free( psz_parser );
}
- free( psz_parser );
#endif
/*
diff --git a/src/missing.c b/src/missing.c
index 59a4770a96..a3e57e9d73 100644
--- a/src/missing.c
+++ b/src/missing.c
@@ -241,9 +241,10 @@ vlm_message_t *vlm_MessageNew (const char *a, const char *fmt, ...)
}
#undef vlm_New
-vlm_t *vlm_New (vlc_object_t *obj)
+vlm_t *vlm_New (vlc_object_t *obj, const char *file)
{
msg_Err (obj, "VLM not compiled-in!");
+ (void) file;
return NULL;
}
#endif /* !ENABLE_VLM */
More information about the vlc-commits
mailing list