Commit 38c08789 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

aout_buffer_t: store length instead of end timestamp

aout_buffer_t now looks very much like a subset of block_t at the
source code level. By the way, we might want to revisit the return value
of date_Increment()...
parent e9eb5d5e
......@@ -134,7 +134,7 @@ struct aout_buffer_t
size_t i_size, i_nb_bytes;
unsigned int i_nb_samples;
uint32_t i_flags;
mtime_t i_pts, end_date;
mtime_t i_pts, i_length;
struct aout_buffer_t * p_next;
void *p_sys;
......
......@@ -220,9 +220,9 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
p_sys->i_old_wing;
p_out_buf->i_pts = date_Get( &p_sys->end_date );
p_out_buf->end_date =
p_out_buf->i_length =
date_Increment( &p_sys->end_date,
p_out_buf->i_nb_samples );
p_out_buf->i_nb_samples ) - p_out_buf->i_pts;
p_out_buf->i_nb_bytes = p_out_buf->i_nb_samples *
p_filter->input.i_bytes_per_frame;
......@@ -455,8 +455,8 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
/* Finalize aout buffer */
p_out_buf->i_nb_samples = i_out;
p_out_buf->i_pts = date_Get( &p_sys->end_date );
p_out_buf->end_date = date_Increment( &p_sys->end_date,
p_out_buf->i_nb_samples );
p_out_buf->i_length = date_Increment( &p_sys->end_date,
p_out_buf->i_nb_samples ) - p_out_buf->i_pts;
p_out_buf->i_nb_bytes = p_out_buf->i_nb_samples *
i_nb_channels * sizeof(int32_t);
......
......@@ -231,8 +231,8 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
date_Set( &p_sys->end_date, p_in_buf->i_pts );
}
p_out_buf->end_date = date_Increment( &p_sys->end_date,
p_out_buf->i_nb_samples );
p_out_buf->i_length = date_Increment( &p_sys->end_date,
p_out_buf->i_nb_samples ) - p_out_buf->i_pts;
p_out_buf->i_nb_bytes = p_out_buf->i_nb_samples *
i_nb_channels * sizeof(int32_t);
......
......@@ -113,6 +113,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
p_out_buf->i_nb_samples = i_out_nb;
p_out_buf->i_nb_bytes = i_out_nb * i_sample_bytes;
p_out_buf->i_pts = p_in_buf->i_pts;
p_out_buf->end_date = p_out_buf->i_pts + p_out_buf->i_nb_samples *
p_out_buf->i_length = p_out_buf->i_nb_samples *
1000000 / p_filter->output.i_rate;
}
......@@ -126,6 +126,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
p_out_buf->i_nb_samples = i_out_nb;
p_out_buf->i_nb_bytes = i_out_nb * i_sample_bytes;
p_out_buf->i_pts = p_in_buf->i_pts;
p_out_buf->end_date = p_out_buf->i_pts + p_out_buf->i_nb_samples *
p_out_buf->i_length = p_out_buf->i_nb_samples *
1000000 / p_filter->output.i_rate;
}
......@@ -663,7 +663,7 @@ static void* OSSThread( vlc_object_t *p_this )
i_size = p_buffer->i_nb_bytes;
/* This is theoretical ... we'll see next iteration whether
* we're drifting */
next_date += p_buffer->end_date - p_buffer->i_pts;
next_date += p_buffer->i_length;
}
else
{
......
......@@ -1062,8 +1062,7 @@ static void* WaveOutThread( vlc_object_t *p_this )
if( p_buffer )
{
mtime_t buffer_length = (p_buffer->end_date
- p_buffer->i_pts);
mtime_t buffer_length = p_buffer->i_length;
next_date = next_date + buffer_length;
i_buffer_length = buffer_length/1000;
}
......
......@@ -394,7 +394,8 @@ static aout_buffer_t *GetAoutBuffer( decoder_t *p_dec )
if( p_buf == NULL ) return NULL;
p_buf->i_pts = date_Get( &p_sys->end_date );
p_buf->end_date = date_Increment( &p_sys->end_date, p_sys->frame.i_samples );
p_buf->i_length = date_Increment( &p_sys->end_date,
p_sys->frame.i_samples ) - p_buf->i_pts;
return p_buf;
}
......
......@@ -301,8 +301,8 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
}
p_out->i_pts = date_Get( &p_sys->end_date );
p_out->end_date =
date_Increment( &p_sys->end_date, p_sys->i_samplesperblock );
p_out->i_length = date_Increment( &p_sys->end_date,
p_sys->i_samplesperblock ) - p_out->i_pts;
switch( p_sys->codec )
{
......
......@@ -135,7 +135,8 @@ static aout_buffer_t *Decode( decoder_t *p_dec, block_t **pp_block )
goto exit;
p_aout_buffer->i_pts = date_Get( &p_sys->end_date );
p_aout_buffer->end_date = date_Increment( &p_sys->end_date, i_frame_length );
p_aout_buffer->i_length = date_Increment( &p_sys->end_date,
i_frame_length ) - p_aout_buffer->i_pts;
p_block->i_buffer -= AES3_HEADER_LEN;
p_block->p_buffer += AES3_HEADER_LEN;
......
......@@ -371,7 +371,8 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
}
p_out->i_pts = date_Get( &p_sys->end_date );
p_out->end_date = date_Increment( &p_sys->end_date, i_samples );
p_out->i_length = date_Increment( &p_sys->end_date, i_samples )
- p_out->i_pts;
if( p_sys->p_logtos16 )
{
......
......@@ -243,7 +243,8 @@ static aout_buffer_t *SplitBuffer( decoder_t *p_dec )
return NULL;
p_buffer->i_pts = date_Get( &p_sys->end_date );
p_buffer->end_date = date_Increment( &p_sys->end_date, i_samples );
p_buffer->i_length = date_Increment( &p_sys->end_date, i_samples )
- p_buffer->i_pts;
if( p_sys->b_extract )
aout_ChannelExtract( p_buffer->p_buffer, p_dec->fmt_out.audio.i_channels,
......
......@@ -982,8 +982,9 @@ static void *DecBlock( decoder_t *p_dec, block_t **pp_block )
block_out.p_buffer, block_out.i_buffer );
/* Date management */
p_aout_buffer->i_pts = date_Get( &p_sys->end_date );
p_aout_buffer->end_date =
date_Increment( &p_sys->end_date, i_samples );
p_aout_buffer->i_length =
date_Increment( &p_sys->end_date, i_samples )
- p_aout_buffer->i_pts;
}
p_out->vt->Release( (IUnknown *)p_out );
......
......@@ -411,8 +411,8 @@ static aout_buffer_t *GetAoutBuffer( decoder_t *p_dec )
p_buf->i_nb_bytes = p_sys->i_frame_size;
p_buf->i_pts = date_Get( &p_sys->end_date );
p_buf->end_date =
date_Increment( &p_sys->end_date, p_sys->i_frame_length );
p_buf->i_length = date_Increment( &p_sys->end_date, p_sys->i_frame_length )
- p_buf->i_pts;
return p_buf;
}
......
......@@ -415,7 +415,9 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
}
p_out->i_pts = date_Get( &p_sys->date );
p_out->end_date = date_Increment( &p_sys->date, frame.samples / frame.channels );
p_out->i_length = date_Increment( &p_sys->date,
frame.samples / frame.channels ),
- p_out->i_pts;
DoReordering( (uint32_t *)p_out->p_buffer, samples,
frame.samples / frame.channels, frame.channels,
......
......@@ -663,8 +663,7 @@ DecoderWriteCallback( const FLAC__StreamDecoder *decoder,
/* Date management (already done by packetizer) */
p_sys->p_aout_buffer->i_pts = p_sys->p_block->i_pts;
p_sys->p_aout_buffer->end_date =
p_sys->p_block->i_pts + p_sys->p_block->i_length;
p_sys->p_aout_buffer->i_length = p_sys->p_block->i_length;
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
......
......@@ -198,7 +198,8 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block)
goto drop;
p_out->i_pts = date_Get (&p_sys->end_date );
p_out->end_date = date_Increment (&p_sys->end_date, samples);
p_out->i_length = date_Increment (&p_sys->end_date, samples)
- p_out->i_pts;
if (!p_sys->fixed)
fluid_synth_write_float (p_sys->synth, samples,
p_out->p_buffer, 0, 2,
......
......@@ -361,8 +361,9 @@ static void *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
return NULL;
p_aout_buffer->i_pts = date_Get( &p_sys->end_date );
p_aout_buffer->end_date =
date_Increment( &p_sys->end_date, i_frame_length );
p_aout_buffer->i_length =
date_Increment( &p_sys->end_date, i_frame_length )
- p_aout_buffer->i_pts;
p_block->p_buffer += p_sys->i_header_size + i_padding;
p_block->i_buffer -= p_sys->i_header_size + i_padding;
......
......@@ -539,8 +539,8 @@ static aout_buffer_t *GetAoutBuffer( decoder_t *p_dec )
if( p_buf == NULL ) return NULL;
p_buf->i_pts = date_Get( &p_sys->end_date );
p_buf->end_date =
date_Increment( &p_sys->end_date, p_sys->i_frame_length );
p_buf->i_length = date_Increment( &p_sys->end_date, p_sys->i_frame_length )
- p_buf->i_pts;
if( p_sys->b_discontinuity )
p_buf->i_flags |= BLOCK_FLAG_DISCONTINUITY;
p_sys->b_discontinuity = false;
......
......@@ -647,7 +647,8 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
if( p_out )
{
p_out->i_pts = date_Get( &p_sys->date );
p_out->end_date = date_Increment( &p_sys->date, i_frames );
p_out->i_length = date_Increment( &p_sys->date, i_frames )
- p_out->i_pts;
memcpy( p_out->p_buffer,
&p_sys->out_buffer[2 * p_sys->i_out * p_dec->fmt_out.audio.i_channels],
......
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