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

aout: use VLC_TS_INVALID

parent 274f047a
...@@ -338,6 +338,7 @@ void aout_FifoInit( vlc_object_t *obj, aout_fifo_t * p_fifo, uint32_t i_rate ) ...@@ -338,6 +338,7 @@ void aout_FifoInit( vlc_object_t *obj, aout_fifo_t * p_fifo, uint32_t i_rate )
p_fifo->p_first = NULL; p_fifo->p_first = NULL;
p_fifo->pp_last = &p_fifo->p_first; p_fifo->pp_last = &p_fifo->p_first;
date_Init( &p_fifo->end_date, i_rate, 1 ); date_Init( &p_fifo->end_date, i_rate, 1 );
date_Set( &p_fifo->end_date, VLC_TS_INVALID );
} }
/***************************************************************************** /*****************************************************************************
...@@ -349,7 +350,7 @@ void aout_FifoPush( aout_fifo_t * p_fifo, aout_buffer_t * p_buffer ) ...@@ -349,7 +350,7 @@ void aout_FifoPush( aout_fifo_t * p_fifo, aout_buffer_t * p_buffer )
p_fifo->pp_last = &p_buffer->p_next; p_fifo->pp_last = &p_buffer->p_next;
*p_fifo->pp_last = NULL; *p_fifo->pp_last = NULL;
/* Enforce the continuity of the stream. */ /* Enforce the continuity of the stream. */
if ( date_Get( &p_fifo->end_date ) ) if( date_Get( &p_fifo->end_date ) != VLC_TS_INVALID )
{ {
p_buffer->i_pts = date_Get( &p_fifo->end_date ); p_buffer->i_pts = date_Get( &p_fifo->end_date );
p_buffer->i_length = date_Increment( &p_fifo->end_date, p_buffer->i_length = date_Increment( &p_fifo->end_date,
...@@ -369,7 +370,7 @@ void aout_FifoReset( aout_fifo_t * p_fifo ) ...@@ -369,7 +370,7 @@ void aout_FifoReset( aout_fifo_t * p_fifo )
{ {
aout_buffer_t * p_buffer; aout_buffer_t * p_buffer;
date_Set( &p_fifo->end_date, 0 ); date_Set( &p_fifo->end_date, VLC_TS_INVALID );
p_buffer = p_fifo->p_first; p_buffer = p_fifo->p_first;
while ( p_buffer != NULL ) while ( p_buffer != NULL )
{ {
...@@ -384,17 +385,17 @@ void aout_FifoReset( aout_fifo_t * p_fifo ) ...@@ -384,17 +385,17 @@ void aout_FifoReset( aout_fifo_t * p_fifo )
/***************************************************************************** /*****************************************************************************
* aout_FifoMoveDates : Move forwards or backwards all dates in the FIFO * aout_FifoMoveDates : Move forwards or backwards all dates in the FIFO
*****************************************************************************/ *****************************************************************************/
void aout_FifoMoveDates( aout_fifo_t * p_fifo, mtime_t difference ) void aout_FifoMoveDates( aout_fifo_t *fifo, mtime_t difference )
{ {
aout_buffer_t * p_buffer; if( date_Get( &fifo->end_date ) == VLC_TS_INVALID )
date_Move( &p_fifo->end_date, difference );
p_buffer = p_fifo->p_first;
while ( p_buffer != NULL )
{ {
p_buffer->i_pts += difference; assert( fifo->p_first == NULL );
p_buffer = p_buffer->p_next; return;
} }
date_Move( &fifo->end_date, difference );
for( block_t *block = fifo->p_first; block != NULL; block = block->p_next )
block->i_pts += difference;
} }
/***************************************************************************** /*****************************************************************************
...@@ -409,9 +410,10 @@ mtime_t aout_FifoNextStart( const aout_fifo_t *p_fifo ) ...@@ -409,9 +410,10 @@ mtime_t aout_FifoNextStart( const aout_fifo_t *p_fifo )
* aout_FifoFirstDate : return the playing date of the first buffer in the * aout_FifoFirstDate : return the playing date of the first buffer in the
* FIFO * FIFO
*****************************************************************************/ *****************************************************************************/
mtime_t aout_FifoFirstDate( const aout_fifo_t *p_fifo ) mtime_t aout_FifoFirstDate( const aout_fifo_t *fifo )
{ {
return (p_fifo->p_first != NULL) ? p_fifo->p_first->i_pts : 0; block_t *first = fifo->p_first;
return (first != NULL) ? first->i_pts : VLC_TS_INVALID;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -252,5 +252,5 @@ bool aout_DecIsEmpty( audio_output_t * p_aout, aout_input_t * p_input ) ...@@ -252,5 +252,5 @@ bool aout_DecIsEmpty( audio_output_t * p_aout, aout_input_t * p_input )
aout_lock( p_aout ); aout_lock( p_aout );
end_date = aout_FifoNextStart( &p_input->fifo ); end_date = aout_FifoNextStart( &p_input->fifo );
aout_unlock( p_aout ); aout_unlock( p_aout );
return end_date <= mdate(); return end_date == VLC_TS_INVALID || end_date <= mdate();
} }
...@@ -542,7 +542,7 @@ void aout_InputPlay( audio_output_t * p_aout, aout_input_t * p_input, ...@@ -542,7 +542,7 @@ void aout_InputPlay( audio_output_t * p_aout, aout_input_t * p_input,
* with the next incoming buffer. */ * with the next incoming buffer. */
start_date = aout_FifoNextStart( &p_input->fifo ); start_date = aout_FifoNextStart( &p_input->fifo );
if ( start_date != 0 && start_date < now ) if ( start_date != VLC_TS_INVALID && start_date < now )
{ {
/* The decoder is _very_ late. This can only happen if the user /* The decoder is _very_ late. This can only happen if the user
* pauses the stream (or if the decoder is buggy, which cannot * pauses the stream (or if the decoder is buggy, which cannot
...@@ -555,7 +555,7 @@ void aout_InputPlay( audio_output_t * p_aout, aout_input_t * p_input, ...@@ -555,7 +555,7 @@ void aout_InputPlay( audio_output_t * p_aout, aout_input_t * p_input,
msg_Warn( p_aout, "timing screwed, stopping resampling" ); msg_Warn( p_aout, "timing screwed, stopping resampling" );
inputResamplingStop( p_input ); inputResamplingStop( p_input );
p_buffer->i_flags |= BLOCK_FLAG_DISCONTINUITY; p_buffer->i_flags |= BLOCK_FLAG_DISCONTINUITY;
start_date = 0; start_date = VLC_TS_INVALID;
} }
if ( p_buffer->i_pts < now + AOUT_MIN_PREPARE_TIME ) if ( p_buffer->i_pts < now + AOUT_MIN_PREPARE_TIME )
...@@ -571,7 +571,7 @@ void aout_InputPlay( audio_output_t * p_aout, aout_input_t * p_input, ...@@ -571,7 +571,7 @@ void aout_InputPlay( audio_output_t * p_aout, aout_input_t * p_input,
/* If the audio drift is too big then it's not worth trying to resample /* If the audio drift is too big then it's not worth trying to resample
* the audio. */ * the audio. */
if( !start_date ) if( start_date == VLC_TS_INVALID )
start_date = p_buffer->i_pts; start_date = p_buffer->i_pts;
mtime_t drift = start_date - p_buffer->i_pts; mtime_t drift = start_date - p_buffer->i_pts;
......
...@@ -111,7 +111,7 @@ static int MixBuffer( audio_output_t * p_aout, float volume ) ...@@ -111,7 +111,7 @@ static int MixBuffer( audio_output_t * p_aout, float volume )
return -1; return -1;
/* Find the earliest start date available. */ /* Find the earliest start date available. */
if ( !start_date ) if ( start_date == VLC_TS_INVALID )
{ {
start_date = p_buffer->i_pts; start_date = p_buffer->i_pts;
date_Set( &exact_start_date, start_date ); date_Set( &exact_start_date, start_date );
......
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