Added decoder_NewAudioBuffer/decoder_DeleteAudioBuffer helpers.
authorLaurent Aimar <fenrir@videolan.org>
Thu, 23 Oct 2008 19:31:23 +0000 (21:31 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Thu, 23 Oct 2008 19:31:23 +0000 (21:31 +0200)
19 files changed:
include/vlc_codec.h
modules/codec/a52.c
modules/codec/adpcm.c
modules/codec/aes3.c
modules/codec/araw.c
modules/codec/avcodec/audio.c
modules/codec/dmo/dmo.c
modules/codec/dts.c
modules/codec/faad.c
modules/codec/flac.c
modules/codec/fluidsynth.c
modules/codec/lpcm.c
modules/codec/mpeg_audio.c
modules/codec/quicktime.c
modules/codec/realaudio.c
modules/codec/speex.c
modules/codec/vorbis.c
src/input/decoder.c
src/libvlccore.sym

index 41cf66b..80ca599 100644 (file)
@@ -85,10 +85,6 @@ struct decoder_t
      * Buffers allocation
      */
 
-    /* Audio output callbacks */
-    aout_buffer_t * ( * pf_aout_buffer_new) ( decoder_t *, int );
-    void            ( * pf_aout_buffer_del) ( decoder_t *, aout_buffer_t * );
-
     /* Video output callbacks */
     picture_t     * ( * pf_vout_buffer_new) ( decoder_t * );
     void            ( * pf_vout_buffer_del) ( decoder_t *, picture_t * );
@@ -99,6 +95,11 @@ struct decoder_t
      * Owner fields
      */
 
+    /* Audio output callbacks
+     * XXX use decoder_NewAudioBuffer/decoder_DeleteAudioBuffer */
+    aout_buffer_t * ( * pf_aout_buffer_new) ( decoder_t *, int );
+    void            ( * pf_aout_buffer_del) ( decoder_t *, aout_buffer_t * );
+
     /* SPU output callbacks
      * XXX use decoder_NewSubpicture and decoder_DeleteSubpicture */
     subpicture_t   *(*pf_spu_buffer_new) ( decoder_t * );
@@ -164,6 +165,19 @@ struct encoder_t
  * @}
  */
 
+
+/**
+ * This function will return a new audio buffer usable by a decoder as an
+ * output buffer. You have to release it using decoder_DeleteAudioBuffer
+ * or by returning it to the caller as a pf_decode_audio return value.
+ */
+VLC_EXPORT( aout_buffer_t *, decoder_NewAudioBuffer, ( decoder_t *, int i_size ) );
+
+/**
+ * This function will release a audio buffer created by decoder_NewAudioBuffer.
+ */
+VLC_EXPORT( void, decoder_DeleteAudioBuffer, ( decoder_t *, aout_buffer_t *p_buffer ) );
+
 /**
  * This function will return a new subpicture usable by a decoder as an output
  * buffer. You have to release it using decoder_DeleteSubpicture or by returning
@@ -172,7 +186,7 @@ struct encoder_t
 VLC_EXPORT( subpicture_t *, decoder_NewSubpicture, ( decoder_t * ) );
 
 /**
- * This function will release a subpicture create by decoder_NewSubicture.
+ * This function will release a subpicture created by decoder_NewSubicture.
  */
 VLC_EXPORT( void, decoder_DeleteSubpicture, ( decoder_t *, subpicture_t *p_subpicture ) );
 
index f6521d5..edba4f1 100644 (file)
@@ -397,7 +397,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, A52_FRAME_NB  );
+    p_buf = decoder_NewAudioBuffer( p_dec, A52_FRAME_NB  );
     if( p_buf == NULL ) return NULL;
 
     p_buf->start_date = aout_DateGet( &p_sys->end_date );
index c9a9ec2..c647f80 100644 (file)
@@ -292,7 +292,7 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     {
         aout_buffer_t *p_out;
 
-        p_out = p_dec->pf_aout_buffer_new( p_dec, p_sys->i_samplesperblock );
+        p_out = decoder_NewAudioBuffer( p_dec, p_sys->i_samplesperblock );
         if( p_out == NULL )
         {
             block_Release( p_block );
index 48ae475..226a3c6 100644 (file)
@@ -130,7 +130,7 @@ static aout_buffer_t *Decode( decoder_t *p_dec, block_t **pp_block )
     if( !p_block )
         return NULL;
 
-    p_aout_buffer = p_dec->pf_aout_buffer_new( p_dec, i_frame_length );
+    p_aout_buffer = decoder_NewAudioBuffer( p_dec, i_frame_length );
     if( p_aout_buffer == NULL )
         goto exit;
 
index 36d826b..93cb691 100644 (file)
@@ -455,7 +455,7 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     /* Create chunks of max 1024 samples */
     i_samples = __MIN( i_samples, 1024 );
 
-    p_out = p_dec->pf_aout_buffer_new( p_dec, i_samples );
+    p_out = decoder_NewAudioBuffer( p_dec, i_samples );
     if( p_out == NULL )
     {
         block_Release( p_block );
index 92c6208..bff0f99 100644 (file)
@@ -223,11 +223,8 @@ static aout_buffer_t *SplitBuffer( decoder_t *p_dec )
 
     if( i_samples == 0 ) return NULL;
 
-    if( ( p_buffer = p_dec->pf_aout_buffer_new( p_dec, i_samples ) ) == NULL )
-    {
-        msg_Err( p_dec, "cannot get aout buffer" );
+    if( ( p_buffer = decoder_NewAudioBuffer( p_dec, i_samples ) ) == NULL )
         return NULL;
-    }
 
     p_buffer->start_date = aout_DateGet( &p_sys->end_date );
     p_buffer->end_date = aout_DateIncrement( &p_sys->end_date, i_samples );
index 91d88d6..5d5ed27 100644 (file)
@@ -928,15 +928,16 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             ( p_dec->fmt_out.audio.i_bitspersample *
               p_dec->fmt_out.audio.i_channels / 8 );
 
-        p_aout_buffer = p_dec->pf_aout_buffer_new( p_dec, i_samples );
-        memcpy( p_aout_buffer->p_buffer,
-                block_out.p_buffer, block_out.i_buffer );
-
-        /* Date management */
-        p_aout_buffer->start_date = date_Get( &p_sys->end_date );
-        p_aout_buffer->end_date =
-            date_Increment( &p_sys->end_date, i_samples );
-
+        p_aout_buffer = decoder_NewAudioBuffer( p_dec, i_samples );
+        if( p_aout_buffer )
+        {
+            memcpy( p_aout_buffer->p_buffer,
+                    block_out.p_buffer, block_out.i_buffer );
+            /* Date management */
+            p_aout_buffer->start_date = date_Get( &p_sys->end_date );
+            p_aout_buffer->end_date =
+                date_Increment( &p_sys->end_date, i_samples );
+        }
         p_out->vt->Release( (IUnknown *)p_out );
 
         return p_aout_buffer;
index 7787cf4..f9ed084 100644 (file)
@@ -385,7 +385,7 @@ static aout_buffer_t *GetAoutBuffer( decoder_t *p_dec )
 
     /* Hack for DTS S/PDIF filter which needs to send 3 frames at a time
      * (plus a few header bytes) */
-    p_buf = p_dec->pf_aout_buffer_new( p_dec, p_sys->i_frame_length * 4 );
+    p_buf = decoder_NewAudioBuffer( p_dec, p_sys->i_frame_length * 4 );
     if( p_buf == NULL ) return NULL;
     p_buf->i_nb_samples = p_sys->i_frame_length;
     p_buf->i_nb_bytes = p_sys->i_frame_size;
index 93118cd..901ad31 100644 (file)
@@ -415,7 +415,7 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         p_dec->fmt_out.audio.i_original_channels =
             p_dec->fmt_out.audio.i_physical_channels;
 
-        p_out = p_dec->pf_aout_buffer_new(p_dec, frame.samples/frame.channels);
+        p_out = decoder_NewAudioBuffer(p_dec, frame.samples/frame.channels);
         if( p_out == NULL )
         {
             p_sys->i_buffer = 0;
index 0180ade..0971a50 100644 (file)
@@ -621,7 +621,7 @@ DecoderWriteCallback( const FLAC__StreamDecoder *decoder,
     decoder_sys_t *p_sys = p_dec->p_sys;
 
     p_sys->p_aout_buffer =
-        p_dec->pf_aout_buffer_new( p_dec, frame->header.blocksize );
+        decoder_NewAudioBuffer( p_dec, frame->header.blocksize );
 
     if( p_sys->p_aout_buffer == NULL )
         return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
index 600353f..2bb5ee7 100644 (file)
@@ -177,7 +177,7 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block)
     if (samples == 0)
         return NULL;
 
-    aout_buffer_t *p_out = p_dec->pf_aout_buffer_new (p_dec, samples);
+    aout_buffer_t *p_out = decoder_NewAudioBuffer (p_dec, samples);
     if (p_out == NULL)
     {
         block_Release (p_block);
index 6827db4..1d98488 100644 (file)
@@ -311,7 +311,7 @@ static void *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
     else
     {
         aout_buffer_t *p_aout_buffer;
-        p_aout_buffer = p_dec->pf_aout_buffer_new( p_dec, i_frame_length );
+        p_aout_buffer = decoder_NewAudioBuffer( p_dec, i_frame_length );
         if( p_aout_buffer == NULL ) return NULL;
 
         p_aout_buffer->start_date = aout_DateGet( &p_sys->end_date );
index 8a60f16..6e7d869 100644 (file)
@@ -533,7 +533,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 );
index bcf4dd2..78531f4 100644 (file)
@@ -649,7 +649,7 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
         aout_buffer_t *p_out;
         int  i_frames = __MIN( p_sys->i_out_frames - p_sys->i_out, 1000 );
 
-        p_out = p_dec->pf_aout_buffer_new( p_dec, i_frames );
+        p_out = decoder_NewAudioBuffer( p_dec, i_frames );
 
         if( p_out )
         {
index 6930827..caa7686 100644 (file)
@@ -706,7 +706,7 @@ static aout_buffer_t *Decode( decoder_t *p_dec, block_t **pp_block )
         p_dec->fmt_out.audio.i_bitspersample /p_dec->fmt_out.audio.i_channels;
 
     p_aout_buffer =
-        p_dec->pf_aout_buffer_new( p_dec, i_samples );
+        decoder_NewAudioBuffer( p_dec, i_samples );
     if( p_aout_buffer )
     {
         memcpy( p_aout_buffer->p_buffer, p_sys->p_out, p_sys->i_out );
index 05e64a5..bd4305b 100644 (file)
@@ -684,7 +684,7 @@ static aout_buffer_t *DecodeRtpSpeexPacket( decoder_t *p_dec, block_t **pp_block
       Ask for a new audio output buffer and make sure
       we get one. 
     */
-    p_aout_buffer = p_dec->pf_aout_buffer_new( p_dec, 
+    p_aout_buffer = decoder_NewAudioBuffer( p_dec, 
         p_sys->p_header->frame_size );
     if ( !p_aout_buffer || p_aout_buffer->i_nb_bytes == 0 )
     {
@@ -748,7 +748,7 @@ static aout_buffer_t *DecodePacket( decoder_t *p_dec, ogg_packet *p_oggpacket )
             return NULL;
 
         p_aout_buffer =
-            p_dec->pf_aout_buffer_new( p_dec, p_sys->p_header->frame_size );
+            decoder_NewAudioBuffer( p_dec, p_sys->p_header->frame_size );
         if( !p_aout_buffer )
         {
             return NULL;
index f7dd711..7217643 100644 (file)
@@ -549,7 +549,7 @@ static aout_buffer_t *DecodePacket( decoder_t *p_dec, ogg_packet *p_oggpacket )
         aout_buffer_t *p_aout_buffer;
 
         p_aout_buffer =
-            p_dec->pf_aout_buffer_new( p_dec, i_samples );
+            decoder_NewAudioBuffer( p_dec, i_samples );
 
         if( p_aout_buffer == NULL ) return NULL;
 
index 2fc0d31..5b5fbbe 100644 (file)
@@ -161,6 +161,19 @@ struct decoder_owner_sys_t
 /*****************************************************************************
  * Public functions
  *****************************************************************************/
+aout_buffer_t *decoder_NewAudioBuffer( decoder_t *p_decoder, int i_size )
+{
+    if( !p_decoder->pf_aout_buffer_new )
+        return NULL;
+    return p_decoder->pf_aout_buffer_new( p_decoder, i_size );
+}
+void decoder_DeleteAudioBuffer( decoder_t *p_decoder, aout_buffer_t *p_buffer )
+{
+    if( !p_decoder->pf_aout_buffer_del )
+        return;
+    p_decoder->pf_aout_buffer_del( p_decoder, p_buffer );
+}
+
 subpicture_t *decoder_NewSubpicture( decoder_t *p_decoder )
 {
     subpicture_t *p_subpicture = p_decoder->pf_spu_buffer_new( p_decoder );
index bf4f18e..8eac704 100644 (file)
@@ -77,10 +77,12 @@ date_Increment
 date_Init
 date_Move
 date_Set
+decoder_DeleteAudioBuffer
 decoder_DeleteSubpicture
 decoder_GetDisplayDate
 decoder_GetDisplayRate
 decoder_GetInputAttachments
+decoder_NewAudioBuffer
 decoder_NewSubpicture
 decoder_SynchroChoose
 decoder_SynchroDate