#include <vlc_common.h>
#include <vlc_aout.h>
#include <vlc_codec.h>
+#include <vlc_avcodec.h>
/* ffmpeg header */
#ifdef HAVE_LIBAVCODEC_AVCODEC_H
}
/* ***** Open the codec ***** */
- vlc_mutex_lock( &avcodec_lock );
-
- if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 )
+ int ret;
+ vlc_avcodec_lock();
+ ret = avcodec_open( p_sys->p_context, p_sys->p_codec );
+ vlc_avcodec_unlock();
+ if( ret < 0 )
{
- 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( &avcodec_lock );
msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
+#include <vlc_avcodec.h>
/* ffmpeg header */
#define HAVE_MMX 1
vlc_module_end ()
-vlc_mutex_t avcodec_lock = VLC_STATIC_MUTEX;
-
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
*****************************************************************************/
if( !p_sys->b_delayed_open )
{
- vlc_mutex_lock( &avcodec_lock );
+ vlc_avcodec_lock();
avcodec_close( p_sys->p_context );
- vlc_mutex_unlock( &avcodec_lock );
+ vlc_avcodec_unlock();
}
msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->psz_namecodec );
av_free( p_sys->p_context );
{
static bool b_ffmpeginit = false;
- vlc_mutex_lock( &avcodec_lock );
+ vlc_avcodec_lock();
/* *** init ffmpeg library (libavcodec) *** */
if( !b_ffmpeginit )
msg_Dbg( p_object, "libavcodec already initialized" );
}
- vlc_mutex_unlock( &avcodec_lock );
+ vlc_avcodec_unlock();
}
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
*****************************************************************************/
#include <vlc_sout.h>
#include <vlc_codec.h>
#include <vlc_dialog.h>
+#include <vlc_avcodec.h>
/* ffmpeg header */
#define HAVE_MMX 1
p_context->extradata = NULL;
p_context->flags |= CODEC_FLAG_GLOBAL_HEADER;
- vlc_mutex_lock( &avcodec_lock );
-
- if( avcodec_open( p_context, p_codec ) )
+ int ret;
+ vlc_avcodec_lock();
+ ret = avcodec_open( p_context, p_codec );
+ vlc_avcodec_unlock();
+ if( ret )
{
- 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( &avcodec_lock );
- if( avcodec_open( p_context, p_codec ) )
+ vlc_avcodec_lock();
+ ret = avcodec_open( p_context, p_codec );
+ vlc_avcodec_unlock();
+ if( ret )
{
- vlc_mutex_unlock( &avcodec_lock );
msg_Err( p_enc, "cannot open encoder" );
dialog_Fatal( p_enc,
_("Streaming / Transcoding failed"),
return VLC_EGENERIC;
}
}
- 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_lock( &avcodec_lock );
+ vlc_avcodec_lock();
avcodec_close( p_sys->p_context );
- vlc_mutex_unlock( &avcodec_lock );
+ vlc_avcodec_unlock();
av_free( p_sys->p_context );
free( p_sys->p_buffer );
#include <vlc_codec.h>
#include <vlc_vout.h>
#include <vlc_codecs.h> /* BITMAPINFOHEADER */
+#include <vlc_avcodec.h>
/* ffmpeg header */
#ifdef HAVE_LIBAVCODEC_AVCODEC_H
p_sys->p_context->bits_per_coded_sample = p_dec->fmt_in.video.i_bits_per_pixel;
#endif
- vlc_mutex_lock( &avcodec_lock );
- if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 )
- {
- vlc_mutex_unlock( &avcodec_lock );
+ int ret;
+ vlc_avcodec_lock();
+ ret = avcodec_open( p_sys->p_context, p_sys->p_codec );
+ vlc_avcodec_unlock();
+ if( ret < 0 )
return VLC_EGENERIC;
- }
- vlc_mutex_unlock( &avcodec_lock );
msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
p_sys->b_delayed_open = false;
#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_vout.h>
+#include <vlc_avcodec.h>
#include <vlc_block.h>
id->ff_enc_c->channels = p_fmt->audio.i_channels;
id->ff_enc_c->bit_rate = p_fmt->i_bitrate;
+ vlc_avcodec_lock();
if( avcodec_open( id->ff_enc_c, id->ff_enc ) )
{
+ avcodec_unlock();
msg_Err( p_stream, "cannot open encoder" );
av_free( id->ff_enc_c );
free( id );
return NULL;
}
+ avcodec_unlock();
id->p_buffer_out = malloc( AVCODEC_MAX_AUDIO_FRAME_SIZE * 2 );
id->p_samples = calloc( id->ff_enc_c->frame_size * p_fmt->audio.i_channels,
return id;
error:
+ vlc_avcodec_lock();
avcodec_close( id->ff_enc_c );
+ vlc_avcodec_unlock();
free( id->p_samples );
free( id->p_buffer_out );
av_free( id->ff_enc_c );
if ( id->ff_enc )
{
+ vlc_avcodec_lock();
avcodec_close( id->ff_enc_c );
+ vlc_avcodec_unlock();
av_free( id->ff_enc_c );
av_free( id->p_frame );
free( id->p_buffer_out );
if ( id->ff_enc )
{
+ vlc_avcodec_lock();
avcodec_close( id->ff_enc_c );
+ vlc_avcodec_unlock();
av_free( id->ff_enc_c );
av_free( id->p_frame );
free( id->p_buffer_out );
id->ff_enc_c->mb_decision = FF_MB_DECISION_SIMPLE;
id->ff_enc_c->pix_fmt = PIX_FMT_YUV420P;
+ avcodec_lock();
if( avcodec_open( id->ff_enc_c, id->ff_enc ) )
{
+ avcodec_unlock();
msg_Err( p_stream, "cannot open encoder" );
return 0;
}
+ avcodec_unlock();
id->p_buffer_out = malloc( id->ff_enc_c->width * id->ff_enc_c->height * 3 );
id->p_frame = avcodec_alloc_frame();