]> git.sesse.net Git - vlc/blobdiff - modules/codec/ffmpeg/audio.c
* modules/codec/ffmpeg/ffmpeg.c: proper fix for disabling aac decoding while keeping...
[vlc] / modules / codec / ffmpeg / audio.c
index 8ac82b6eff623e285a37beedaa2396c80ed77d57..c3c93813b89db4038410b58439a8f8044e7dde70 100644 (file)
@@ -2,7 +2,7 @@
  * 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
@@ -86,6 +79,9 @@ int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context,
                       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 =
@@ -117,15 +113,16 @@ int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context,
     }
 
     /* ***** 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 );
 
@@ -160,7 +157,7 @@ aout_buffer_t *E_( DecodeAudio )( decoder_t *p_dec, block_t **pp_block )
         return NULL;
     }
 
-    if( p_block->i_buffer <= 0 )
+    if( p_block->i_buffer <= 0 || p_block->b_discontinuity )
     {
         block_Release( p_block );
         return NULL;