* audio.c: audio decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2003 VideoLAN
- * $Id: audio.c,v 1.24 2003/11/19 13:10:48 gbazin Exp $
+ * $Id: audio.c,v 1.27 2003/11/27 12:32:03 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <stdlib.h> /* malloc(), free() */
-#include <string.h>
-
#include <vlc/vlc.h>
#include <vlc/decoder.h>
-#include <vlc/input.h>
-
-#include "codecs.h"
-#include "aout_internal.h"
/* ffmpeg header */
#ifdef HAVE_FFMPEG_AVCODEC_H
AVCodec *p_codec, int i_codec_id, char *psz_namecodec )
{
decoder_sys_t *p_sys;
+ vlc_value_t lockval;
+
+ var_Get( p_dec->p_libvlc, "avcodec", &lockval );
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
}
/* ***** Open the codec ***** */
+ vlc_mutex_lock( lockval.p_address );
if (avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0)
{
+ vlc_mutex_unlock( lockval.p_address );
msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
return VLC_EGENERIC;
}
- else
- {
- msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
- }
+ vlc_mutex_unlock( lockval.p_address );
+
+ msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
p_sys->p_output = malloc( 3 * AVCODEC_MAX_AUDIO_FRAME_SIZE );
return NULL;
}
- if( p_block->i_buffer <= 0 )
+ if( p_block->i_buffer <= 0 || p_block->b_discontinuity )
{
block_Release( p_block );
return NULL;