]> git.sesse.net Git - vlc/blobdiff - modules/codec/mpeg_audio.c
XCB: Factor picture allocation
[vlc] / modules / codec / mpeg_audio.c
index 8a60f164b319ff4aa8bbd2554cb2af1ccc781202..306bf0737b9ac343dbe1c2ecb1ff40ab26579e5a 100644 (file)
@@ -109,27 +109,27 @@ static int SyncInfo( uint32_t i_header, unsigned int * pi_channels,
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_description( N_("MPEG audio layer I/II/III decoder") );
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_ACODEC );
+vlc_module_begin ()
+    set_description( N_("MPEG audio layer I/II/III decoder") )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_ACODEC )
 #if defined(UNDER_CE)
-   set_capability( "decoder", 5 );
+   set_capability( "decoder", 5 )
 #else
-    set_capability( "decoder", 100 );
+    set_capability( "decoder", 100 )
 #endif
-    set_callbacks( OpenDecoder, CloseDecoder );
+    set_callbacks( OpenDecoder, CloseDecoder )
 
-    add_submodule();
-    set_description( N_("MPEG audio layer I/II/III packetizer") );
-    set_capability( "packetizer", 10 );
-    set_callbacks( OpenPacketizer, CloseDecoder );
-vlc_module_end();
+    add_submodule ()
+    set_description( N_("MPEG audio layer I/II/III packetizer") )
+    set_capability( "packetizer", 10 )
+    set_callbacks( OpenPacketizer, CloseDecoder )
+vlc_module_end ()
 
 /*****************************************************************************
- * OpenDecoder: probe the decoder and return score
+ * Open: probe the decoder and return score
  *****************************************************************************/
-static int OpenDecoder( vlc_object_t *p_this )
+static int Open( vlc_object_t *p_this )
 {
     decoder_t *p_dec = (decoder_t*)p_this;
     decoder_sys_t *p_sys;
@@ -139,13 +139,6 @@ static int OpenDecoder( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    /* HACK: Don't use this codec if we don't have an mpga audio filter */
-    if( p_dec->i_object_type == VLC_OBJECT_DECODER &&
-        !module_exists( "mpgatofixed32" ) )
-    {
-        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 )
@@ -175,11 +168,20 @@ static int OpenDecoder( vlc_object_t *p_this )
     return VLC_SUCCESS;
 }
 
+static int OpenDecoder( vlc_object_t *p_this )
+{
+    /* HACK: Don't use this codec if we don't have an mpga audio filter */
+    if( !module_exists( "mpgatofixed32" ) )
+        return VLC_EGENERIC;
+
+    return Open( p_this );
+}
+
 static int OpenPacketizer( vlc_object_t *p_this )
 {
     decoder_t *p_dec = (decoder_t*)p_this;
 
-    int i_ret = OpenDecoder( p_this );
+    int i_ret = Open( p_this );
 
     if( i_ret == VLC_SUCCESS ) p_dec->p_sys->b_packetizer = true;
 
@@ -206,9 +208,9 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
         {
             p_sys->i_state = STATE_NOSYNC;
-            block_BytestreamFlush( &p_sys->bytestream );
+            block_BytestreamEmpty( &p_sys->bytestream );
         }
-//        aout_DateSet( &p_sys->end_date, 0 );
+        aout_DateSet( &p_sys->end_date, 0 );
         block_Release( *pp_block );
         p_sys->b_discontinuity = true;
         return NULL;
@@ -533,7 +535,7 @@ static aout_buffer_t *GetAoutBuffer( decoder_t *p_dec )
     decoder_sys_t *p_sys = p_dec->p_sys;
     aout_buffer_t *p_buf;
 
-    p_buf = p_dec->pf_aout_buffer_new( p_dec, p_sys->i_frame_length );
+    p_buf = decoder_NewAudioBuffer( p_dec, p_sys->i_frame_length );
     if( p_buf == NULL ) return NULL;
 
     p_buf->start_date = aout_DateGet( &p_sys->end_date );