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

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