Commit 8d46058e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlm: read vlm-conf variable just once

parent 75dd0452
......@@ -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, ... );
......
......@@ -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" );
......
......@@ -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 )
{
......
......@@ -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." );
......
......@@ -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;
}
......
......@@ -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
/*
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment