[vlc-commits] aout: use VLC_TS_INVALID
Rémi Denis-Courmont
git at videolan.org
Mon Aug 1 18:35:26 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Aug 1 19:31:07 2011 +0300| [4f7824b2e24b2c3a4c04e229ff33005b08489943] | committer: Rémi Denis-Courmont
aout: use VLC_TS_INVALID
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4f7824b2e24b2c3a4c04e229ff33005b08489943
---
src/audio_output/common.c | 26 ++++++++++++++------------
src/audio_output/dec.c | 2 +-
src/audio_output/input.c | 6 +++---
src/audio_output/mixer.c | 2 +-
4 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index 91c3f00..bc82617 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -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->pp_last = &p_fifo->p_first;
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 )
p_fifo->pp_last = &p_buffer->p_next;
*p_fifo->pp_last = NULL;
/* 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_length = date_Increment( &p_fifo->end_date,
@@ -369,7 +370,7 @@ void aout_FifoReset( aout_fifo_t * p_fifo )
{
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;
while ( p_buffer != NULL )
{
@@ -384,17 +385,17 @@ void aout_FifoReset( aout_fifo_t * p_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;
-
- date_Move( &p_fifo->end_date, difference );
- p_buffer = p_fifo->p_first;
- while ( p_buffer != NULL )
+ if( date_Get( &fifo->end_date ) == VLC_TS_INVALID )
{
- p_buffer->i_pts += difference;
- p_buffer = p_buffer->p_next;
+ assert( fifo->p_first == NULL );
+ 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 )
* aout_FifoFirstDate : return the playing date of the first buffer in the
* 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;
}
/*****************************************************************************
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 5aed63b..8aad091 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -252,5 +252,5 @@ bool aout_DecIsEmpty( audio_output_t * p_aout, aout_input_t * p_input )
aout_lock( p_aout );
end_date = aout_FifoNextStart( &p_input->fifo );
aout_unlock( p_aout );
- return end_date <= mdate();
+ return end_date == VLC_TS_INVALID || end_date <= mdate();
}
diff --git a/src/audio_output/input.c b/src/audio_output/input.c
index 8ed95ce..dcd3d7a 100644
--- a/src/audio_output/input.c
+++ b/src/audio_output/input.c
@@ -542,7 +542,7 @@ void aout_InputPlay( audio_output_t * p_aout, aout_input_t * p_input,
* with the next incoming buffer. */
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
* 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,
msg_Warn( p_aout, "timing screwed, stopping resampling" );
inputResamplingStop( p_input );
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 )
@@ -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
* the audio. */
- if( !start_date )
+ if( start_date == VLC_TS_INVALID )
start_date = p_buffer->i_pts;
mtime_t drift = start_date - p_buffer->i_pts;
diff --git a/src/audio_output/mixer.c b/src/audio_output/mixer.c
index 1e11021..de55977 100644
--- a/src/audio_output/mixer.c
+++ b/src/audio_output/mixer.c
@@ -111,7 +111,7 @@ static int MixBuffer( audio_output_t * p_aout, float volume )
return -1;
/* Find the earliest start date available. */
- if ( !start_date )
+ if ( start_date == VLC_TS_INVALID )
{
start_date = p_buffer->i_pts;
date_Set( &exact_start_date, start_date );
More information about the vlc-commits
mailing list