vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Sun Oct 21 12:30:56 2018 +0300| [cc42179c13346b26fdce929970cc885e23ef102f] | committer: Rémi Denis-Courmont
gst: use vlc_once() > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cc42179c13346b26fdce929970cc885e23ef102f --- modules/codec/gstreamer/gstdecode.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/modules/codec/gstreamer/gstdecode.c b/modules/codec/gstreamer/gstdecode.c index 413917d2ea..ca58e6d599 100644 --- a/modules/codec/gstreamer/gstdecode.c +++ b/modules/codec/gstreamer/gstdecode.c @@ -329,25 +329,23 @@ static gboolean vlc_gst_plugin_init( GstPlugin *p_plugin ) return TRUE; } -/* gst_init( ) is not thread-safe, hence a thread-safe wrapper */ -static bool vlc_gst_init( void ) -{ - static vlc_mutex_t init_lock = VLC_STATIC_MUTEX; - static bool b_registered = false; - bool b_ret = true; +static bool vlc_gst_registered = false; - vlc_mutex_lock( &init_lock ); +static void vlc_gst_init_once(void) +{ gst_init( NULL, NULL ); - if ( !b_registered ) - { - b_ret = gst_plugin_register_static( 1, 0, "videolan", + vlc_gst_registered = gst_plugin_register_static( 1, 0, "videolan", "VLC Gstreamer plugins", vlc_gst_plugin_init, "1.0.0", "LGPL", "NA", "vlc", "NA" ); - b_registered = b_ret; - } - vlc_mutex_unlock( &init_lock ); +} + +/* gst_init( ) is not thread-safe, hence a thread-safe wrapper */ +static bool vlc_gst_init( void ) +{ + static vlc_once_t once = VLC_STATIC_ONCE; - return b_ret; + vlc_once(&once, vlc_gst_init_once); + return vlc_gst_registered; } static GstStructure* vlc_to_gst_fmt( const es_format_t *p_fmt ) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
