Commit 5dc2da73 authored by Sam Hocevar's avatar Sam Hocevar

* ./src/misc/modules.c: the module linked list is going bye bye. We now use

    the vlc_object_* and vlc_list_* functions to manage modules. The Win32
    interface doesn't build, but I'll fix this.
parent 17e19cc1
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* modules.h : Module management functions. * modules.h : Module management functions.
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: modules.h,v 1.59 2002/07/31 20:56:50 sam Exp $ * $Id: modules.h,v 1.60 2002/08/15 12:11:15 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -45,11 +45,6 @@ struct module_bank_t ...@@ -45,11 +45,6 @@ struct module_bank_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
module_t * first; /* First module in the bank */
int i_count; /* Number of allocated modules */
vlc_mutex_t lock; /* Global lock -- you can't imagine how awful *
it is to design thread-safe linked lists */
module_symbols_t symbols; module_symbols_t symbols;
}; };
...@@ -98,12 +93,6 @@ struct module_t ...@@ -98,12 +93,6 @@ struct module_t
vlc_bool_t b_builtin; /* Set to true if the module is built in */ vlc_bool_t b_builtin; /* Set to true if the module is built in */
int i_usage; /* Reference counter */
int i_unused_delay; /* Delay until module is unloaded */
module_t *next; /* Next module */
module_t *prev; /* Previous module */
/* /*
* Symbol table we send to the module so that it can access vlc symbols * Symbol table we send to the module so that it can access vlc symbols
*/ */
...@@ -125,8 +114,6 @@ void __module_LoadPlugins ( vlc_object_t * ); ...@@ -125,8 +114,6 @@ void __module_LoadPlugins ( vlc_object_t * );
void __module_EndBank ( vlc_object_t * ); void __module_EndBank ( vlc_object_t * );
#define module_ResetBank(a) __module_ResetBank(VLC_OBJECT(a)) #define module_ResetBank(a) __module_ResetBank(VLC_OBJECT(a))
void __module_ResetBank ( vlc_object_t * ); void __module_ResetBank ( vlc_object_t * );
#define module_ManageBank(a) __module_ManageBank(VLC_OBJECT(a))
void __module_ManageBank ( vlc_object_t * );
#define module_Need(a,b,c) __module_Need(VLC_OBJECT(a),b,c) #define module_Need(a,b,c) __module_Need(VLC_OBJECT(a),b,c)
VLC_EXPORT( module_t *, __module_Need, ( vlc_object_t *, const char *, const char * ) ); VLC_EXPORT( module_t *, __module_Need, ( vlc_object_t *, const char *, const char * ) );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vlc_objects.h: vlc_object_t definition. * vlc_objects.h: vlc_object_t definition.
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: vlc_objects.h,v 1.9 2002/08/14 17:06:53 sam Exp $ * $Id: vlc_objects.h,v 1.10 2002/08/15 12:11:15 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -52,7 +52,7 @@ VLC_EXPORT( void *, __vlc_object_find, ( vlc_object_t *, int, int ) ); ...@@ -52,7 +52,7 @@ VLC_EXPORT( void *, __vlc_object_find, ( vlc_object_t *, int, int ) );
VLC_EXPORT( void, __vlc_object_yield, ( vlc_object_t * ) ); VLC_EXPORT( void, __vlc_object_yield, ( vlc_object_t * ) );
VLC_EXPORT( void, __vlc_object_release, ( vlc_object_t * ) ); VLC_EXPORT( void, __vlc_object_release, ( vlc_object_t * ) );
VLC_EXPORT( vlc_list_t *, __vlc_list_find, ( vlc_object_t *, int, int ) ); VLC_EXPORT( vlc_list_t *, __vlc_list_find, ( vlc_object_t *, int, int ) );
VLC_EXPORT( void, __vlc_list_release, ( vlc_object_t *, vlc_list_t * ) ); VLC_EXPORT( void, vlc_list_release, ( vlc_list_t * ) );
VLC_EXPORT( void, __vlc_liststructure, ( vlc_object_t * ) ); VLC_EXPORT( void, __vlc_liststructure, ( vlc_object_t * ) );
VLC_EXPORT( void, __vlc_dumpstructure, ( vlc_object_t * ) ); VLC_EXPORT( void, __vlc_dumpstructure, ( vlc_object_t * ) );
...@@ -82,9 +82,6 @@ VLC_EXPORT( void, __vlc_dumpstructure, ( vlc_object_t * ) ); ...@@ -82,9 +82,6 @@ VLC_EXPORT( void, __vlc_dumpstructure, ( vlc_object_t * ) );
#define vlc_list_find(a,b,c) \ #define vlc_list_find(a,b,c) \
__vlc_list_find( VLC_OBJECT(a),b,c) __vlc_list_find( VLC_OBJECT(a),b,c)
#define vlc_list_release(a,b) \
__vlc_list_release( VLC_OBJECT(a),b )
#define vlc_liststructure(a) \ #define vlc_liststructure(a) \
__vlc_liststructure( VLC_OBJECT(a) ) __vlc_liststructure( VLC_OBJECT(a) )
......
...@@ -93,7 +93,6 @@ struct module_symbols_t ...@@ -93,7 +93,6 @@ struct module_symbols_t
void (* __msg_Unsubscribe_inner) ( vlc_object_t *, msg_subscription_t * ) ; void (* __msg_Unsubscribe_inner) ( vlc_object_t *, msg_subscription_t * ) ;
void (* __msg_Warn_inner) ( void *, const char *, ... ) ; void (* __msg_Warn_inner) ( void *, const char *, ... ) ;
void (* __vlc_dumpstructure_inner) ( vlc_object_t * ) ; void (* __vlc_dumpstructure_inner) ( vlc_object_t * ) ;
void (* __vlc_list_release_inner) ( vlc_object_t *, vlc_list_t * ) ;
void (* __vlc_liststructure_inner) ( vlc_object_t * ) ; void (* __vlc_liststructure_inner) ( vlc_object_t * ) ;
void (* __vlc_object_attach_inner) ( vlc_object_t *, vlc_object_t * ) ; void (* __vlc_object_attach_inner) ( vlc_object_t *, vlc_object_t * ) ;
void (* __vlc_object_destroy_inner) ( vlc_object_t * ) ; void (* __vlc_object_destroy_inner) ( vlc_object_t * ) ;
...@@ -129,6 +128,7 @@ struct module_symbols_t ...@@ -129,6 +128,7 @@ struct module_symbols_t
void (* mwait_inner) ( mtime_t date ) ; void (* mwait_inner) ( mtime_t date ) ;
void (* playlist_Command_inner) ( playlist_t *, int, int ) ; void (* playlist_Command_inner) ( playlist_t *, int, int ) ;
void (* sout_DeleteInstance_inner) ( sout_instance_t * ) ; void (* sout_DeleteInstance_inner) ( sout_instance_t * ) ;
void (* vlc_list_release_inner) ( vlc_list_t * ) ;
void (* vout_AllocatePicture_inner) ( vout_thread_t *, picture_t *, int, int, u32 ) ; void (* vout_AllocatePicture_inner) ( vout_thread_t *, picture_t *, int, int, u32 ) ;
void (* vout_DatePicture_inner) ( vout_thread_t *, picture_t *, mtime_t ) ; void (* vout_DatePicture_inner) ( vout_thread_t *, picture_t *, mtime_t ) ;
void (* vout_DestroyPicture_inner) ( vout_thread_t *, picture_t * ) ; void (* vout_DestroyPicture_inner) ( vout_thread_t *, picture_t * ) ;
...@@ -191,7 +191,6 @@ struct module_symbols_t ...@@ -191,7 +191,6 @@ struct module_symbols_t
# define __vlc_cond_init p_symbols->__vlc_cond_init_inner # define __vlc_cond_init p_symbols->__vlc_cond_init_inner
# define __vlc_dumpstructure p_symbols->__vlc_dumpstructure_inner # define __vlc_dumpstructure p_symbols->__vlc_dumpstructure_inner
# define __vlc_list_find p_symbols->__vlc_list_find_inner # define __vlc_list_find p_symbols->__vlc_list_find_inner
# define __vlc_list_release p_symbols->__vlc_list_release_inner
# define __vlc_liststructure p_symbols->__vlc_liststructure_inner # define __vlc_liststructure p_symbols->__vlc_liststructure_inner
# define __vlc_mutex_destroy p_symbols->__vlc_mutex_destroy_inner # define __vlc_mutex_destroy p_symbols->__vlc_mutex_destroy_inner
# define __vlc_mutex_init p_symbols->__vlc_mutex_init_inner # define __vlc_mutex_init p_symbols->__vlc_mutex_init_inner
...@@ -272,6 +271,7 @@ struct module_symbols_t ...@@ -272,6 +271,7 @@ struct module_symbols_t
# define playlist_Command p_symbols->playlist_Command_inner # define playlist_Command p_symbols->playlist_Command_inner
# define playlist_Delete p_symbols->playlist_Delete_inner # define playlist_Delete p_symbols->playlist_Delete_inner
# define sout_DeleteInstance p_symbols->sout_DeleteInstance_inner # define sout_DeleteInstance p_symbols->sout_DeleteInstance_inner
# define vlc_list_release p_symbols->vlc_list_release_inner
# define vout_AllocatePicture p_symbols->vout_AllocatePicture_inner # define vout_AllocatePicture p_symbols->vout_AllocatePicture_inner
# define vout_ChromaCmp p_symbols->vout_ChromaCmp_inner # define vout_ChromaCmp p_symbols->vout_ChromaCmp_inner
# define vout_CreatePicture p_symbols->vout_CreatePicture_inner # define vout_CreatePicture p_symbols->vout_CreatePicture_inner
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk_preferences.c: functions to handle the preferences dialog box. * gtk_preferences.c: functions to handle the preferences dialog box.
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: preferences.c,v 1.3 2002/08/14 17:06:53 sam Exp $ * $Id: preferences.c,v 1.4 2002/08/15 12:11:15 sam Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Loc Minier <lool@via.ecp.fr> * Loc Minier <lool@via.ecp.fr>
...@@ -118,7 +118,8 @@ void GtkPreferencesShow( GtkMenuItem * menuitem, gpointer user_data ) ...@@ -118,7 +118,8 @@ void GtkPreferencesShow( GtkMenuItem * menuitem, gpointer user_data )
static void GtkCreateConfigDialog( char *psz_module_name, static void GtkCreateConfigDialog( char *psz_module_name,
intf_thread_t *p_intf ) intf_thread_t *p_intf )
{ {
module_t *p_module; module_t **pp_parser;
vlc_list_t *p_list;
module_config_t *p_item; module_config_t *p_item;
guint rows = 0; guint rows = 0;
...@@ -173,27 +174,36 @@ static void GtkCreateConfigDialog( char *psz_module_name, ...@@ -173,27 +174,36 @@ static void GtkCreateConfigDialog( char *psz_module_name,
/* Look for the selected module */ /* Look for the selected module */
for( p_module = p_intf->p_vlc->p_module_bank->first ; p_module != NULL ; p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
p_module = p_module->next )
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
{ {
if( psz_module_name if( psz_module_name
&& !strcmp( psz_module_name, p_module->psz_object_name ) ) && !strcmp( psz_module_name, (*pp_parser)->psz_object_name ) )
{ {
break; break;
} }
} }
if( !p_module ) return;
if( !(*pp_parser) )
{
vlc_list_release( p_list );
return;
}
/* We found it, now we can start building its configuration interface */ /* We found it, now we can start building its configuration interface */
/* Create the configuration dialog box */ /* Create the configuration dialog box */
#ifdef MODULE_NAME_IS_gnome #ifdef MODULE_NAME_IS_gnome
config_dialog = gnome_dialog_new( p_module->psz_longname, NULL ); config_dialog = gnome_dialog_new( (*pp_parser)->psz_longname, NULL );
config_dialog_vbox = GNOME_DIALOG(config_dialog)->vbox; config_dialog_vbox = GNOME_DIALOG(config_dialog)->vbox;
#else #else
config_dialog = gtk_dialog_new(); config_dialog = gtk_dialog_new();
gtk_window_set_title( GTK_WINDOW(config_dialog), p_module->psz_longname ); gtk_window_set_title( GTK_WINDOW(config_dialog),
(*pp_parser)->psz_longname );
config_dialog_vbox = GTK_DIALOG(config_dialog)->vbox; config_dialog_vbox = GTK_DIALOG(config_dialog)->vbox;
#endif #endif
...@@ -215,8 +225,9 @@ static void GtkCreateConfigDialog( char *psz_module_name, ...@@ -215,8 +225,9 @@ static void GtkCreateConfigDialog( char *psz_module_name,
gtk_container_add( GTK_CONTAINER(config_dialog_vbox), config_notebook ); gtk_container_add( GTK_CONTAINER(config_dialog_vbox), config_notebook );
/* Enumerate config options and add corresponding config boxes */ /* Enumerate config options and add corresponding config boxes */
p_item = p_module->p_config; p_item = (*pp_parser)->p_config;
do
if( p_item ) do
{ {
switch( p_item->i_type ) switch( p_item->i_type )
{ {
...@@ -318,9 +329,7 @@ static void GtkCreateConfigDialog( char *psz_module_name, ...@@ -318,9 +329,7 @@ static void GtkCreateConfigDialog( char *psz_module_name,
/* build a list of available modules */ /* build a list of available modules */
{ {
gchar * entry[2]; gchar * entry[2];
vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, pp_parser = (module_t **)p_list->pp_objects;
FIND_ANYWHERE );
module_t **pp_parser = (module_t **)p_list->pp_objects;
for( ; *pp_parser ; pp_parser++ ) for( ; *pp_parser ; pp_parser++ )
{ {
...@@ -332,8 +341,6 @@ static void GtkCreateConfigDialog( char *psz_module_name, ...@@ -332,8 +341,6 @@ static void GtkCreateConfigDialog( char *psz_module_name,
gtk_clist_append( GTK_CLIST(module_clist), entry ); gtk_clist_append( GTK_CLIST(module_clist), entry );
} }
} }
vlc_list_release( p_intf, p_list );
} }
gtk_clist_set_column_auto_resize( GTK_CLIST(module_clist), gtk_clist_set_column_auto_resize( GTK_CLIST(module_clist),
...@@ -508,6 +515,8 @@ static void GtkCreateConfigDialog( char *psz_module_name, ...@@ -508,6 +515,8 @@ static void GtkCreateConfigDialog( char *psz_module_name,
} }
while( p_item->i_type != CONFIG_HINT_END && p_item++ ); while( p_item->i_type != CONFIG_HINT_END && p_item++ );
vlc_list_release( p_list );
#ifndef MODULE_NAME_IS_gnome #ifndef MODULE_NAME_IS_gnome
/* Now let's add the action buttons at the bottom of the page */ /* Now let's add the action buttons at the bottom of the page */
dialog_action_area = GTK_DIALOG(config_dialog)->action_area; dialog_action_area = GTK_DIALOG(config_dialog)->action_area;
...@@ -649,26 +658,32 @@ void GtkModuleHighlighted( GtkCList *module_clist, int row, int column, ...@@ -649,26 +658,32 @@ void GtkModuleHighlighted( GtkCList *module_clist, int row, int column,
{ {
intf_thread_t *p_intf; intf_thread_t *p_intf;
GtkWidget *config_button; GtkWidget *config_button;
module_t *p_module; module_t **pp_parser;
vlc_list_t *p_list;
char *psz_name; char *psz_name;
p_intf = (intf_thread_t *)gtk_object_get_data( GTK_OBJECT(module_clist), p_intf = (intf_thread_t *)gtk_object_get_data( GTK_OBJECT(module_clist),
"p_intf" ); "p_intf" );
if( gtk_clist_get_text( GTK_CLIST(module_clist), row, 0, &psz_name ) ) if( !gtk_clist_get_text( GTK_CLIST(module_clist), row, 0, &psz_name ) )
{ {
return;
}
/* look for module 'psz_name' */ /* look for module 'psz_name' */
for( p_module = p_intf->p_vlc->p_module_bank->first ; p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
p_module != NULL ;
p_module = p_module->next ) for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
{ {
if( !strcmp( p_module->psz_object_name, psz_name ) ) if( !strcmp( (*pp_parser)->psz_object_name, psz_name ) )
{ {
gtk_object_set_data( GTK_OBJECT(module_clist), gtk_object_set_data( GTK_OBJECT(module_clist),
"module_highlighted", p_module ); "module_highlighted", (*pp_parser) );
config_button = gtk_object_get_data( GTK_OBJECT(module_clist), config_button = gtk_object_get_data( GTK_OBJECT(module_clist),
"config_button" ); "config_button" );
if( p_module->i_config_items ) if( (*pp_parser)->i_config_items )
gtk_widget_set_sensitive( config_button, TRUE ); gtk_widget_set_sensitive( config_button, TRUE );
else else
gtk_widget_set_sensitive( config_button, FALSE ); gtk_widget_set_sensitive( config_button, FALSE );
...@@ -677,7 +692,7 @@ void GtkModuleHighlighted( GtkCList *module_clist, int row, int column, ...@@ -677,7 +692,7 @@ void GtkModuleHighlighted( GtkCList *module_clist, int row, int column,
} }
} }
} vlc_list_release( p_list );
} }
/**************************************************************************** /****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* preferences.cpp: preferences window for the kde gui * preferences.cpp: preferences window for the kde gui
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: preferences.cpp,v 1.3 2002/08/14 17:06:53 sam Exp $ * $Id: preferences.cpp,v 1.4 2002/08/15 12:11:15 sam Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> Mon Aug 12 2002 * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> Mon Aug 12 2002
* *
...@@ -51,7 +51,6 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name, ...@@ -51,7 +51,6 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name,
KDialogBase ( Tabbed, caption, Ok| Apply|Cancel|User1, Ok, parent, KDialogBase ( Tabbed, caption, Ok| Apply|Cancel|User1, Ok, parent,
"vlc preferences", true, false, "Save") "vlc preferences", true, false, "Save")
{ {
module_t *p_module;
module_t **pp_parser; module_t **pp_parser;
vlc_list_t *p_list; vlc_list_t *p_list;
module_config_t *p_item; module_config_t *p_item;
...@@ -60,17 +59,30 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name, ...@@ -60,17 +59,30 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name,
this->p_intf = p_intf; this->p_intf = p_intf;
/* List all modules */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
/* Look for the selected module */ /* Look for the selected module */
for( p_module = p_intf->p_vlc->p_module_bank->first ; p_module != NULL ; for( pp_parser = (module_t **)p_list->pp_objects ;
p_module = p_module->next ) *pp_parser ;
pp_parser++ )
{ {
if( psz_module_name && !strcmp( psz_module_name, p_module->psz_object_name ) ) if( psz_module_name
&& !strcmp( psz_module_name, (*pp_parser)->psz_object_name ) )
{
break; break;
} }
if( !p_module ) return; }
p_item = p_module->p_config;
do if( !(*pp_parser) )
{
vlc_list_release( p_list );
return;
}
p_item = (*pp_parser)->p_config;
if( p_item ) do
{ {
switch( p_item->i_type ) switch( p_item->i_type )
{ {
...@@ -118,11 +130,9 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name, ...@@ -118,11 +130,9 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name,
/* build a list of available plugins */ /* build a list of available plugins */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, for( pp_parser = (module_t **)p_list->pp_objects ;
FIND_ANYWHERE ); *pp_parser ;
pp_parser = (module_t **)p_list->pp_objects; pp_parser++ )
for( ; *pp_parser ; pp_parser++ )
{ {
if( !strcmp( (*pp_parser)->psz_capability, if( !strcmp( (*pp_parser)->psz_capability,
p_item->psz_type ) ) p_item->psz_type ) )
...@@ -132,7 +142,6 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name, ...@@ -132,7 +142,6 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name,
(*pp_parser)->psz_longname); (*pp_parser)->psz_longname);
} }
} }
vlc_list_release( p_intf, p_list );
vlc_mutex_unlock( p_item->p_lock ); vlc_mutex_unlock( p_item->p_lock );
} }
...@@ -221,8 +230,10 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name, ...@@ -221,8 +230,10 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name,
p_item++; p_item++;
} }
while( p_item->i_type != CONFIG_HINT_END ); while( p_item->i_type != CONFIG_HINT_END );
exec();
vlc_list_release( p_list );
exec();
} }
/* /*
...@@ -237,16 +248,25 @@ KPreferences::~KPreferences() ...@@ -237,16 +248,25 @@ KPreferences::~KPreferences()
*/ */
bool KPreferences::isConfigureable(QString module) bool KPreferences::isConfigureable(QString module)
{ {
module_t *p_module; module_t **pp_parser;
for( p_module = p_intf->p_vlc->p_module_bank->first ; vlc_list_t *p_list;
p_module != NULL ;
p_module = p_module->next ) { p_list = vlc_list_find( this->p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
if( !module.compare( p_module->psz_object_name ) ) {
return p_module->i_config_items != 0; for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
{
if( !module.compare( (*pp_parser)->psz_object_name ) )
{
bool ret = (*pp_parser)->i_config_items != 0;
vlc_list_release( p_list );
return ret;
} }
} }
return false;
vlc_list_release( p_list );
return false;
} }
/* /*
......
...@@ -394,7 +394,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -394,7 +394,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
/* Enumerate config options and add corresponding config boxes */ /* Enumerate config options and add corresponding config boxes */
p_item = p_module->p_config; p_item = p_module->p_config;
do if( p_item ) do
{ {
switch( p_item->i_type ) switch( p_item->i_type )
{ {
...@@ -438,7 +438,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -438,7 +438,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
} }
} }
vlc_list_release( p_intfGlobal, p_list ); vlc_list_release( p_list );
break; break;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source * libvlc.c: main libvlc source
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.c,v 1.25 2002/08/12 09:34:15 sam Exp $ * $Id: libvlc.c,v 1.26 2002/08/15 12:11:15 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -272,13 +272,12 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -272,13 +272,12 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
} }
p_help_module->psz_object_name = "help"; p_help_module->psz_object_name = "help";
config_Duplicate( p_help_module, p_help_config ); config_Duplicate( p_help_module, p_help_config );
p_help_module->next = p_vlc->p_module_bank->first; vlc_object_attach( p_help_module, p_vlc->p_module_bank );
p_vlc->p_module_bank->first = p_help_module;
/* End hack */ /* End hack */
if( config_LoadCmdLine( p_vlc, &i_argc, ppsz_argv, VLC_TRUE ) ) if( config_LoadCmdLine( p_vlc, &i_argc, ppsz_argv, VLC_TRUE ) )
{ {
p_vlc->p_module_bank->first = p_help_module->next; vlc_object_detach( p_help_module );
config_Free( p_help_module ); config_Free( p_help_module );
vlc_object_destroy( p_help_module ); vlc_object_destroy( p_help_module );
module_EndBank( p_vlc ); module_EndBank( p_vlc );
...@@ -294,7 +293,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -294,7 +293,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
Usage( p_vlc, "help" ); Usage( p_vlc, "help" );
Usage( p_vlc, "main" ); Usage( p_vlc, "main" );
p_vlc->p_module_bank->first = p_help_module->next; vlc_object_detach( p_help_module );
config_Free( p_help_module ); config_Free( p_help_module );
vlc_object_destroy( p_help_module ); vlc_object_destroy( p_help_module );
module_EndBank( p_vlc ); module_EndBank( p_vlc );
...@@ -306,7 +305,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -306,7 +305,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
if( config_GetInt( p_vlc, "version" ) ) if( config_GetInt( p_vlc, "version" ) )
{ {
Version(); Version();
p_vlc->p_module_bank->first = p_help_module->next; vlc_object_detach( p_help_module );
config_Free( p_help_module ); config_Free( p_help_module );
vlc_object_destroy( p_help_module ); vlc_object_destroy( p_help_module );
module_EndBank( p_vlc ); module_EndBank( p_vlc );
...@@ -315,7 +314,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -315,7 +314,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
} }
/* Hack: remove the help module here */ /* Hack: remove the help module here */
p_vlc->p_module_bank->first = p_help_module->next; vlc_object_detach( p_help_module );
/* End hack */ /* End hack */
/* /*
...@@ -327,11 +326,10 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -327,11 +326,10 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
module_LoadBuiltins( p_vlc ); module_LoadBuiltins( p_vlc );
module_LoadPlugins( p_vlc ); module_LoadPlugins( p_vlc );
msg_Dbg( p_vlc, "module bank initialized, found %i modules", msg_Dbg( p_vlc, "module bank initialized, found %i modules",
p_vlc->p_module_bank->i_count ); p_vlc->p_module_bank->i_children );
/* Hack: insert the help module here */ /* Hack: insert the help module here */
p_help_module->next = p_vlc->p_module_bank->first; vlc_object_attach( p_help_module, p_vlc->p_module_bank );
p_vlc->p_module_bank->first = p_help_module;
/* End hack */ /* End hack */
/* Check for help on modules */ /* Check for help on modules */
...@@ -339,7 +337,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -339,7 +337,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
{ {
Usage( p_vlc, p_tmp ); Usage( p_vlc, p_tmp );
free( p_tmp ); free( p_tmp );
p_vlc->p_module_bank->first = p_help_module->next; vlc_object_detach( p_help_module );
config_Free( p_help_module ); config_Free( p_help_module );
vlc_object_destroy( p_help_module ); vlc_object_destroy( p_help_module );
module_EndBank( p_vlc ); module_EndBank( p_vlc );
...@@ -351,7 +349,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -351,7 +349,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
if( config_GetInt( p_vlc, "longhelp" ) ) if( config_GetInt( p_vlc, "longhelp" ) )
{ {
Usage( p_vlc, NULL ); Usage( p_vlc, NULL );
p_vlc->p_module_bank->first = p_help_module->next; vlc_object_detach( p_help_module );
config_Free( p_help_module ); config_Free( p_help_module );
vlc_object_destroy( p_help_module ); vlc_object_destroy( p_help_module );
module_EndBank( p_vlc ); module_EndBank( p_vlc );
...@@ -363,7 +361,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -363,7 +361,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
if( config_GetInt( p_vlc, "list" ) ) if( config_GetInt( p_vlc, "list" ) )
{ {
ListModules( p_vlc ); ListModules( p_vlc );
p_vlc->p_module_bank->first = p_help_module->next; vlc_object_detach( p_help_module );
config_Free( p_help_module ); config_Free( p_help_module );
vlc_object_destroy( p_help_module ); vlc_object_destroy( p_help_module );
module_EndBank( p_vlc ); module_EndBank( p_vlc );
...@@ -372,7 +370,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -372,7 +370,7 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
} }
/* Hack: remove the help module here */ /* Hack: remove the help module here */
p_vlc->p_module_bank->first = p_help_module->next; vlc_object_detach( p_help_module );
config_Free( p_help_module ); config_Free( p_help_module );
vlc_object_destroy( p_help_module ); vlc_object_destroy( p_help_module );
/* End hack */ /* End hack */
...@@ -902,7 +900,8 @@ static void Usage( vlc_t *p_this, const char *psz_module_name ) ...@@ -902,7 +900,8 @@ static void Usage( vlc_t *p_this, const char *psz_module_name )
*/ */
#define LINE_START 8 #define LINE_START 8
#define PADDING_SPACES 25 #define PADDING_SPACES 25
module_t *p_module; vlc_list_t *p_list;
module_t **pp_parser;
module_config_t *p_item; module_config_t *p_item;
char psz_spaces[PADDING_SPACES+LINE_START+1]; char psz_spaces[PADDING_SPACES+LINE_START+1];
char psz_format[sizeof(FORMAT_STRING)]; char psz_format[sizeof(FORMAT_STRING)];
...@@ -916,30 +915,34 @@ static void Usage( vlc_t *p_this, const char *psz_module_name ) ...@@ -916,30 +915,34 @@ static void Usage( vlc_t *p_this, const char *psz_module_name )
ShowConsole(); ShowConsole();
#endif #endif
/* List all modules */
p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
/* Enumerate the config for each module */ /* Enumerate the config for each module */
for( p_module = p_this->p_vlc->p_module_bank->first ; for( pp_parser = (module_t **)p_list->pp_objects ;
p_module != NULL ; *pp_parser ;
p_module = p_module->next ) pp_parser++ )
{ {
vlc_bool_t b_help_module = !strcmp( "help", p_module->psz_object_name ); vlc_bool_t b_help_module =
!strcmp( "help", (*pp_parser)->psz_object_name );
if( psz_module_name && strcmp( psz_module_name, if( psz_module_name && strcmp( psz_module_name,
p_module->psz_object_name ) ) (*pp_parser)->psz_object_name ) )
{ {
continue; continue;
} }
/* Ignore modules without config options */ /* Ignore modules without config options */
if( !p_module->i_config_items ) if( !(*pp_parser)->i_config_items )
{ {
continue; continue;
} }
/* Print module name */ /* Print module name */
fprintf( stderr, _("%s module options:\n\n"), fprintf( stderr, _("%s module options:\n\n"),
p_module->psz_object_name ); (*pp_parser)->psz_object_name );
for( p_item = p_module->p_config; for( p_item = (*pp_parser)->p_config;
p_item->i_type != CONFIG_HINT_END; p_item->i_type != CONFIG_HINT_END;
p_item++ ) p_item++ )
{ {
...@@ -1072,6 +1075,9 @@ static void Usage( vlc_t *p_this, const char *psz_module_name ) ...@@ -1072,6 +1075,9 @@ static void Usage( vlc_t *p_this, const char *psz_module_name )
} }
/* Release the module list */
vlc_list_release( p_list );
#ifdef WIN32 /* Pause the console because it's destroyed when we exit */ #ifdef WIN32 /* Pause the console because it's destroyed when we exit */
fprintf( stderr, _("\nPress the RETURN key to continue...\n") ); fprintf( stderr, _("\nPress the RETURN key to continue...\n") );
getchar(); getchar();
...@@ -1086,7 +1092,8 @@ static void Usage( vlc_t *p_this, const char *psz_module_name ) ...@@ -1086,7 +1092,8 @@ static void Usage( vlc_t *p_this, const char *psz_module_name )
*****************************************************************************/ *****************************************************************************/
static void ListModules( vlc_t *p_this ) static void ListModules( vlc_t *p_this )
{ {
module_t *p_module; vlc_list_t *p_list;
module_t **pp_parser;
char psz_spaces[22]; char psz_spaces[22];
memset( psz_spaces, ' ', 22 ); memset( psz_spaces, ' ', 22 );
...@@ -1101,24 +1108,26 @@ static void ListModules( vlc_t *p_this ) ...@@ -1101,24 +1108,26 @@ static void ListModules( vlc_t *p_this )
fprintf( stderr, _("[module] [description]\n") ); fprintf( stderr, _("[module] [description]\n") );
/* List all modules */
p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
/* Enumerate each module */ /* Enumerate each module */
for( p_module = p_this->p_vlc->p_module_bank->first ; for( pp_parser = (module_t **)p_list->pp_objects ;
p_module != NULL ; *pp_parser ;
p_module = p_module->next ) pp_parser++ )
{ {
int i; int i;
/* Nasty hack, but right now I'm too tired to think about a nice /* Nasty hack, but right now I'm too tired to think about a nice
* solution */ * solution */
i = 22 - strlen( p_module->psz_object_name ) - 1; i = 22 - strlen( (*pp_parser)->psz_object_name ) - 1;
if( i < 0 ) i = 0; if( i < 0 ) i = 0;
psz_spaces[i] = 0; psz_spaces[i] = 0;
fprintf( stderr, " %s%s %s\n", p_module->psz_object_name, psz_spaces, fprintf( stderr, " %s%s %s\n", (*pp_parser)->psz_object_name,
p_module->psz_longname ); psz_spaces, (*pp_parser)->psz_longname );
psz_spaces[i] = ' '; psz_spaces[i] = ' ';
} }
#ifdef WIN32 /* Pause the console because it's destroyed when we exit */ #ifdef WIN32 /* Pause the console because it's destroyed when we exit */
......
This diff is collapsed.
This diff is collapsed.
...@@ -304,7 +304,7 @@ static const char * module_error( char *psz_buffer ) ...@@ -304,7 +304,7 @@ static const char * module_error( char *psz_buffer )
(p_symbols)->__vlc_object_yield_inner = __vlc_object_yield; \ (p_symbols)->__vlc_object_yield_inner = __vlc_object_yield; \
(p_symbols)->__vlc_object_release_inner = __vlc_object_release; \ (p_symbols)->__vlc_object_release_inner = __vlc_object_release; \
(p_symbols)->__vlc_list_find_inner = __vlc_list_find; \ (p_symbols)->__vlc_list_find_inner = __vlc_list_find; \
(p_symbols)->__vlc_list_release_inner = __vlc_list_release; \ (p_symbols)->vlc_list_release_inner = vlc_list_release; \
(p_symbols)->__vlc_liststructure_inner = __vlc_liststructure; \ (p_symbols)->__vlc_liststructure_inner = __vlc_liststructure; \
(p_symbols)->__vlc_dumpstructure_inner = __vlc_dumpstructure; \ (p_symbols)->__vlc_dumpstructure_inner = __vlc_dumpstructure; \
(p_symbols)->playlist_Command_inner = playlist_Command; \ (p_symbols)->playlist_Command_inner = playlist_Command; \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* objects.c: vlc_object_t handling * objects.c: vlc_object_t handling
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: objects.c,v 1.18 2002/08/14 17:06:53 sam Exp $ * $Id: objects.c,v 1.19 2002/08/15 12:11:15 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -410,9 +410,8 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode ) ...@@ -410,9 +410,8 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
/***************************************************************************** /*****************************************************************************
* vlc_liststructure: print the current vlc objects * vlc_liststructure: print the current vlc objects
***************************************************************************** *****************************************************************************
* This function prints an ASCII tree showing the connections between vlc * This function prints alist of vlc objects, and additional information such
* objects, and additional information such as their refcount, thread ID, * as their refcount, thread ID, etc.
* address, etc.
*****************************************************************************/ *****************************************************************************/
void __vlc_liststructure( vlc_object_t *p_this ) void __vlc_liststructure( vlc_object_t *p_this )
{ {
...@@ -444,8 +443,7 @@ void __vlc_liststructure( vlc_object_t *p_this ) ...@@ -444,8 +443,7 @@ void __vlc_liststructure( vlc_object_t *p_this )
* vlc_dumpstructure: print the current vlc structure * vlc_dumpstructure: print the current vlc structure
***************************************************************************** *****************************************************************************
* This function prints an ASCII tree showing the connections between vlc * This function prints an ASCII tree showing the connections between vlc
* objects, and additional information such as their refcount, thread ID, * objects, and additional information such as their refcount, thread ID, etc.
* address, etc.
*****************************************************************************/ *****************************************************************************/
void __vlc_dumpstructure( vlc_object_t *p_this ) void __vlc_dumpstructure( vlc_object_t *p_this )
{ {
...@@ -463,19 +461,23 @@ void __vlc_dumpstructure( vlc_object_t *p_this ) ...@@ -463,19 +461,23 @@ void __vlc_dumpstructure( vlc_object_t *p_this )
* This function decreases the refcount of all objects in the list and * This function decreases the refcount of all objects in the list and
* frees the list. * frees the list.
*****************************************************************************/ *****************************************************************************/
void __vlc_list_release( vlc_object_t *p_this, vlc_list_t *p_list ) void vlc_list_release( vlc_list_t *p_list )
{ {
vlc_object_t **p_current = p_list->pp_objects; if( p_list->i_count )
{
vlc_t * p_vlc = p_list->pp_objects[0]->p_vlc;
vlc_object_t ** pp_current = p_list->pp_objects;
vlc_mutex_lock( &p_this->p_vlc->structure_lock ); vlc_mutex_lock( &p_vlc->structure_lock );
while( p_current[0] ) while( pp_current[0] )
{ {
p_current[0]->i_refcount--; pp_current[0]->i_refcount--;
p_current++; pp_current++;
} }
vlc_mutex_unlock( &p_this->p_vlc->structure_lock ); vlc_mutex_unlock( &p_vlc->structure_lock );
}
free( p_list ); free( p_list );
} }
......
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