[vlc-commits] mtp: use vlc_once()

Rémi Denis-Courmont git at videolan.org
Sun Oct 21 13:01:21 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Oct 21 12:42:09 2018 +0300| [d11a6b86221c4f2df6c5958e505bf922b59e7a96] | committer: Rémi Denis-Courmont

mtp: use vlc_once()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d11a6b86221c4f2df6c5958e505bf922b59e7a96
---

 modules/services_discovery/mtp.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/modules/services_discovery/mtp.c b/modules/services_discovery/mtp.c
index 8a51707711..6692effd29 100644
--- a/modules/services_discovery/mtp.c
+++ b/modules/services_discovery/mtp.c
@@ -79,9 +79,6 @@ typedef struct
     vlc_thread_t thread;
 } services_discovery_sys_t;
 
-static vlc_mutex_t mtp_lock = VLC_STATIC_MUTEX;
-static bool b_mtp_initialized = false;
-
 /*****************************************************************************
  * Open: initialize and create stuff
  *****************************************************************************/
@@ -96,13 +93,9 @@ static int Open( vlc_object_t *p_this )
     p_sd->description = _("MTP devices");
     p_sys->psz_name = NULL;
 
-    vlc_mutex_lock( &mtp_lock );
-    if( !b_mtp_initialized )
-    {
-        LIBMTP_Init();
-        b_mtp_initialized = true;
-    }
-    vlc_mutex_unlock( &mtp_lock );
+    static vlc_once_t mtp_init_once = VLC_STATIC_ONCE;
+
+    vlc_once( &mtp_init_once, LIBMTP_Init );
 
     if (vlc_clone (&p_sys->thread, Run, p_sd, VLC_THREAD_PRIORITY_LOW))
     {



More information about the vlc-commits mailing list