Commit cb98a99c authored by Gildas Bazin's avatar Gildas Bazin

* ALL: brought back module_EndBank() from the dead and fixed a few bugs in libvlc.c.

parent 3b3c50ab
......@@ -4,9 +4,9 @@
* It includes functions allowing to declare, get or set configuration options.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: configuration.h,v 1.35 2004/01/29 17:04:01 gbazin Exp $
* $Id$
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Authors: Gildas Bazin <gbazin@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -130,6 +130,9 @@ VLC_EXPORT( void, config_UnsetCallbacks, ( module_config_t * ) );
#define config_SaveConfigFile(a,b) __config_SaveConfigFile(VLC_OBJECT(a),b)
#define config_ResetAll(a) __config_ResetAll(VLC_OBJECT(a))
/* internal only */
int config_CreateDir( vlc_object_t *, char * );
/*****************************************************************************
* Macros used to build the configuration structure.
*
......
......@@ -54,6 +54,7 @@ struct module_bank_t
{
VLC_COMMON_MEMBERS
int i_usage;
module_symbols_t symbols;
/* Plugins cache */
......
......@@ -246,7 +246,6 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
vlc_t * p_vlc = vlc_current_object( i_object );
module_t *p_help_module;
playlist_t *p_playlist;
vlc_value_t lockval;
if( !p_vlc )
{
......@@ -285,22 +284,13 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
* main module. We need to do this at this stage to be able to display
* a short help if required by the user. (short help == main module
* options) */
var_Create( p_libvlc, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
if( libvlc.p_module_bank == NULL )
{
module_InitBank( p_vlc );
module_LoadMain( p_vlc );
}
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_libvlc, "libvlc" );
module_InitBank( p_vlc );
/* Hack: insert the help module here */
p_help_module = vlc_object_create( p_vlc, VLC_OBJECT_MODULE );
if( p_help_module == NULL )
{
/*module_EndBank( p_vlc );*/
module_EndBank( p_vlc );
if( i_object ) vlc_object_release( p_vlc );
return VLC_EGENERIC;
}
......@@ -315,7 +305,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
vlc_object_detach( p_help_module );
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
/*module_EndBank( p_vlc );*/
module_EndBank( p_vlc );
if( i_object ) vlc_object_release( p_vlc );
return VLC_EGENERIC;
}
......@@ -354,7 +344,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
{
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
/*module_EndBank( p_vlc );*/
module_EndBank( p_vlc );
if( i_object ) vlc_object_release( p_vlc );
return VLC_EEXIT;
}
......@@ -372,6 +362,8 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
psz_language = config_GetPsz( p_vlc, "language" );
if( psz_language && *psz_language && strcmp( psz_language, "auto" ) )
{
vlc_bool_t b_cache_delete = libvlc.p_module_bank->b_cache_delete;
/* Reset the default domain */
SetLanguage( psz_language );
......@@ -386,8 +378,9 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
module_EndBank( p_vlc );
module_InitBank( p_vlc );
module_LoadMain( p_vlc );
config_LoadConfigFile( p_vlc, "main" );
config_LoadCmdLine( p_vlc, &i_argc, ppsz_argv, VLC_TRUE );
libvlc.p_module_bank->b_cache_delete = b_cache_delete;
}
if( psz_language ) free( psz_language );
#endif
......@@ -458,7 +451,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
{
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
/*module_EndBank( p_vlc );*/
module_EndBank( p_vlc );
if( i_object ) vlc_object_release( p_vlc );
return VLC_EEXIT;
}
......@@ -487,7 +480,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
vlc_object_detach( p_help_module );
config_Free( p_help_module );
vlc_object_destroy( p_help_module );
/*module_EndBank( p_vlc );*/
module_EndBank( p_vlc );
if( i_object ) vlc_object_release( p_vlc );
return VLC_EGENERIC;
}
......@@ -598,7 +591,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
{
module_Unneed( p_vlc, p_vlc->p_memcpy_module );
}
/*module_EndBank( p_vlc );*/
module_EndBank( p_vlc );
if( i_object ) vlc_object_release( p_vlc );
return VLC_EGENERIC;
}
......@@ -736,7 +729,7 @@ int VLC_Destroy( int i_object )
}
/*
* XXX: Free module bank !
* Free module bank !
*/
module_EndBank( p_vlc );
......
......@@ -910,7 +910,7 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
}
/*****************************************************************************
* config_CreateConfigDir: Create configuration directory if it doesn't exist.
* config_CreateDir: Create configuration directory if it doesn't exist.
*****************************************************************************/
int config_CreateDir( vlc_object_t *p_this, char *psz_dirname )
{
......
......@@ -168,9 +168,24 @@ static char * GetWindowsError ( void );
void __module_InitBank( vlc_object_t *p_this )
{
module_bank_t *p_bank;
vlc_value_t lockval;
var_Create( p_this->p_libvlc, "libvlc", VLC_VAR_MUTEX );
var_Get( p_this->p_libvlc, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
if( p_this->p_libvlc->p_module_bank )
{
p_this->p_libvlc->p_module_bank->i_usage++;
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc, "libvlc" );
return;
}
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc, "libvlc" );
p_bank = vlc_object_create( p_this, sizeof(module_bank_t) );
p_bank->psz_object_name = "module bank";
p_bank->i_usage = 1;
p_bank->i_cache = p_bank->i_loaded_cache = 0;
p_bank->pp_cache = p_bank->pp_loaded_cache = 0;
p_bank->b_cache = p_bank->b_cache_dirty =
......@@ -187,6 +202,8 @@ void __module_InitBank( vlc_object_t *p_this )
p_this->p_libvlc->p_module_bank = p_bank;
vlc_object_attach( p_bank, p_this->p_libvlc );
module_LoadMain( p_this );
return;
}
......@@ -211,6 +228,25 @@ void __module_ResetBank( vlc_object_t *p_this )
void __module_EndBank( vlc_object_t *p_this )
{
module_t * p_next;
vlc_value_t lockval;
var_Create( p_this->p_libvlc, "libvlc", VLC_VAR_MUTEX );
var_Get( p_this->p_libvlc, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
if( !p_this->p_libvlc->p_module_bank )
{
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc, "libvlc" );
return;
}
if( --p_this->p_libvlc->p_module_bank->i_usage )
{
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc, "libvlc" );
return;
}
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc, "libvlc" );
#ifdef HAVE_DYNAMIC_PLUGINS
if( p_this->p_libvlc->p_module_bank->b_cache ) CacheSave( p_this );
......
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