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

aout: do not check for PTS discontinuity in packetizer

Continuity of the two FIFOs is maintained, as is consistency with the
input date. PTS discontinuity only seems to occur due to rounding
errors in the filters. It should be better not to drop samples, but
simply fix the buffer PTS and length.

Ideally, resamplers would use date_Increment() so they do not introduce
rounding errors. But first the block disconuity flag should be checked
for correctness during filtering, so that resamplers can reset the date
in case of hole.
parent d219a21c
...@@ -485,76 +485,22 @@ static block_t *aout_OutputSlice (audio_output_t *p_aout) ...@@ -485,76 +485,22 @@ static block_t *aout_OutputSlice (audio_output_t *p_aout)
/* Compute the end date for the new buffer. */ /* Compute the end date for the new buffer. */
mtime_t end_date = date_Increment( &exact_start_date, samples ); mtime_t end_date = date_Increment( &exact_start_date, samples );
/* Check that start_date is available. */ /* Check that we have enough samples (TODO merge with next loop). */
mtime_t prev_date; for( unsigned available = 0; available < samples; )
for( ;; )
{
/* Check for the continuity of start_date */
prev_date = p_buffer->i_pts + p_buffer->i_length;
if( prev_date >= start_date - 1 )
break;
/* We authorize a +-1 because rounding errors get compensated
* regularly. */
msg_Warn( p_aout, "got a packet in the past (%"PRId64")",
start_date - prev_date );
aout_BufferFree( aout_FifoPop( p_fifo ) );
p_buffer = p_fifo->p_first;
if( p_buffer == NULL )
return NULL;
}
/* Check that we have enough samples. */
while( prev_date < end_date )
{ {
p_buffer = p_buffer->p_next; p_buffer = p_buffer->p_next;
if( p_buffer == NULL ) if( p_buffer == NULL )
return NULL; return NULL;
/* Check that all buffers are contiguous. */ available += p_buffer->i_nb_samples;
if( prev_date != p_buffer->i_pts )
{
msg_Warn( p_aout,
"buffer hole, dropping packets (%"PRId64")",
p_buffer->i_pts - prev_date );
aout_buffer_t *p_deleted;
while( (p_deleted = p_fifo->p_first) != p_buffer )
aout_BufferFree( aout_FifoPop( p_fifo ) );
}
prev_date = p_buffer->i_pts + p_buffer->i_length;
} }
if( AOUT_FMT_LINEAR( &p_aout->format ) ) if( AOUT_FMT_LINEAR( &p_aout->format ) )
{ {
p_buffer = p_fifo->p_first;
/* Additionally check that p_first_byte_to_mix is well located. */
const unsigned framesize = p_aout->format.i_bytes_per_frame; const unsigned framesize = p_aout->format.i_bytes_per_frame;
ssize_t delta = (start_date - p_buffer->i_pts)
* p_aout->format.i_rate / CLOCK_FREQ;
if( delta != 0 )
msg_Warn( p_aout, "input start is not output end (%zd)", delta );
if( delta < 0 )
{
/* Is it really the best way to do it ? */
aout_FifoReset (&p->fifo);
return NULL;
}
if( delta > 0 )
{
mtime_t t = delta * CLOCK_FREQ / p_aout->format.i_rate;
p_buffer->i_nb_samples -= delta;
p_buffer->i_pts += t;
p_buffer->i_length -= t;
delta *= framesize;
p_buffer->p_buffer += delta;
p_buffer->i_buffer -= delta;
}
/* Build packet with adequate number of samples */ /* Build packet with adequate number of samples */
unsigned needed = samples * framesize; unsigned needed = samples * framesize;
p_buffer = block_Alloc( needed ); p_buffer = block_Alloc( needed );
if( unlikely(p_buffer == NULL) ) if( unlikely(p_buffer == NULL) )
/* XXX: should free input buffers */ /* XXX: should free input buffers */
......
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