Commit b3b21577 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Make aout_buffer_t an alias for block_t

parent bfe09648
......@@ -125,25 +125,7 @@ typedef int32_t vlc_fixed_t;
* Main audio output structures
*****************************************************************************/
/** audio output buffer */
struct aout_buffer_t
{
uint8_t * p_buffer;
/* i_size is the real size of the buffer (used for debug ONLY), i_nb_bytes
* is the number of significative bytes in it. */
size_t i_size, i_buffer;
unsigned int i_nb_samples;
uint32_t i_flags;
mtime_t i_pts, i_length;
struct aout_buffer_t * p_next;
void *p_sys;
};
static inline void aout_BufferFree( aout_buffer_t *buffer )
{
free( buffer );
}
#define aout_BufferFree( buffer ) block_Release( buffer )
/* Size of a frame for S/PDIF output. */
#define AOUT_SPDIF_SIZE 6144
......@@ -171,6 +153,7 @@ struct aout_fifo_t
/* FIXME to remove once aout.h is cleaned a bit more */
#include <vlc_aout_mixer.h>
#include <vlc_block.h>
/* */
typedef struct
......
......@@ -206,7 +206,7 @@ typedef struct aout_instance_t aout_instance_t;
typedef struct aout_sys_t aout_sys_t;
typedef struct aout_fifo_t aout_fifo_t;
typedef struct aout_input_t aout_input_t;
typedef struct aout_buffer_t aout_buffer_t;
typedef struct block_t aout_buffer_t;
typedef audio_format_t audio_sample_format_t;
typedef struct audio_date_t audio_date_t;
typedef struct aout_filter_t aout_filter_t;
......
......@@ -201,16 +201,16 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
/* Check if we really need to run the resampler */
if( i_out_rate == p_filter->input.i_rate )
{
#if 0 /* FIXME: needs audio filter2 to use block_Realloc */
if( /*p_filter->b_continuity && /--* What difference does it make ? :) */
p_sys->i_old_wing &&
p_in_buf->i_size >=
p_in_buf->i_buffer + p_sys->i_old_wing *
p_filter->input.i_bytes_per_frame )
p_sys->i_old_wing )
{
/* output the whole thing with the samples from last time */
memmove( ((float *)(p_in_buf->p_buffer)) +
i_nb_channels * p_sys->i_old_wing,
p_in_buf->p_buffer, p_in_buf->i_buffer );
p_in_buf = block_Realloc( p_in_buf,
p_sys->i_old_wing * p_filter->input.i_bytes_per_frame,
p_in_buf->i_buffer );
if( !p_in_buf )
abort();
memcpy( p_in_buf->p_buffer, p_sys->p_buf +
i_nb_channels * p_sys->i_old_wing,
p_sys->i_old_wing *
......@@ -227,6 +227,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
p_out_buf->i_buffer = p_out_buf->i_nb_samples *
p_filter->input.i_bytes_per_frame;
}
#endif
p_filter->b_continuity = false;
p_sys->i_old_wing = 0;
return;
......@@ -269,7 +270,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
p_in_buf->i_nb_samples * p_filter->input.i_bytes_per_frame );
/* Make sure the output buffer is reset */
memset( p_out, 0, p_out_buf->i_size );
memset( p_out, 0, p_out_buf->i_buffer );
/* Calculate the new length of the filter wing */
d_factor = (double)i_out_rate / p_filter->input.i_rate;
......@@ -327,7 +328,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
#endif
/* Sanity check */
if( p_out_buf->i_size/p_filter->input.i_bytes_per_frame
if( p_out_buf->i_buffer/p_filter->input.i_bytes_per_frame
<= (unsigned int)i_out+1 )
{
p_out += i_nb_channels;
......@@ -402,7 +403,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
}
#endif
/* Sanity check */
if( p_out_buf->i_size/p_filter->input.i_bytes_per_frame
if( p_out_buf->i_buffer/p_filter->input.i_bytes_per_frame
<= (unsigned int)i_out+1 )
{
p_out += i_nb_channels;
......@@ -448,7 +449,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
}
#if 0
msg_Err( p_filter, "p_out size: %i, nb bytes out: %i", p_out_buf->i_size,
msg_Err( p_filter, "p_out size: %i, nb bytes out: %i", p_out_buf->i_buffer,
i_out * p_filter->input.i_bytes_per_frame );
#endif
......@@ -586,10 +587,10 @@ static block_t *Resample( filter_t *p_filter, block_t *p_block )
p_filter->p_sys->b_first = false;
in_buf.p_buffer = p_block->p_buffer;
in_buf.i_buffer = in_buf.i_size = p_block->i_buffer;
in_buf.i_buffer = p_block->i_buffer;
in_buf.i_nb_samples = p_block->i_nb_samples;
out_buf.p_buffer = p_out->p_buffer;
out_buf.i_buffer = out_buf.i_size = p_out->i_buffer;
out_buf.i_buffer = p_out->i_buffer;
out_buf.i_nb_samples = p_out->i_nb_samples;
DoWork( (aout_instance_t *)p_filter, &aout_filter, &in_buf, &out_buf );
......
......@@ -147,16 +147,18 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
/* Check if we really need to run the resampler */
if( p_aout->mixer_format.i_rate == p_filter->input.i_rate )
{
if( p_filter->b_continuity &&
p_in_buf->i_size >=
p_in_buf->i_buffer + sizeof(float) * i_nb_channels )
#if 0 /* FIXME: needs audio filter2 for block_Realloc */
if( p_filter->b_continuity )
{
/* output the whole thing with the last sample from last time */
memmove( ((float *)(p_in_buf->p_buffer)) + i_nb_channels,
p_in_buf->p_buffer, p_in_buf->i_buffer );
p_in_buf = block_Realloc( p_in_buf, sizeof(float) * i_nb_channels,
p_in_buf->i_buffer );
if( !p_in_buf )
abort();
memcpy( p_in_buf->p_buffer, p_prev_sample,
i_nb_channels * sizeof(float) );
}
#endif
p_filter->b_continuity = false;
return;
}
......
......@@ -501,7 +501,13 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
}
size_t i_outsize = calculate_output_buffer_size ( p_filter, p_in_buf->i_buffer );
if( i_outsize > p_out_buf->i_size ) {
if( i_outsize > p_out_buf->i_buffer ) {
#if 0 /* FIXME: This requires audio filter2 to work */
p_out_buf = block_Realloc( p_out_buf, i_outsize, 0 );
if( p_out_buf == NULL )
abort();
#else /* This fails horribly if we have more than two buffers in the
* pipeline, or if the buffer is passed to another thread... XXX */
void *temp = realloc( p->p_buffers[ p->i_buf ], i_outsize );
if( temp == NULL )
{
......@@ -510,6 +516,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
p->p_buffers[ p->i_buf ] = temp;
p_out_buf->p_buffer = p->p_buffers[ p->i_buf ];
p->i_buf = ! p->i_buf;
#endif
}
size_t bytes_out = transform_buffer( p_filter,
......
......@@ -1284,8 +1284,7 @@ static int transcode_audio_process( sout_stream_t *p_stream,
block_t *in, block_t **out )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
aout_buffer_t *p_audio_buf;
block_t *p_block, *p_audio_block;
block_t *p_block, *p_audio_buf;
*out = NULL;
while( (p_audio_buf = id->p_decoder->pf_decode_audio( id->p_decoder,
......@@ -1307,36 +1306,29 @@ static int transcode_audio_process( sout_stream_t *p_stream,
p_audio_buf->i_pts -= p_sys->i_master_drift;
}
p_audio_block = p_audio_buf->p_sys;
p_audio_block->i_buffer = p_audio_buf->i_buffer;
p_audio_block->i_dts = p_audio_block->i_pts =
p_audio_buf->i_pts;
p_audio_block->i_length = p_audio_buf->i_length;
p_audio_block->i_nb_samples = p_audio_buf->i_nb_samples;
p_audio_buf->i_dts = p_audio_buf->i_pts;
/* Run filter chain */
if( id->p_uf_chain )
{
p_audio_block = filter_chain_AudioFilter( id->p_uf_chain, p_audio_block );
assert( p_audio_block );
p_audio_buf = filter_chain_AudioFilter( id->p_uf_chain,
p_audio_buf );
if( !p_audio_buf )
abort();
}
p_audio_block = filter_chain_AudioFilter( id->p_f_chain, p_audio_block );
assert( p_audio_block );
p_audio_buf = filter_chain_AudioFilter( id->p_f_chain, p_audio_buf );
if( !p_audio_buf )
abort();
p_audio_buf->p_buffer = p_audio_block->p_buffer;
p_audio_buf->i_buffer = p_audio_block->i_buffer;
p_audio_buf->i_nb_samples = p_audio_block->i_nb_samples;
p_audio_buf->i_pts = p_audio_block->i_dts;
p_audio_buf->i_length = p_audio_block->i_length;
p_audio_buf->i_pts = p_audio_buf->i_dts;
audio_timer_start( id->p_encoder );
p_block = id->p_encoder->pf_encode_audio( id->p_encoder, p_audio_buf );
audio_timer_stop( id->p_encoder );
block_ChainAppend( out, p_block );
block_Release( p_audio_block );
free( p_audio_buf );
block_Release( p_audio_buf );
}
return VLC_SUCCESS;
......@@ -1344,7 +1336,6 @@ static int transcode_audio_process( sout_stream_t *p_stream,
static aout_buffer_t *audio_new_buffer( decoder_t *p_dec, int i_samples )
{
aout_buffer_t *p_buffer;
block_t *p_block;
int i_size;
......@@ -1364,24 +1355,15 @@ static aout_buffer_t *audio_new_buffer( decoder_t *p_dec, int i_samples )
i_size = i_samples * 4 * p_dec->fmt_out.audio.i_channels;
}
p_buffer = malloc( sizeof(aout_buffer_t) );
if( !p_buffer ) return NULL;
p_buffer->i_flags = 0;
p_buffer->p_sys = p_block = block_New( p_dec, i_size );
p_buffer->p_buffer = p_block->p_buffer;
p_buffer->i_size = p_buffer->i_buffer = p_block->i_buffer;
p_buffer->i_nb_samples = i_samples;
p_block = block_New( p_dec, i_size );
p_block->i_nb_samples = i_samples;
return p_buffer;
return p_block;
}
static void audio_del_buffer( decoder_t *p_dec, aout_buffer_t *p_buffer )
{
VLC_UNUSED(p_dec);
if( p_buffer && p_buffer->p_sys ) block_Release( p_buffer->p_sys );
free( p_buffer );
block_Release( p_buffer );
}
/*
......
......@@ -707,18 +707,8 @@ aout_buffer_t *aout_BufferAlloc(aout_alloc_t *allocation, mtime_t microseconds,
return old_buffer;
}
aout_buffer_t *buffer;
int i_alloc_size;
i_alloc_size = (int)( (uint64_t)allocation->i_bytes_per_sec
size_t i_alloc_size = (int)( (uint64_t)allocation->i_bytes_per_sec
* (microseconds) / 1000000 + 1 );
buffer = malloc( i_alloc_size + sizeof(aout_buffer_t) );
if ( !buffer )
return NULL;
buffer->i_size = i_alloc_size;
buffer->p_buffer = (uint8_t *)buffer + sizeof(aout_buffer_t);
buffer->i_flags = 0;
return buffer;
return block_Alloc( i_alloc_size );
}
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