Commit e3984284 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use static mutexes

parent 917aae76
...@@ -88,7 +88,19 @@ static const struct gcry_thread_cbs gcry_threads_vlc = ...@@ -88,7 +88,19 @@ static const struct gcry_thread_cbs gcry_threads_vlc =
*/ */
static inline void vlc_gcrypt_init (void) static inline void vlc_gcrypt_init (void)
{ {
vlc_mutex_t *lock = var_AcquireMutex ("gcrypt_mutex"); /* This would need a process-wide static mutex with all libraries linking
gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_vlc); * to a given instance of libgcrypt. We cannot do this as we have different
vlc_mutex_unlock (lock); * 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);
} }
...@@ -180,23 +180,17 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -180,23 +180,17 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
} }
/* ***** Open the codec ***** */ /* ***** Open the codec ***** */
vlc_mutex_t *lock = var_AcquireMutex( "avcodec" ); vlc_mutex_lock( &avcodec_lock );
if( lock == NULL )
{
free( p_sys->p_context->extradata );
free( p_sys );
return VLC_ENOMEM;
}
if (avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0) 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 ); msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
free( p_sys->p_context->extradata ); free( p_sys->p_context->extradata );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
vlc_mutex_unlock( lock ); vlc_mutex_unlock( &avcodec_lock );
msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec ); msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
......
...@@ -202,6 +202,8 @@ vlc_module_begin(); ...@@ -202,6 +202,8 @@ vlc_module_begin();
vlc_module_end(); vlc_module_end();
vlc_mutex_t avcodec_lock = VLC_STATIC_MUTEX;
/***************************************************************************** /*****************************************************************************
* OpenDecoder: probe the decoder and return score * OpenDecoder: probe the decoder and return score
*****************************************************************************/ *****************************************************************************/
...@@ -319,9 +321,9 @@ static void CloseDecoder( vlc_object_t *p_this ) ...@@ -319,9 +321,9 @@ static void CloseDecoder( vlc_object_t *p_this )
free( p_sys->p_context->extradata ); free( p_sys->p_context->extradata );
p_sys->p_context->extradata = NULL; p_sys->p_context->extradata = NULL;
lock = var_AcquireMutex( "avcodec" ); vlc_mutex_lock( &avcodec_lock );
avcodec_close( p_sys->p_context ); 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 ); msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->psz_namecodec );
av_free( p_sys->p_context ); av_free( p_sys->p_context );
} }
...@@ -331,8 +333,9 @@ static void CloseDecoder( vlc_object_t *p_this ) ...@@ -331,8 +333,9 @@ static void CloseDecoder( vlc_object_t *p_this )
void InitLibavcodec( vlc_object_t *p_object ) void InitLibavcodec( vlc_object_t *p_object )
{ {
static int b_ffmpeginit = 0; static bool b_ffmpeginit = false;
vlc_mutex_t *lock = var_AcquireMutex( "avcodec" );
vlc_mutex_lock( &avcodec_lock );
/* *** init ffmpeg library (libavcodec) *** */ /* *** init ffmpeg library (libavcodec) *** */
if( !b_ffmpeginit ) if( !b_ffmpeginit )
...@@ -340,9 +343,9 @@ void InitLibavcodec( vlc_object_t *p_object ) ...@@ -340,9 +343,9 @@ void InitLibavcodec( vlc_object_t *p_object )
avcodec_init(); avcodec_init();
avcodec_register_all(); avcodec_register_all();
av_log_set_callback( LibavutilCallback ); 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 ); LIBAVCODEC_VERSION_INT );
} }
else else
...@@ -350,5 +353,5 @@ void InitLibavcodec( vlc_object_t *p_object ) ...@@ -350,5 +353,5 @@ void InitLibavcodec( vlc_object_t *p_object )
msg_Dbg( p_object, "libavcodec already initialized" ); msg_Dbg( p_object, "libavcodec already initialized" );
} }
vlc_mutex_unlock( lock ); vlc_mutex_unlock( &avcodec_lock );
} }
...@@ -48,6 +48,9 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -48,6 +48,9 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
AVCodec *p_codec, int i_codec_id, const char *psz_namecodec ); AVCodec *p_codec, int i_codec_id, const char *psz_namecodec );
void EndAudioDec( decoder_t *p_dec ); void EndAudioDec( decoder_t *p_dec );
/* Avcodec global lock */
extern vlc_mutex_t avcodec_lock;
/***************************************************************************** /*****************************************************************************
* Module descriptor help strings * Module descriptor help strings
*****************************************************************************/ *****************************************************************************/
......
...@@ -604,11 +604,11 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -604,11 +604,11 @@ int OpenEncoder( vlc_object_t *p_this )
p_context->extradata = NULL; p_context->extradata = NULL;
p_context->flags |= CODEC_FLAG_GLOBAL_HEADER; 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 ) ) 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 && if( p_enc->fmt_in.i_cat == AUDIO_ES &&
(p_context->channels > 2 || i_codec_id == CODEC_ID_MP2 (p_context->channels > 2 || i_codec_id == CODEC_ID_MP2
|| i_codec_id == CODEC_ID_MP3) ) || i_codec_id == CODEC_ID_MP3) )
...@@ -658,10 +658,10 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -658,10 +658,10 @@ int OpenEncoder( vlc_object_t *p_this )
} }
p_context->codec = NULL; p_context->codec = NULL;
vlc_mutex_lock( lock ); vlc_mutex_lock( &avcodec_lock );
if( avcodec_open( p_context, p_codec ) ) if( avcodec_open( p_context, p_codec ) )
{ {
vlc_mutex_unlock( lock ); vlc_mutex_unlock( &avcodec_lock );
msg_Err( p_enc, "cannot open encoder" ); msg_Err( p_enc, "cannot open encoder" );
intf_UserFatal( p_enc, false, intf_UserFatal( p_enc, false,
_("Streaming / Transcoding failed"), _("Streaming / Transcoding failed"),
...@@ -679,7 +679,7 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -679,7 +679,7 @@ int OpenEncoder( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
} }
vlc_mutex_unlock( lock); vlc_mutex_unlock( &avcodec_lock );
p_enc->fmt_out.i_extra = p_context->extradata_size; p_enc->fmt_out.i_extra = p_context->extradata_size;
if( p_enc->fmt_out.i_extra ) if( p_enc->fmt_out.i_extra )
...@@ -1111,9 +1111,9 @@ void CloseEncoder( vlc_object_t *p_this ) ...@@ -1111,9 +1111,9 @@ void CloseEncoder( vlc_object_t *p_this )
free( pp_contexts ); free( pp_contexts );
} }
vlc_mutex_t *lock = var_AcquireMutex( "avcodec" ); vlc_mutex_lock( &avcodec_lock );
avcodec_close( p_sys->p_context ); avcodec_close( p_sys->p_context );
vlc_mutex_unlock( lock ); vlc_mutex_unlock( &avcodec_lock );
av_free( p_sys->p_context ); av_free( p_sys->p_context );
free( p_sys->p_buffer ); free( p_sys->p_buffer );
......
...@@ -383,23 +383,16 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -383,23 +383,16 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
} }
/* ***** Open the codec ***** */ /* ***** Open the codec ***** */
vlc_mutex_t *lock = var_AcquireMutex( "avcodec" ); vlc_mutex_lock( &avcodec_lock );
if( lock == NULL )
{
free( p_sys->p_buffer_orig );
free( p_sys );
return VLC_ENOMEM;
}
if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 ) 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 ); msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
free( p_sys->p_buffer_orig ); free( p_sys->p_buffer_orig );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
vlc_mutex_unlock( lock ); vlc_mutex_unlock( &avcodec_lock );
msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec ); msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
......
...@@ -72,7 +72,6 @@ typedef struct ...@@ -72,7 +72,6 @@ typedef struct
{ {
vlc_object_t *p_libvlc; vlc_object_t *p_libvlc;
vlc_mutex_t *p_lock;
int i_refcount; int i_refcount;
ass_library_t *p_library; ass_library_t *p_library;
ass_renderer_t *p_renderer; ass_renderer_t *p_renderer;
...@@ -120,6 +119,8 @@ static int BuildRegions( spu_t *p_spu, rectangle_t *p_region, int i_max_region, ...@@ -120,6 +119,8 @@ static int BuildRegions( spu_t *p_spu, rectangle_t *p_region, int i_max_region,
static void SubpictureReleaseRegions( spu_t *p_spu, subpicture_t *p_subpic ); 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 void RegionDraw( subpicture_region_t *p_region, ass_image_t *p_img );
static vlc_mutex_t libass_lock = VLC_STATIC_MUTEX;
//#define DEBUG_REGION //#define DEBUG_REGION
/***************************************************************************** /*****************************************************************************
...@@ -151,16 +152,16 @@ static int Create( vlc_object_t *p_this ) ...@@ -151,16 +152,16 @@ static int Create( vlc_object_t *p_this )
p_sys->i_refcount = 1; p_sys->i_refcount = 1;
/* Add a track */ /* 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 ); p_sys->p_track = p_track = ass_new_track( p_sys->p_ass->p_library );
if( !p_track ) if( !p_track )
{ {
vlc_mutex_unlock( p_sys->p_ass->p_lock ); vlc_mutex_unlock( &libass_lock );
DecSysRelease( p_sys ); DecSysRelease( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
ass_process_codec_private( p_track, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra ); 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; return VLC_SUCCESS;
} }
...@@ -194,10 +195,10 @@ static void DecSysRelease( decoder_sys_t *p_sys ) ...@@ -194,10 +195,10 @@ static void DecSysRelease( decoder_sys_t *p_sys )
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
vlc_mutex_destroy( &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 ) if( p_sys->p_track )
ass_free_track( 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 ); AssHandleRelease( p_sys->p_ass );
free( p_sys ); free( p_sys );
...@@ -264,13 +265,13 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -264,13 +265,13 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
p_spu->b_ephemer = true; p_spu->b_ephemer = true;
p_spu->b_absolute = 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 ) 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, 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 ); 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_pre_render = PreRender;
p_spu->pf_update_regions = UpdateRegions; p_spu->pf_update_regions = UpdateRegions;
...@@ -320,7 +321,7 @@ static void UpdateRegions( spu_t *p_spu, subpicture_t *p_subpic, ...@@ -320,7 +321,7 @@ static void UpdateRegions( spu_t *p_spu, subpicture_t *p_subpic,
return; return;
} }
vlc_mutex_lock( p_ass->p_lock ); vlc_mutex_lock( &libass_lock );
/* */ /* */
fmt = *p_fmt; fmt = *p_fmt;
...@@ -347,7 +348,7 @@ static void UpdateRegions( spu_t *p_spu, subpicture_t *p_subpic, ...@@ -347,7 +348,7 @@ static void UpdateRegions( spu_t *p_spu, subpicture_t *p_subpic,
if( !i_changed && !b_fmt_changed ) if( !i_changed && !b_fmt_changed )
{ {
vlc_mutex_unlock( p_ass->p_lock ); vlc_mutex_unlock( &libass_lock );
return; return;
} }
...@@ -368,7 +369,7 @@ static void UpdateRegions( spu_t *p_spu, subpicture_t *p_subpic, ...@@ -368,7 +369,7 @@ static void UpdateRegions( spu_t *p_spu, subpicture_t *p_subpic,
if( i_region <= 0 ) if( i_region <= 0 )
{ {
vlc_mutex_unlock( p_ass->p_lock ); vlc_mutex_unlock( &libass_lock );
return; return;
} }
...@@ -402,7 +403,7 @@ static void UpdateRegions( spu_t *p_spu, subpicture_t *p_subpic, ...@@ -402,7 +403,7 @@ static void UpdateRegions( spu_t *p_spu, subpicture_t *p_subpic,
*pp_region_last = r; *pp_region_last = r;
pp_region_last = &r->p_next; 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 rectangle_t r_create( int x0, int y0, int x1, int y1 )
...@@ -616,9 +617,7 @@ static void SubpictureReleaseRegions( spu_t *p_spu, subpicture_t *p_subpic ) ...@@ -616,9 +617,7 @@ static void SubpictureReleaseRegions( spu_t *p_spu, subpicture_t *p_subpic )
/* */ /* */
static ass_handle_t *AssHandleHold( decoder_t *p_dec ) static ass_handle_t *AssHandleHold( decoder_t *p_dec )
{ {
vlc_mutex_t *p_lock = var_AcquireMutex( "libass" ); vlc_mutex_lock( &libass_lock );
if( !p_lock )
return NULL;
ass_handle_t *p_ass = NULL; ass_handle_t *p_ass = NULL;
ass_library_t *p_library = NULL; ass_library_t *p_library = NULL;
...@@ -635,7 +634,7 @@ static ass_handle_t *AssHandleHold( decoder_t *p_dec ) ...@@ -635,7 +634,7 @@ static ass_handle_t *AssHandleHold( decoder_t *p_dec )
p_ass->i_refcount++; p_ass->i_refcount++;
vlc_mutex_unlock( p_lock ); vlc_mutex_unlock( &libass_lock );
return p_ass; return p_ass;
} }
...@@ -646,7 +645,6 @@ static ass_handle_t *AssHandleHold( decoder_t *p_dec ) ...@@ -646,7 +645,6 @@ static ass_handle_t *AssHandleHold( decoder_t *p_dec )
/* */ /* */
p_ass->p_libvlc = VLC_OBJECT(p_dec->p_libvlc); p_ass->p_libvlc = VLC_OBJECT(p_dec->p_libvlc);
p_ass->p_lock = p_lock;
p_ass->i_refcount = 1; p_ass->i_refcount = 1;
/* Create libass library */ /* Create libass library */
...@@ -713,7 +711,7 @@ static ass_handle_t *AssHandleHold( decoder_t *p_dec ) ...@@ -713,7 +711,7 @@ static ass_handle_t *AssHandleHold( decoder_t *p_dec )
var_Set( p_dec->p_libvlc, "libass-handle", val ); var_Set( p_dec->p_libvlc, "libass-handle", val );
/* */ /* */
vlc_mutex_unlock( p_ass->p_lock ); vlc_mutex_unlock( &libass_lock );
return p_ass; return p_ass;
error: error:
...@@ -723,16 +721,16 @@ error: ...@@ -723,16 +721,16 @@ error:
ass_library_done( p_library ); ass_library_done( p_library );
free( p_ass ); free( p_ass );
vlc_mutex_unlock( p_lock ); vlc_mutex_unlock( &libass_lock );
return NULL; return NULL;
} }
static void AssHandleRelease( ass_handle_t *p_ass ) static void AssHandleRelease( ass_handle_t *p_ass )
{ {
vlc_mutex_lock( p_ass->p_lock ); vlc_mutex_lock( &libass_lock );
p_ass->i_refcount--; p_ass->i_refcount--;
if( p_ass->i_refcount > 0 ) if( p_ass->i_refcount > 0 )
{ {
vlc_mutex_unlock( p_ass->p_lock ); vlc_mutex_unlock( &libass_lock );
return; return;
} }
...@@ -743,7 +741,7 @@ static void AssHandleRelease( ass_handle_t *p_ass ) ...@@ -743,7 +741,7 @@ static void AssHandleRelease( ass_handle_t *p_ass )
val.p_address = NULL; val.p_address = NULL;
var_Set( p_ass->p_libvlc, "libass-handle", val ); var_Set( p_ass->p_libvlc, "libass-handle", val );
vlc_mutex_unlock( p_ass->p_lock ); vlc_mutex_unlock( &libass_lock );
free( p_ass ); free( p_ass );
} }
...@@ -326,6 +326,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -326,6 +326,8 @@ static int Open( vlc_object_t *p_this )
} }
} }
static vlc_mutex_t qt_mutex = VLC_STATIC_MUTEX;
/***************************************************************************** /*****************************************************************************
* Close: * Close:
*****************************************************************************/ *****************************************************************************/
...@@ -333,10 +335,9 @@ static void Close( vlc_object_t *p_this ) ...@@ -333,10 +335,9 @@ static void Close( vlc_object_t *p_this )
{ {
decoder_t *p_dec = (decoder_t*)p_this; decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
vlc_mutex_t *lock;
/* get lock, avoid segfault */ /* get lock, avoid segfault */
lock = var_AcquireMutex( "qt_mutex" ); vlc_mutex_lock( &qt_mutex );
if( p_dec->fmt_out.i_cat == AUDIO_ES ) if( p_dec->fmt_out.i_cat == AUDIO_ES )
{ {
...@@ -375,7 +376,7 @@ static void Close( vlc_object_t *p_this ) ...@@ -375,7 +376,7 @@ static void Close( vlc_object_t *p_this )
#endif #endif
#endif #endif
vlc_mutex_unlock( lock ); vlc_mutex_unlock( &qt_mutex );
free( p_sys ); free( p_sys );
} }
...@@ -394,9 +395,7 @@ static int OpenAudio( decoder_t *p_dec ) ...@@ -394,9 +395,7 @@ static int OpenAudio( decoder_t *p_dec )
unsigned long OutputBufferSize = 0; unsigned long OutputBufferSize = 0;
/* get lock, avoid segfault */ /* get lock, avoid segfault */
vlc_mutex_t *lock = var_AcquireMutex( "qt_mutex" ); vlc_mutex_lock( &qt_mutex );
if( lock == NULL )
return VLC_EGENERIC;
p_sys = calloc( sizeof( decoder_sys_t ), 1 ); p_sys = calloc( sizeof( decoder_sys_t ), 1 );
p_dec->p_sys = p_sys; p_dec->p_sys = p_sys;
...@@ -515,7 +514,7 @@ static int OpenAudio( decoder_t *p_dec ) ...@@ -515,7 +514,7 @@ static int OpenAudio( decoder_t *p_dec )
p_sys->i_out = 0; p_sys->i_out = 0;
p_sys->i_out_frames = 0; p_sys->i_out_frames = 0;
vlc_mutex_unlock( lock ); vlc_mutex_unlock( &qt_mutex );
return VLC_SUCCESS; return VLC_SUCCESS;
exit_error: exit_error:
...@@ -523,7 +522,7 @@ exit_error: ...@@ -523,7 +522,7 @@ exit_error:
#ifdef LOADER #ifdef LOADER
Restore_LDT_Keeper( p_sys->ldt_fs ); Restore_LDT_Keeper( p_sys->ldt_fs );
#endif #endif
vlc_mutex_unlock( lock ); vlc_mutex_unlock( &qt_mutex );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -595,7 +594,7 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block ) ...@@ -595,7 +594,7 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
{ {
int i_frames = p_sys->i_buffer / p_sys->InFrameSize; int i_frames = p_sys->i_buffer / p_sys->InFrameSize;
unsigned long i_out_frames, i_out_bytes; 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, i_error = p_sys->SoundConverterConvertBuffer( p_sys->myConverter,
p_sys->p_buffer, p_sys->p_buffer,
...@@ -603,7 +602,7 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block ) ...@@ -603,7 +602,7 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
p_sys->out_buffer, p_sys->out_buffer,
&i_out_frames, &i_out_frames,
&i_out_bytes ); &i_out_bytes );
vlc_mutex_unlock( lock ); vlc_mutex_unlock( &qt_mutex );
/* /*
msg_Dbg( p_dec, "decoded %d frames -> %ld frames (error=%d)", msg_Dbg( p_dec, "decoded %d frames -> %ld frames (error=%d)",
...@@ -674,7 +673,6 @@ static int OpenVideo( decoder_t *p_dec ) ...@@ -674,7 +673,6 @@ static int OpenVideo( decoder_t *p_dec )
return VLC_ENOMEM; return VLC_ENOMEM;
#ifndef WIN32 #ifndef WIN32
vlc_mutex_t *lock;
long i_result; long i_result;
ComponentDescription desc; ComponentDescription desc;
Component prev; Component prev;
...@@ -703,7 +701,7 @@ static int OpenVideo( decoder_t *p_dec ) ...@@ -703,7 +701,7 @@ static int OpenVideo( decoder_t *p_dec )
fcc, p_dec->fmt_in.video.i_width, p_dec->fmt_in.video.i_height ); fcc, p_dec->fmt_in.video.i_width, p_dec->fmt_in.video.i_height );
/* get lock, avoid segfault */ /* get lock, avoid segfault */
lock = var_AcquireMutex( "qt_mutex" ); vlc_mutex_lock( &qt_mutex );
#ifdef __APPLE__ #ifdef __APPLE__
EnterMovies();