]> git.sesse.net Git - vlc/commitdiff
Make GnuTLS use pthread directly rather than VLC's API when appropriate.
authorRémi Denis-Courmont <rem@videolan.org>
Thu, 7 Sep 2006 19:23:03 +0000 (19:23 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Thu, 7 Sep 2006 19:23:03 +0000 (19:23 +0000)
This would be needed if libvlc is ever embedded in an application that
also uses GnuTLS.

include/vlc_threads.h
modules/misc/gnutls.c

index 913c89ad9bcfdac2d0786aae6bdbc5440302d9f8..9627fc1fc01bd8b22abd8cfebe2bc847cd6127c0 100644 (file)
@@ -48,6 +48,8 @@
 #   include <byteorder.h>
 
 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )  /* pthreads (like Linux & BSD) */
+#   define LIBVLC_USE_PTHREAD 1
+
 #   include <pthread.h>
 #   ifdef DEBUG
         /* Needed for pthread_cond_timedwait */
index b4234e676b4b2cc7c249053668635eeda183f58a..95de9edab124603d01107cddca6b480c34957ad1 100644 (file)
@@ -1134,10 +1134,16 @@ error:
 }
 
 
+#ifdef LIBVLC_USE_PTHREAD
+GCRY_THREAD_OPTION_PTHREAD_IMPL;
+# define gcry_threads_vlc gcry_threads_pthread
+#else
 /**
  * gcrypt thread option VLC implementation
  */
-vlc_object_t *__p_gcry_data;
+
+# define NEED_THREAD_CONTEXT 1
+static vlc_object_t *__p_gcry_data;
 
 static int gcry_vlc_mutex_init( void **p_sys )
 {
@@ -1184,6 +1190,7 @@ static struct gcry_thread_cbs gcry_threads_vlc =
     gcry_vlc_mutex_lock,
     gcry_vlc_mutex_unlock
 };
+#endif
 
 
 /*****************************************************************************
@@ -1206,9 +1213,9 @@ Open( vlc_object_t *p_this )
 
     if( count.i_int == 0)
     {
-        const char *psz_version;
-
+#ifdef NEED_THREAD_CONTEXT
         __p_gcry_data = VLC_OBJECT( p_this->p_vlc );
+#endif
 
         gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_vlc);
         if( gnutls_global_init( ) )
@@ -1218,7 +1225,7 @@ Open( vlc_object_t *p_this )
             return VLC_EGENERIC;
         }
 
-        psz_version = gnutls_check_version( "1.2.9" );
+        const char *psz_version = gnutls_check_version( "1.2.9" );
         if( psz_version == NULL )
         {
             gnutls_global_deinit( );