Commit 17485fb4 authored by Laurent Aimar's avatar Laurent Aimar

Added decoder_NewAudioBuffer/decoder_DeleteAudioBuffer helpers.

parent 7765d6b8
......@@ -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 ) );
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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 );
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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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 )
{
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment