Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <errno.h>
00027
00028 #ifdef LIBVLC_USE_PTHREAD
00029
00030
00031
00032
00033 GCRY_THREAD_OPTION_PTHREAD_IMPL;
00034 # define gcry_threads_vlc gcry_threads_pthread
00035 #else
00036
00037
00038
00039
00040
00041 static int gcry_vlc_mutex_init( void **p_sys )
00042 {
00043 vlc_mutex_t *p_lock = (vlc_mutex_t *)malloc( sizeof( vlc_mutex_t ) );
00044 if( p_lock == NULL)
00045 return ENOMEM;
00046
00047 vlc_mutex_init( p_lock );
00048 *p_sys = p_lock;
00049 return VLC_SUCCESS;
00050 }
00051
00052 static int gcry_vlc_mutex_destroy( void **p_sys )
00053 {
00054 vlc_mutex_t *p_lock = (vlc_mutex_t *)*p_sys;
00055 vlc_mutex_destroy( p_lock );
00056 free( p_lock );
00057 return VLC_SUCCESS;
00058 }
00059
00060 static int gcry_vlc_mutex_lock( void **p_sys )
00061 {
00062 vlc_mutex_lock( (vlc_mutex_t *)*p_sys );
00063 return VLC_SUCCESS;
00064 }
00065
00066 static int gcry_vlc_mutex_unlock( void **lock )
00067 {
00068 vlc_mutex_unlock( (vlc_mutex_t *)*lock );
00069 return VLC_SUCCESS;
00070 }
00071
00072 static const struct gcry_thread_cbs gcry_threads_vlc =
00073 {
00074 GCRY_THREAD_OPTION_USER,
00075 NULL,
00076 gcry_vlc_mutex_init,
00077 gcry_vlc_mutex_destroy,
00078 gcry_vlc_mutex_lock,
00079 gcry_vlc_mutex_unlock,
00080 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
00081 };
00082 #endif
00083
00084
00085
00086
00087 static inline void vlc_gcrypt_init (void)
00088 {
00089
00090
00091
00092
00093
00094 static bool done = false;
00095
00096 vlc_global_lock (VLC_GCRYPT_MUTEX);
00097 if (!done)
00098 {
00099 gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_vlc);
00100 done = true;
00101 }
00102 vlc_global_unlock (VLC_GCRYPT_MUTEX);
00103 }