[vlc-devel] Re: Reentrant module?

Rémi Denis-Courmont 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", 
        return VLC_ENOMEM;
    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 
avoid this.

Rémi Denis-Courmont
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20070214/87bb696b/attachment.sig>

More information about the vlc-devel mailing list