*/
static inline void vlc_gcrypt_init (void)
{
- vlc_mutex_t *lock = var_AcquireMutex ("gcrypt_mutex");
- gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_vlc);
- vlc_mutex_unlock (lock);
+ /* This would need a process-wide static mutex with all libraries linking
+ * to a given instance of libgcrypt. We cannot do this as we have different
+ * plugins linking with gcrypt, and some underlying libraries may use it
+ * behind our back. Only way is to always link gcrypt statically (ouch!) or
+ * have upstream gcrypt provide one shared object per threading system. */
+ static vlc_mutex_t lock = VLC_STATIC_MUTEX;
+ static bool done = false;
+
+ vlc_mutex_lock (&lock);
+ if (!done)
+ {
+ gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_vlc);
+ done = true;
+ }
+ vlc_mutex_unlock (&lock);
}
}
/* ***** Open the codec ***** */
- vlc_mutex_t *lock = var_AcquireMutex( "avcodec" );
- if( lock == NULL )
- {
- free( p_sys->p_context->extradata );
- free( p_sys );
- return VLC_ENOMEM;
- }
+ vlc_mutex_lock( &avcodec_lock );
if (avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0)
{
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &avcodec_lock );
msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
free( p_sys->p_context->extradata );
free( p_sys );
return VLC_EGENERIC;
}
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &avcodec_lock );
msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
vlc_module_end();
+vlc_mutex_t avcodec_lock = VLC_STATIC_MUTEX;
+
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
*****************************************************************************/
free( p_sys->p_context->extradata );
p_sys->p_context->extradata = NULL;
- lock = var_AcquireMutex( "avcodec" );
+ vlc_mutex_lock( &avcodec_lock );
avcodec_close( p_sys->p_context );
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &avcodec_lock );
msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->psz_namecodec );
av_free( p_sys->p_context );
}
void InitLibavcodec( vlc_object_t *p_object )
{
- static int b_ffmpeginit = 0;
- vlc_mutex_t *lock = var_AcquireMutex( "avcodec" );
+ static bool b_ffmpeginit = false;
+
+ vlc_mutex_lock( &avcodec_lock );
/* *** init ffmpeg library (libavcodec) *** */
if( !b_ffmpeginit )
avcodec_init();
avcodec_register_all();
av_log_set_callback( LibavutilCallback );
- b_ffmpeginit = 1;
+ b_ffmpeginit = true;
- msg_Dbg( p_object, "libavcodec initialized (interface %d )",
+ msg_Dbg( p_object, "libavcodec initialized (interface 0x%x)",
LIBAVCODEC_VERSION_INT );
}
else
msg_Dbg( p_object, "libavcodec already initialized" );
}
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &avcodec_lock );
}
AVCodec *p_codec, int i_codec_id, const char *psz_namecodec );
void EndAudioDec( decoder_t *p_dec );
+/* Avcodec global lock */
+extern vlc_mutex_t avcodec_lock;
+
/*****************************************************************************
* Module descriptor help strings
*****************************************************************************/
p_context->extradata = NULL;
p_context->flags |= CODEC_FLAG_GLOBAL_HEADER;
- vlc_mutex_t *lock = var_AcquireMutex( "avcodec" );
+ vlc_mutex_lock( &avcodec_lock );
if( avcodec_open( p_context, p_codec ) )
{
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &avcodec_lock );
if( p_enc->fmt_in.i_cat == AUDIO_ES &&
(p_context->channels > 2 || i_codec_id == CODEC_ID_MP2
|| i_codec_id == CODEC_ID_MP3) )
}
p_context->codec = NULL;
- vlc_mutex_lock( lock );
+ vlc_mutex_lock( &avcodec_lock );
if( avcodec_open( p_context, p_codec ) )
{
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &avcodec_lock );
msg_Err( p_enc, "cannot open encoder" );
intf_UserFatal( p_enc, false,
_("Streaming / Transcoding failed"),
return VLC_EGENERIC;
}
}
- vlc_mutex_unlock( lock);
+ vlc_mutex_unlock( &avcodec_lock );
p_enc->fmt_out.i_extra = p_context->extradata_size;
if( p_enc->fmt_out.i_extra )
free( pp_contexts );
}
- vlc_mutex_t *lock = var_AcquireMutex( "avcodec" );
+ vlc_mutex_lock( &avcodec_lock );
avcodec_close( p_sys->p_context );
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &avcodec_lock );
av_free( p_sys->p_context );
free( p_sys->p_buffer );
}
/* ***** Open the codec ***** */
- vlc_mutex_t *lock = var_AcquireMutex( "avcodec" );
- if( lock == NULL )
- {
- free( p_sys->p_buffer_orig );
- free( p_sys );
- return VLC_ENOMEM;
- }
-
+ vlc_mutex_lock( &avcodec_lock );
if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 )
{
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &avcodec_lock );
msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
free( p_sys->p_buffer_orig );
free( p_sys );
return VLC_EGENERIC;
}
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &avcodec_lock );
msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
{
vlc_object_t *p_libvlc;
- vlc_mutex_t *p_lock;
int i_refcount;
ass_library_t *p_library;
ass_renderer_t *p_renderer;
static void SubpictureReleaseRegions( spu_t *p_spu, subpicture_t *p_subpic );
static void RegionDraw( subpicture_region_t *p_region, ass_image_t *p_img );
+static vlc_mutex_t libass_lock = VLC_STATIC_MUTEX;
+
//#define DEBUG_REGION
/*****************************************************************************
p_sys->i_refcount = 1;
/* Add a track */
- vlc_mutex_lock( p_sys->p_ass->p_lock );
+ vlc_mutex_lock( &libass_lock );
p_sys->p_track = p_track = ass_new_track( p_sys->p_ass->p_library );
if( !p_track )
{
- vlc_mutex_unlock( p_sys->p_ass->p_lock );
+ vlc_mutex_unlock( &libass_lock );
DecSysRelease( p_sys );
return VLC_EGENERIC;
}
ass_process_codec_private( p_track, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra );
- vlc_mutex_unlock( p_sys->p_ass->p_lock );
+ vlc_mutex_unlock( &libass_lock );
return VLC_SUCCESS;
}
vlc_mutex_unlock( &p_sys->lock );
vlc_mutex_destroy( &p_sys->lock );
- vlc_mutex_lock( p_sys->p_ass->p_lock );
+ vlc_mutex_lock( &libass_lock );
if( p_sys->p_track )
ass_free_track( p_sys->p_track );
- vlc_mutex_unlock( p_sys->p_ass->p_lock );
+ vlc_mutex_unlock( &libass_lock );
AssHandleRelease( p_sys->p_ass );
free( p_sys );
p_spu->b_ephemer = true;
p_spu->b_absolute = true;
- vlc_mutex_lock( p_sys->p_ass->p_lock );
+ vlc_mutex_lock( &libass_lock );
if( p_sys->p_track )
{
ass_process_chunk( p_sys->p_track, p_spu->p_sys->p_subs_data, p_spu->p_sys->i_subs_len,
p_spu->i_start / 1000, (p_spu->i_stop-p_spu->i_start) / 1000 );
}
- vlc_mutex_unlock( p_sys->p_ass->p_lock );
+ vlc_mutex_unlock( &libass_lock );
p_spu->pf_pre_render = PreRender;
p_spu->pf_update_regions = UpdateRegions;
return;
}
- vlc_mutex_lock( p_ass->p_lock );
+ vlc_mutex_lock( &libass_lock );
/* */
fmt = *p_fmt;
if( !i_changed && !b_fmt_changed )
{
- vlc_mutex_unlock( p_ass->p_lock );
+ vlc_mutex_unlock( &libass_lock );
return;
}
if( i_region <= 0 )
{
- vlc_mutex_unlock( p_ass->p_lock );
+ vlc_mutex_unlock( &libass_lock );
return;
}
*pp_region_last = r;
pp_region_last = &r->p_next;
}
- vlc_mutex_unlock( p_ass->p_lock );
+ vlc_mutex_unlock( &libass_lock );
}
static rectangle_t r_create( int x0, int y0, int x1, int y1 )
/* */
static ass_handle_t *AssHandleHold( decoder_t *p_dec )
{
- vlc_mutex_t *p_lock = var_AcquireMutex( "libass" );
- if( !p_lock )
- return NULL;
+ vlc_mutex_lock( &libass_lock );
ass_handle_t *p_ass = NULL;
ass_library_t *p_library = NULL;
p_ass->i_refcount++;
- vlc_mutex_unlock( p_lock );
+ vlc_mutex_unlock( &libass_lock );
return p_ass;
}
/* */
p_ass->p_libvlc = VLC_OBJECT(p_dec->p_libvlc);
- p_ass->p_lock = p_lock;
p_ass->i_refcount = 1;
/* Create libass library */
var_Set( p_dec->p_libvlc, "libass-handle", val );
/* */
- vlc_mutex_unlock( p_ass->p_lock );
+ vlc_mutex_unlock( &libass_lock );
return p_ass;
error:
ass_library_done( p_library );
free( p_ass );
- vlc_mutex_unlock( p_lock );
+ vlc_mutex_unlock( &libass_lock );
return NULL;
}
static void AssHandleRelease( ass_handle_t *p_ass )
{
- vlc_mutex_lock( p_ass->p_lock );
+ vlc_mutex_lock( &libass_lock );
p_ass->i_refcount--;
if( p_ass->i_refcount > 0 )
{
- vlc_mutex_unlock( p_ass->p_lock );
+ vlc_mutex_unlock( &libass_lock );
return;
}
val.p_address = NULL;
var_Set( p_ass->p_libvlc, "libass-handle", val );
- vlc_mutex_unlock( p_ass->p_lock );
+ vlc_mutex_unlock( &libass_lock );
free( p_ass );
}
}
}
+static vlc_mutex_t qt_mutex = VLC_STATIC_MUTEX;
+
/*****************************************************************************
* Close:
*****************************************************************************/
{
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys = p_dec->p_sys;
- vlc_mutex_t *lock;
/* get lock, avoid segfault */
- lock = var_AcquireMutex( "qt_mutex" );
+ vlc_mutex_lock( &qt_mutex );
if( p_dec->fmt_out.i_cat == AUDIO_ES )
{
#endif
#endif
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &qt_mutex );
free( p_sys );
}
unsigned long OutputBufferSize = 0;
/* get lock, avoid segfault */
- vlc_mutex_t *lock = var_AcquireMutex( "qt_mutex" );
- if( lock == NULL )
- return VLC_EGENERIC;
+ vlc_mutex_lock( &qt_mutex );
p_sys = calloc( sizeof( decoder_sys_t ), 1 );
p_dec->p_sys = p_sys;
p_sys->i_out = 0;
p_sys->i_out_frames = 0;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &qt_mutex );
return VLC_SUCCESS;
exit_error:
#ifdef LOADER
Restore_LDT_Keeper( p_sys->ldt_fs );
#endif
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &qt_mutex );
free( p_sys );
return VLC_EGENERIC;
{
int i_frames = p_sys->i_buffer / p_sys->InFrameSize;
unsigned long i_out_frames, i_out_bytes;
- vlc_mutex_t *lock = var_AcquireMutex( "qt_mutex ");
+ vlc_mutex_lock( &qt_mutex );
i_error = p_sys->SoundConverterConvertBuffer( p_sys->myConverter,
p_sys->p_buffer,
p_sys->out_buffer,
&i_out_frames,
&i_out_bytes );
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &qt_mutex );
/*
msg_Dbg( p_dec, "decoded %d frames -> %ld frames (error=%d)",
return VLC_ENOMEM;
#ifndef WIN32
- vlc_mutex_t *lock;
long i_result;
ComponentDescription desc;
Component prev;
fcc, p_dec->fmt_in.video.i_width, p_dec->fmt_in.video.i_height );
/* get lock, avoid segfault */
- lock = var_AcquireMutex( "qt_mutex" );
+ vlc_mutex_lock( &qt_mutex );
#ifdef __APPLE__
EnterMovies();
p_dec->fmt_out.video.i_height= p_dec->fmt_in.video.i_height;
p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_dec->fmt_in.video.i_width / p_dec->fmt_in.video.i_height;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &qt_mutex );
return VLC_SUCCESS;
exit_error:
#ifdef LOADER
Restore_LDT_Keeper( p_sys->ldt_fs );
#endif
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &qt_mutex );
#endif /* !WIN32 */
static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
- vlc_mutex_t *lock;
block_t *p_block;
picture_t *p_pic;
mtime_t i_pts;
return NULL;
}
- lock = var_AcquireMutex( "qt_mutex" );
+ vlc_mutex_lock( &qt_mutex );
if( ( p_pic = p_dec->pf_vout_buffer_new( p_dec ) ) )
{
p_pic->date = i_pts;
}
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &qt_mutex );
block_Release( p_block );
return p_pic;
}
#endif
+static vlc_mutex_t rm_mutex = VLC_STATIC_MUTEX;
+
static int InitVideo(decoder_t *p_dec)
{
int result;
struct rv_init_t init_data;
char fcc[4];
- vlc_mutex_t *lock;
char *g_decode_path;
int i_vide = p_dec->fmt_in.i_extra;
return VLC_EGENERIC;
}
- lock = var_AcquireMutex( "rm_mutex" );
- if ( lock == NULL )
- return VLC_EGENERIC;
+ vlc_mutex_lock( &rm_mutex );
p_sys->handle=NULL;
#ifdef WIN32
p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_dec->fmt_in.video.i_width / p_dec->fmt_in.video.i_height;
p_sys->inited = 0;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &rm_mutex );
return VLC_SUCCESS;
}
{
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys = p_dec->p_sys;
- vlc_mutex_t *lock;
/* get lock, avoid segfault */
- lock = var_AcquireMutex( "rm_mutex" );
+ vlc_mutex_lock( &rm_mutex );
#ifdef WIN32
if (dll_type == 1)
#endif
p_sys->inited = 0;
- if ( lock )
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &rm_mutex );
if ( p_sys )
free( p_sys );
static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
- vlc_mutex_t *lock;
block_t *p_block;
picture_t *p_pic;
mtime_t i_pts;
i_pts = p_block->i_pts ? p_block->i_pts : p_block->i_dts;
- lock = var_AcquireMutex( "rm_mutex" );
- if ( lock == NULL )
- return NULL;
+ vlc_mutex_lock( &rm_mutex );
p_pic = p_dec->pf_vout_buffer_new( p_dec );
p_pic->b_force = 1;
}
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &rm_mutex );
block_Release( p_block );
return p_pic;
static void FreeLine( line_desc_t * );
#ifdef HAVE_FONTCONFIG
-static vlc_object_t *FontBuilderAttach( filter_t *p_filter, vlc_mutex_t **pp_lock );
+static vlc_object_t *FontBuilderAttach( filter_t *p_filter );
static void FontBuilderDetach( filter_t *p_filter, vlc_object_t *p_fontbuilder );
static void* FontBuilderThread( vlc_object_t *p_this);
static void FontBuilderDestructor( vlc_object_t *p_this );
int i_default_font_size;
int i_display_height;
#ifdef HAVE_FONTCONFIG
- vlc_mutex_t *p_fontconfig_lock;
bool b_fontconfig_ok;
FcConfig *p_fontconfig;
#endif
#ifdef HAVE_FONTCONFIG
p_sys->b_fontconfig_ok = false;
p_sys->p_fontconfig = NULL;
- p_sys->p_fontbuilder = FontBuilderAttach( p_filter, &p_sys->p_fontconfig_lock );
+ p_sys->p_fontbuilder = FontBuilderAttach( p_filter );
#endif
p_sys->i_use_kerning = FT_HAS_KERNING( p_sys->p_face );
}
#ifdef HAVE_FONTCONFIG
-static vlc_object_t *FontBuilderAttach( filter_t *p_filter, vlc_mutex_t **pp_lock )
+static vlc_mutex_t fb_lock = VLC_STATIC_MUTEX;
+
+static vlc_object_t *FontBuilderAttach( filter_t *p_filter )
{
/* Check for an existing Fontbuilder thread */
- vlc_mutex_t *p_lock = var_AcquireMutex( "fontbuilder" );
+ vlc_mutex_lock( &fb_lock );
vlc_object_t *p_fontbuilder =
vlc_object_find_name( p_filter->p_libvlc,
"fontlist builder", FIND_CHILD );
var_AddCallback( p_fontbuilder, "build-done", FontBuilderDone, p_filter );
FontBuilderGetFcConfig( p_filter, p_fontbuilder );
}
- vlc_mutex_unlock( p_lock );
- *pp_lock = p_lock;
+ vlc_mutex_unlock( &fb_lock );
return p_fontbuilder;
}
static void FontBuilderDetach( filter_t *p_filter, vlc_object_t *p_fontbuilder )
{
- vlc_mutex_t *lock = var_AcquireMutex( "fontbuilder" );
+ vlc_mutex_lock( &fb_lock );
if( p_fontbuilder )
{
const bool b_alive = vlc_object_alive( p_fontbuilder );
if( b_alive )
{
vlc_object_kill( p_fontbuilder );
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &fb_lock );
/* We need to unlock otherwise we may not join (the thread waiting
* for the lock). It is safe to unlock as no one else will try a
* join and we have a reference on the object) */
vlc_thread_join( p_fontbuilder );
- vlc_mutex_lock( lock );
+ vlc_mutex_lock( &fb_lock );
}
vlc_object_release( p_fontbuilder );
}
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &fb_lock );
}
static void* FontBuilderThread( vlc_object_t *p_this )
{
msg_Dbg( p_this, "Finished building font database." );
msg_Dbg( p_this, "Took %ld seconds", (long)((t2 - t1)/1000000) );
- vlc_mutex_t *p_lock = var_AcquireMutex( "fontbuilder" );
+ vlc_mutex_lock( &fb_lock );
p_this->p_private = p_fontconfig;
- vlc_mutex_unlock( p_lock );
+ vlc_mutex_unlock( &fb_lock );
var_SetBool( p_this, "build-done", true );
vlc_restorecancel (canc);
if( newval.b_bool )
{
- vlc_mutex_t *p_lock = var_AcquireMutex( "fontbuilder" );
+ vlc_mutex_lock( &fb_lock );
FontBuilderGetFcConfig( p_filter, p_this );
- vlc_mutex_unlock( p_lock );
+ vlc_mutex_unlock( &fb_lock );
}
VLC_UNUSED(psz_var);
{
char *psz_fontfile = NULL;
- vlc_mutex_lock( p_sys->p_fontconfig_lock );
+ vlc_mutex_lock( &fb_lock );
if( p_sys->b_fontconfig_ok )
{
/* FIXME Is there really a race condition between FontConfig_Select with default fontconfig(NULL)
p_style->b_italic,
&i_idx );
}
- vlc_mutex_unlock( p_sys->p_fontconfig_lock );
+ vlc_mutex_unlock( &fb_lock );
if( psz_fontfile && ! *psz_fontfile )
{
CACHE_SIZE_LONGTEXT, true );
vlc_module_end();
+static vlc_mutex_t gnutls_mutex = VLC_STATIC_MUTEX;
+
/**
* Initializes GnuTLS with proper locking.
* @return VLC_SUCCESS on success, a VLC error code otherwise.
vlc_gcrypt_init (); /* GnuTLS depends on gcrypt */
- vlc_mutex_t *lock = var_AcquireMutex ("gnutls_mutex");
+ vlc_mutex_lock (&gnutls_mutex);
if (gnutls_global_init ())
{
msg_Err (p_this, "cannot initialize GnuTLS");
ret = VLC_SUCCESS;
error:
- vlc_mutex_unlock (lock);
+ vlc_mutex_unlock (&gnutls_mutex);
return ret;
}
*/
static void gnutls_Deinit (vlc_object_t *p_this)
{
- vlc_mutex_t *lock = var_AcquireMutex( "gnutls_mutex" );
+ vlc_mutex_lock (&gnutls_mutex);
gnutls_global_deinit ();
msg_Dbg (p_this, "GnuTLS deinitialized");
- vlc_mutex_unlock (lock);
+ vlc_mutex_unlock (&gnutls_mutex);
}
linked_with_a_crap_library_which_uses_atexit();
vlc_module_end();
+static vlc_mutex_t gtk_lock = VLC_STATIC_MUTEX;
+
/*****************************************************************************
* Open: initialize and create window
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
- vlc_mutex_t *lock;
-
- lock = var_AcquireMutex( "gtk" );
+ vlc_mutex_lock( >k_lock );
if( i_refcount > 0 )
{
}
i_refcount++;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( >k_lock );
return VLC_SUCCESS;
}
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
- vlc_mutex_t *lock;
-
- lock = var_AcquireMutex( "gtk" );
+ vlc_mutex_lock( >k_lock );
i_refcount--;
- if( i_refcount > 0 )
+ if( --i_refcount == 0 )
{
- vlc_mutex_unlock( lock );
- return;
- }
-
- gtk_main_quit();
- vlc_thread_join( p_gtk_main );
-
- vlc_object_release( p_gtk_main );
- p_gtk_main = NULL;
+ gtk_main_quit();
+ vlc_thread_join( p_gtk_main );
- vlc_mutex_unlock( lock );
+ vlc_object_release( p_gtk_main );
+ p_gtk_main = NULL;
+ }
+ vlc_mutex_unlock( >k_lock );
}
static gint foo( gpointer bar ) { return TRUE; }
} /* extern "C" */
+static vlc_mutex_t qte_lock = VLC_STATIC_MUTEX;
+
/*****************************************************************************
* Open: initialize and create window
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
- vlc_mutex_t *lock;
-
- lock = var_AcquireMutex( "qte" );
+ vlc_mutex_lock( &qte_lock );
if( i_refcount > 0 )
{
i_refcount++;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &qte_lock );
return VLC_SUCCESS;
}
}
i_refcount++;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &qte_lock );
vlc_object_attach( p_qte_main, p_this );
msg_Dbg( p_this, "qte_main running" );
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
- vlc_mutex_t *lock;
-
- lock = var_AcquireMutex( "qte" );
+ vlc_mutex_lock( &qte_lock );
i_refcount--;
vlc_object_release( p_qte_main );
p_qte_main = NULL;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &qte_lock );
}
/*****************************************************************************
#endif
vlc_module_end();
+static vlc_mutex_t sdl_lock = VLC_STATIC_MUTEX;
+
/*****************************************************************************
* OpenVideo: allocate SDL video thread output method
*****************************************************************************
{
vout_thread_t * p_vout = (vout_thread_t *)p_this;
/* XXX: check for conflicts with the SDL audio output */
- vlc_mutex_t *lock = var_AcquireMutex( "sdl" );
+ vlc_mutex_lock( &sdl_lock );
#ifdef HAVE_SETENV
char *psz_method;
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &sdl_lock );
return VLC_ENOMEM;
}
/* Check if SDL video module has been initialized */
if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 )
{
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &sdl_lock );
free( p_vout->p_sys );
return VLC_EGENERIC;
}
{
msg_Err( p_vout, "cannot initialize SDL (%s)", SDL_GetError() );
free( p_vout->p_sys );
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &sdl_lock );
return VLC_EGENERIC;
}
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &sdl_lock );
/* Translate keys into unicode */
SDL_EnableUNICODE(1);
static void InitDeviceValues( libvlc_int_t * );
+vlc_mutex_t global_lock = VLC_STATIC_MUTEX;
+
/**
* Allocate a libvlc instance, initialize global data if needed
* It also initializes the threading system
/* Now that the thread system is initialized, we don't have much, but
* at least we have variables */
- vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
+ vlc_mutex_lock( &global_lock );
if( i_instances == 0 )
{
/* Guess what CPU we have */
VLC_OBJECT_GENERIC, "libvlc" );
if( p_libvlc != NULL )
i_instances++;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &global_lock );
if( p_libvlc == NULL )
return NULL;
p_libvlc->p_hotkeys );
FREENULL( p_libvlc->p_hotkeys );
- vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
+ vlc_mutex_lock( &global_lock );
i_instances--;
if( i_instances == 0 )
/* System specific cleaning code */
system_End( p_libvlc );
}
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &global_lock );
msg_Flush( p_libvlc );
msg_Destroy( p_libvlc );
/*
* Threads subsystem
*/
+vlc_mutex_t global_lock; /* TODO: remove this crap */
/* Hopefully, no need to export this. There is a new thread API instead. */
void vlc_thread_cancel (vlc_object_t *);
static void FlushMsg ( msg_queue_t * );
static void PrintMsg ( vlc_object_t *, msg_item_t * );
+static vlc_mutex_t msg_stack_lock = VLC_STATIC_MUTEX;
+
/**
* Initialize messages queues
* This function initializes all message queues
SetFilePointer( QUEUE.logfile, 0, NULL, FILE_END );
#endif
- vlc_mutex_t *lock = var_AcquireMutex( "msg-stack" );
+ vlc_mutex_lock( &msg_stack_lock );
if( banks++ == 0 )
vlc_threadvar_create( &msg_context, NULL );
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &msg_stack_lock );
}
/**
FlushMsg( &QUEUE );
- vlc_mutex_t *lock = var_AcquireMutex( "msg-stack" );
+ vlc_mutex_lock( &msg_stack_lock );
if( --banks == 0 )
vlc_threadvar_delete( &msg_context );
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &msg_stack_lock );
#ifdef UNDER_CE
CloseHandle( QUEUE.logfile );
{
module_bank_t *p_bank = NULL;
- vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
+ vlc_mutex_lock( &global_lock );
if( p_module_bank == NULL )
{
else
p_module_bank->i_usage++;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &global_lock );
}
{
module_bank_t *p_bank;
- vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
+ vlc_mutex_lock( &global_lock );
p_bank = p_module_bank;
assert (p_bank != NULL);
if( --p_bank->i_usage > 0 )
{
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &global_lock );
return;
}
/*FIXME: For thread safety, we need to:
p_module_bank = NULL; - immediately, but that will crash the cache */
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &global_lock );
/* Save the configuration */
config_AutoSaveConfigFile( p_this );
*/
void __module_LoadBuiltins( vlc_object_t * p_this )
{
- vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
+ vlc_mutex_lock( &global_lock );
if( p_module_bank->b_builtins )
{
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &global_lock );
return;
}
p_module_bank->b_builtins = true;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &global_lock );
msg_Dbg( p_this, "checking builtin modules" );
ALLOCATE_ALL_BUILTINS();
void __module_LoadPlugins( vlc_object_t * p_this )
{
#ifdef HAVE_DYNAMIC_PLUGINS
- vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
+ vlc_mutex_lock( &global_lock );
if( p_module_bank->b_plugins )
{
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &global_lock );
return;
}
p_module_bank->b_plugins = true;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &global_lock );
msg_Dbg( p_this, "checking plugin modules" );