Commit 6e70470e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Remove module_hold and module_release

Modules are created at initialization and destroyed at exit (after all
VLC threads are terminated) There is no need to count references.
parent 6aea0905
...@@ -53,8 +53,6 @@ void module_stop(vlc_object_t *, const module_t *); ...@@ -53,8 +53,6 @@ void module_stop(vlc_object_t *, const module_t *);
VLC_API module_config_t * module_config_get( const module_t *, unsigned * ) VLC_USED; VLC_API module_config_t * module_config_get( const module_t *, unsigned * ) VLC_USED;
VLC_API void module_config_free( module_config_t * ); VLC_API void module_config_free( module_config_t * );
VLC_API module_t * module_hold(module_t *module);
VLC_API void module_release(module_t *module);
VLC_API void module_list_free(module_t **); VLC_API void module_list_free(module_t **);
VLC_API module_t ** module_list_get(size_t *n) VLC_USED; VLC_API module_t ** module_list_get(size_t *n) VLC_USED;
......
...@@ -1222,7 +1222,6 @@ unsigned int CocoaKeyToVLC( unichar i_key ) ...@@ -1222,7 +1222,6 @@ unsigned int CocoaKeyToVLC( unichar i_key )
} }
} }
module_config_free (p_config); module_config_free (p_config);
module_release (p_main);
o_usedHotkeys = [[NSArray alloc] initWithArray: o_usedHotkeys copyItems: YES]; o_usedHotkeys = [[NSArray alloc] initWithArray: o_usedHotkeys copyItems: YES];
} }
......
...@@ -632,8 +632,7 @@ static inline char * __config_GetLabel( vlc_object_t *p_this, const char *psz_na ...@@ -632,8 +632,7 @@ static inline char * __config_GetLabel( vlc_object_t *p_this, const char *psz_na
} }
} }
module_config_free (p_config); module_config_free (p_config);
module_release (p_main);
[o_hotkeyDescriptions release]; [o_hotkeyDescriptions release];
o_hotkeyDescriptions = [[NSArray alloc] initWithArray: o_tempArray_desc copyItems: YES]; o_hotkeyDescriptions = [[NSArray alloc] initWithArray: o_tempArray_desc copyItems: YES];
[o_tempArray_desc release]; [o_tempArray_desc release];
......
...@@ -187,7 +187,6 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) : ...@@ -187,7 +187,6 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
} }
} }
module_config_free( p_config ); module_config_free( p_config );
module_release( p_module );
module_t **p_list = module_list_get( NULL ); module_t **p_list = module_list_get( NULL );
...@@ -464,10 +463,7 @@ bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs ) ...@@ -464,10 +463,7 @@ bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs )
} }
if (name.contains( text, cs ) || head.contains( text, cs ) || help.contains( text, cs )) if (name.contains( text, cs ) || head.contains( text, cs ) || help.contains( text, cs ))
{
module_release( p_module );
return true; return true;
}
if( p_item ) do if( p_item ) do
{ {
...@@ -483,10 +479,7 @@ bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs ) ...@@ -483,10 +479,7 @@ bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs )
if( p_item->b_internal ) continue; if( p_item->b_internal ) continue;
if ( p_item->psz_text && qtr( p_item->psz_text ).contains( text, cs ) ) if ( p_item->psz_text && qtr( p_item->psz_text ).contains( text, cs ) )
{
module_release( p_module );
return true; return true;
}
} }
while ( while (
!( !(
...@@ -497,8 +490,6 @@ bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs ) ...@@ -497,8 +490,6 @@ bool PrefsItemData::contains( const QString &text, Qt::CaseSensitivity cs )
&& ( ++p_item < p_end ) && ( ++p_item < p_end )
); );
module_release( p_module );
return false; return false;
} }
...@@ -648,8 +639,6 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -648,8 +639,6 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
layout->addWidget( box, i_line, 0, 1, -1 ); layout->addWidget( box, i_line, 0, 1, -1 );
} }
module_release (p_module);
scrolled_area->setSizePolicy( QSizePolicy::Preferred,QSizePolicy::Fixed ); scrolled_area->setSizePolicy( QSizePolicy::Preferred,QSizePolicy::Fixed );
scrolled_area->setLayout( layout ); scrolled_area->setLayout( layout );
scroller->setWidget( scrolled_area ); scroller->setWidget( scrolled_area );
......
...@@ -317,11 +317,9 @@ static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_ ...@@ -317,11 +317,9 @@ static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_
} }
else else
{ {
module_release (p_obj);
msg_Err( p_intf, "Unknown video filter type." ); msg_Err( p_intf, "Unknown video filter type." );
return; return;
} }
module_release (p_obj);
psz_string = config_GetPsz( p_intf, psz_filter_type ); psz_string = config_GetPsz( p_intf, psz_filter_type );
......
...@@ -1339,6 +1339,5 @@ void CaptureOpenPanel::advancedDialog() ...@@ -1339,6 +1339,5 @@ void CaptureOpenPanel::advancedDialog()
qDeleteAll( controls ); qDeleteAll( controls );
delete adv; delete adv;
module_config_free( p_config ); module_config_free( p_config );
module_release (p_module);
} }
...@@ -1294,7 +1294,6 @@ void KeySelectorControl::finish() ...@@ -1294,7 +1294,6 @@ void KeySelectorControl::finish()
} }
} }
module_config_free (p_config); module_config_free (p_config);
module_release (p_main);
table->resizeColumnToContents( 0 ); table->resizeColumnToContents( 0 );
......
...@@ -268,12 +268,10 @@ module_get_name ...@@ -268,12 +268,10 @@ module_get_name
module_get_object module_get_object
module_get_score module_get_score
module_gettext module_gettext
module_hold
module_list_free module_list_free
module_list_get module_list_get
module_need module_need
module_provides module_provides
module_release
module_unneed module_unneed
vlc_module_load vlc_module_load
vlc_module_unload vlc_module_unload
......
...@@ -96,7 +96,6 @@ void xml_ReaderDelete(xml_reader_t *reader) ...@@ -96,7 +96,6 @@ void xml_ReaderDelete(xml_reader_t *reader)
{ {
if (reader->p_stream) if (reader->p_stream)
module_stop(reader, reader->p_module); module_stop(reader, reader->p_module);
module_release(reader->p_module);
vlc_object_release(reader); vlc_object_release(reader);
} }
...@@ -121,7 +120,6 @@ xml_reader_t *xml_ReaderReset(xml_reader_t *reader, stream_t *stream) ...@@ -121,7 +120,6 @@ xml_reader_t *xml_ReaderReset(xml_reader_t *reader, stream_t *stream)
reader->p_stream = stream; reader->p_stream = stream;
if ((stream != NULL) && module_start(reader, reader->p_module)) if ((stream != NULL) && module_start(reader, reader->p_module))
{ {
module_release(reader->p_module);
vlc_object_release(reader); vlc_object_release(reader);
return NULL; return NULL;
} }
......
...@@ -34,14 +34,6 @@ ...@@ -34,14 +34,6 @@
#include "config/configuration.h" #include "config/configuration.h"
#include "libvlc.h" #include "libvlc.h"
static void vlc_module_destruct (gc_object_t *obj)
{
module_t *module = vlc_priv (obj, module_t);
free (module->pp_shortcuts);
free (module);
}
module_t *vlc_module_create (void) module_t *vlc_module_create (void)
{ {
module_t *module = malloc (sizeof (*module)); module_t *module = malloc (sizeof (*module));
...@@ -52,7 +44,6 @@ module_t *vlc_module_create (void) ...@@ -52,7 +44,6 @@ module_t *vlc_module_create (void)
module->submodule = NULL; module->submodule = NULL;
module->parent = NULL; module->parent = NULL;
module->submodule_count = 0; module->submodule_count = 0;
vlc_gc_init (module, vlc_module_destruct);
module->psz_shortname = NULL; module->psz_shortname = NULL;
module->psz_longname = NULL; module->psz_longname = NULL;
...@@ -76,11 +67,8 @@ module_t *vlc_module_create (void) ...@@ -76,11 +67,8 @@ module_t *vlc_module_create (void)
return module; return module;
} }
void vlc_module_destroy (module_t *module)
static void vlc_submodule_destruct (gc_object_t *obj)
{ {
module_t *module = vlc_priv (obj, module_t);
free (module->pp_shortcuts); free (module->pp_shortcuts);
free (module); free (module);
} }
...@@ -94,8 +82,6 @@ module_t *vlc_submodule_create (module_t *module) ...@@ -94,8 +82,6 @@ module_t *vlc_submodule_create (module_t *module)
return NULL; return NULL;
/* TODO: replace module/submodules with plugin/modules */ /* TODO: replace module/submodules with plugin/modules */
vlc_gc_init (submodule, vlc_submodule_destruct);
submodule->next = module->submodule; submodule->next = module->submodule;
module->submodule = submodule; module->submodule = submodule;
module->submodule_count++; module->submodule_count++;
......
...@@ -280,17 +280,6 @@ const char *module_gettext (const module_t *m, const char *str) ...@@ -280,17 +280,6 @@ const char *module_gettext (const module_t *m, const char *str)
#endif #endif
} }
module_t *module_hold (module_t *m)
{
vlc_hold (&m->vlc_gc_data);
return m;
}
void module_release (module_t *m)
{
vlc_release (&m->vlc_gc_data);
}
#undef module_start #undef module_start
int module_start (vlc_object_t *obj, const module_t *m) int module_start (vlc_object_t *obj, const module_t *m)
{ {
...@@ -316,11 +305,6 @@ void module_stop (vlc_object_t *obj, const module_t *m) ...@@ -316,11 +305,6 @@ void module_stop (vlc_object_t *obj, const module_t *m)
*/ */
void module_list_free (module_t **list) void module_list_free (module_t **list)
{ {
if (list == NULL)
return;
for (size_t i = 0; list[i] != NULL; i++)
module_release (list[i]);
free (list); free (list);
} }
...@@ -348,9 +332,9 @@ module_t **module_list_get (size_t *n) ...@@ -348,9 +332,9 @@ module_t **module_list_get (size_t *n)
} }
tab = nt; tab = nt;
tab[i++] = module_hold (mod); tab[i++] = mod;
for (module_t *subm = mod->submodule; subm; subm = subm->next) for (module_t *subm = mod->submodule; subm; subm = subm->next)
tab[i++] = module_hold (subm); tab[i++] = subm;
tab[i] = NULL; tab[i] = NULL;
} }
if (n != NULL) if (n != NULL)
...@@ -508,7 +492,7 @@ module_t *vlc_module_load(vlc_object_t *p_this, const char *psz_capability, ...@@ -508,7 +492,7 @@ module_t *vlc_module_load(vlc_object_t *p_this, const char *psz_capability,
found_shortcut: found_shortcut:
/* Store this new module */ /* Store this new module */
p_list[count].p_module = module_hold (p_module); p_list[count].p_module = p_module;
p_list[count].i_score = p_module->i_score + i_shortcut_bonus; p_list[count].i_score = p_module->i_score + i_shortcut_bonus;
p_list[count].b_force = i_shortcut_bonus && b_strict; p_list[count].b_force = i_shortcut_bonus && b_strict;
count++; count++;
...@@ -542,7 +526,6 @@ found_shortcut: ...@@ -542,7 +526,6 @@ found_shortcut:
if( p_new_module == NULL ) if( p_new_module == NULL )
{ /* Corrupted module */ { /* Corrupted module */
msg_Err( p_this, "possibly corrupt module cache" ); msg_Err( p_this, "possibly corrupt module cache" );
module_release( p_cand );
continue; continue;
} }
CacheMerge( p_this, p_real, p_new_module ); CacheMerge( p_this, p_real, p_new_module );
...@@ -573,17 +556,11 @@ found_shortcut: ...@@ -573,17 +556,11 @@ found_shortcut:
case VLC_ETIMEOUT: case VLC_ETIMEOUT:
/* good module, but aborted */ /* good module, but aborted */
module_release( p_cand );
break; break;
default: /* bad module */ default: /* bad module */
module_release( p_cand );
continue; continue;
} }
/* Release the remaining modules */
while (++i < count)
module_release (p_list[i].p_module);
} }
va_end (args); va_end (args);
...@@ -631,7 +608,6 @@ void vlc_module_unload(module_t *module, vlc_deactivate_t deinit, ...) ...@@ -631,7 +608,6 @@ void vlc_module_unload(module_t *module, vlc_deactivate_t deinit, ...)
deinit(module->pf_deactivate, ap); deinit(module->pf_deactivate, ap);
va_end(ap); va_end(ap);
} }
module_release(module);
} }
...@@ -685,10 +661,7 @@ module_t *module_find (const char *name) ...@@ -685,10 +661,7 @@ module_t *module_find (const char *name)
if (unlikely(module->i_shortcuts == 0)) if (unlikely(module->i_shortcuts == 0))
continue; continue;
if (!strcmp (module->pp_shortcuts[0], name)) if (!strcmp (module->pp_shortcuts[0], name))
{
module_hold (module);
break; break;
}
} }
module_list_free (list); module_list_free (list);
return module; return module;
...@@ -702,10 +675,7 @@ module_t *module_find (const char *name) ...@@ -702,10 +675,7 @@ module_t *module_find (const char *name)
*/ */
bool module_exists (const char * psz_name) bool module_exists (const char * psz_name)
{ {
module_t *p_module = module_find (psz_name); return module_find (psz_name) != NULL;
if( p_module )
module_release (p_module);
return p_module != NULL;
} }
/** /**
...@@ -726,16 +696,9 @@ module_t *module_find_by_shortcut (const char *psz_shortcut) ...@@ -726,16 +696,9 @@ module_t *module_find_by_shortcut (const char *psz_shortcut)
return NULL; return NULL;
for (size_t i = 0; (module = list[i]) != NULL; i++) for (size_t i = 0; (module = list[i]) != NULL; i++)
{
for (size_t j = 0; j < module->i_shortcuts; j++) for (size_t j = 0; j < module->i_shortcuts; j++)
{
if (!strcmp (module->pp_shortcuts[j], psz_shortcut)) if (!strcmp (module->pp_shortcuts[j], psz_shortcut))
{
module_hold (module);
goto out; goto out;
}
}
}
out: out:
module_list_free (list); module_list_free (list);
return module; return module;
...@@ -1059,7 +1022,7 @@ static module_t *AllocatePlugin( vlc_object_t * p_this, const char *psz_file, ...@@ -1059,7 +1022,7 @@ static module_t *AllocatePlugin( vlc_object_t * p_this, const char *psz_file,
return p_module; return p_module;
error: error:
free( p_module->psz_filename ); free( p_module->psz_filename );
module_release( p_module ); vlc_module_destroy (p_module);
module_Unload( handle ); module_Unload( handle );
return NULL; return NULL;
} }
...@@ -1139,7 +1102,7 @@ static int AllocateBuiltinModule( vlc_object_t * p_this, ...@@ -1139,7 +1102,7 @@ static int AllocateBuiltinModule( vlc_object_t * p_this,
/* With a well-written module we shouldn't have to print an /* With a well-written module we shouldn't have to print an
* additional error message here, but just make sure. */ * additional error message here, but just make sure. */
msg_Err( p_this, "failed calling entry point in builtin module" ); msg_Err( p_this, "failed calling entry point in builtin module" );
module_release( p_module ); vlc_module_destroy (p_module);
return -1; return -1;
} }
...@@ -1187,9 +1150,9 @@ static void DeleteModule (module_t **head, module_t *p_module) ...@@ -1187,9 +1150,9 @@ static void DeleteModule (module_t **head, module_t *p_module)
{ {
module_t *submodule = p_module->submodule; module_t *submodule = p_module->submodule;
p_module->submodule = submodule->next; p_module->submodule = submodule->next;
module_release (submodule); vlc_module_destroy (submodule);
} }
config_Free( p_module ); config_Free( p_module );
module_release( p_module ); vlc_module_destroy (p_module);
} }
...@@ -62,8 +62,6 @@ typedef void * module_handle_t; ...@@ -62,8 +62,6 @@ typedef void * module_handle_t;
*/ */
struct module_t struct module_t
{ {
gc_object_t vlc_gc_data;
module_t *next; module_t *next;
module_t *parent; module_t *parent;
module_t *submodule; module_t *submodule;
...@@ -110,6 +108,7 @@ struct module_t ...@@ -110,6 +108,7 @@ struct module_t
module_t *vlc_module_create (void); module_t *vlc_module_create (void);
module_t *vlc_submodule_create (module_t *module); module_t *vlc_submodule_create (module_t *module);
void vlc_module_destroy (module_t *);
void module_InitBank( vlc_object_t * ); void module_InitBank( vlc_object_t * );
#define module_InitBank(a) module_InitBank(VLC_OBJECT(a)) #define module_InitBank(a) module_InitBank(VLC_OBJECT(a))
......
...@@ -484,11 +484,9 @@ void vout_EnableFilter( vout_thread_t *p_vout, const char *psz_name, ...@@ -484,11 +484,9 @@ void vout_EnableFilter( vout_thread_t *p_vout, const char *psz_name,
} }
else else
{ {
module_release( p_obj );
msg_Err( p_vout, "Unknown video filter type." ); msg_Err( p_vout, "Unknown video filter type." );
return; return;
} }
module_release( p_obj );
psz_string = var_GetString( p_vout, psz_filter_type ); psz_string = var_GetString( p_vout, psz_filter_type );
......
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