[vlc-devel] Re: Reentrant module?
rem at videolan.org
Wed Feb 14 21:09:52 CET 2007
Le mercredi 14 février 2007 16:47, araceli manso a écrit :
> I´m writting a new decoder for vlc. And I would like to set one
> on the properties of the module.I want to fix "b_reentrant" to
> false, but I don´t how to do it. Somebody could help me?
You could set b_reentrant to false with: “p_module->b_reentrant =
VLC_FALSE;” in the plugin declaration (i.e. after vlc_module_begin()).
But AFAICT this flag is currently not implemented by VLC at all.
At the moment, all modules must be thread-safe; there is the p_sys
private pointer to store per-instance data. If a global mutex is
required, it can be implemented as follow:
if( var_Create( p_this->p_libvlc_global, "foobar_mutex",
VLC_VAR_MUTEX ) )
var_Get( p_this->p_libvlc_global, "foorbar_mutex", &lockval );
vlc_mutex_lock( lockval.p_address );
/* critical section */
vlc_mutex_unlock( lockval.p_access );
This should be sufficient to protect access to utterly non-thread safe
code. If it is really completely non-reentrant to the point where you
want a single instance at any given time, you can use the mutex trick
above plus a reference counter and return an error if the reference
counter is non-null in the module's Open callback. You should obviously
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 197 bytes
Desc: not available
More information about the vlc-devel