]> git.sesse.net Git - vlc/blobdiff - modules/codec/ffmpeg/audio.c
Disable --vbi-text by default.
[vlc] / modules / codec / ffmpeg / audio.c
index 4479b4eee1543d73a962fef88b1bcdc3702c1f60..37e72c73a2873b281980605e94a7b464fd032c52 100644 (file)
@@ -89,17 +89,17 @@ int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context,
                       AVCodec *p_codec, int i_codec_id, const char *psz_namecodec )
 {
     decoder_sys_t *p_sys;
-    vlc_value_t lockval;
+    vlc_mutex_t *lock = var_GetGlobalMutex( "avcodec" );
 
-    var_Create( p_dec->p_libvlc_global, "avcodec", VLC_VAR_MUTEX );
-    var_Get( p_dec->p_libvlc_global, "avcodec", &lockval );
+    if( lock == NULL )
+        return VLC_EGENERIC;
 
     /* Allocate the memory needed to store the decoder's structure */
     if( ( p_dec->p_sys = p_sys =
           (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
     {
         msg_Err( p_dec, "out of memory" );
-        return VLC_EGENERIC;
+        return VLC_ENOMEM;
     }
 
     p_sys->p_context = p_context;
@@ -134,15 +134,15 @@ int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context,
     }
 
     /* ***** Open the codec ***** */
-    vlc_mutex_lock( lockval.p_address );
+    vlc_mutex_lock( lock );
     if (avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0)
     {
-        vlc_mutex_unlock( lockval.p_address );
+        vlc_mutex_unlock( lock );
         msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
         free( p_sys );
         return VLC_EGENERIC;
     }
-    vlc_mutex_unlock( lockval.p_address );
+    vlc_mutex_unlock( lock );
 
     msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
 
@@ -253,10 +253,16 @@ aout_buffer_t *E_( DecodeAudio )( decoder_t *p_dec, block_t **pp_block )
     p_block->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE;
     memset( &p_block->p_buffer[p_block->i_buffer], 0, FF_INPUT_BUFFER_PADDING_SIZE );
 
+#if LIBAVCODEC_VERSION_INT >= ((52<<16)+(0<<8)+0)
     i_output = __MAX( AVCODEC_MAX_AUDIO_FRAME_SIZE, p_block->i_buffer );
     i_used = avcodec_decode_audio2( p_sys->p_context,
                                    (int16_t*)p_sys->p_output, &i_output,
                                    p_block->p_buffer, p_block->i_buffer );
+#else
+    i_used = avcodec_decode_audio( p_sys->p_context,
+                                   (int16_t*)p_sys->p_output, &i_output,
+                                   p_block->p_buffer, p_block->i_buffer );
+#endif
 
     if( i_used < 0 || i_output < 0 )
     {