Commit 87720524 authored by Laurent Aimar's avatar Laurent Aimar

Removed audio_date_t in favor to date_t.

parent a882fa8a
......@@ -163,16 +163,6 @@ struct aout_buffer_t
/* Max input rate factor (1/4 -> 4) */
#define AOUT_MAX_INPUT_RATE (4)
/** date incrementation helper structure without long-term
* rounding errors
*/
struct audio_date_t
{
mtime_t date;
uint32_t i_divider;
uint32_t i_remainder;
};
/** allocation of memory in the audio output */
typedef struct aout_alloc_t
{
......@@ -208,7 +198,7 @@ struct aout_fifo_t
{
aout_buffer_t * p_first;
aout_buffer_t ** pp_last;
audio_date_t end_date;
date_t end_date;
};
/* */
......@@ -382,13 +372,6 @@ static const uint32_t pi_vlc_chan_order_wg4[] =
* Prototypes
*****************************************************************************/
/* From common.c : */
VLC_EXPORT( void, aout_DateInit, ( audio_date_t *, uint32_t ) );
VLC_EXPORT( void, aout_DateSet, ( audio_date_t *, mtime_t ) );
VLC_EXPORT( void, aout_DateMove, ( audio_date_t *, mtime_t ) );
VLC_EXPORT( mtime_t, aout_DateGet, ( const audio_date_t * ) LIBVLC_USED);
VLC_EXPORT( mtime_t, aout_DateIncrement, ( audio_date_t *, uint32_t ) );
VLC_EXPORT( aout_buffer_t *, aout_OutputNextBuffer, ( aout_instance_t *, mtime_t, bool ) LIBVLC_USED );
/**
......
......@@ -350,7 +350,7 @@ void aout_FifoInit( aout_instance_t * p_aout, aout_fifo_t * p_fifo,
p_fifo->p_first = NULL;
p_fifo->pp_last = &p_fifo->p_first;
aout_DateInit( &p_fifo->end_date, i_rate );
date_Init( &p_fifo->end_date, i_rate, 1 );
}
/*****************************************************************************
......@@ -366,15 +366,15 @@ void aout_FifoPush( aout_instance_t * p_aout, aout_fifo_t * p_fifo,
p_fifo->pp_last = &p_buffer->p_next;
*p_fifo->pp_last = NULL;
/* Enforce the continuity of the stream. */
if ( aout_DateGet( &p_fifo->end_date ) )
if ( date_Get( &p_fifo->end_date ) )
{
p_buffer->start_date = aout_DateGet( &p_fifo->end_date );
p_buffer->end_date = aout_DateIncrement( &p_fifo->end_date,
p_buffer->start_date = date_Get( &p_fifo->end_date );
p_buffer->end_date = date_Increment( &p_fifo->end_date,
p_buffer->i_nb_samples );
}
else
{
aout_DateSet( &p_fifo->end_date, p_buffer->end_date );
date_Set( &p_fifo->end_date, p_buffer->end_date );
}
}
......@@ -389,7 +389,7 @@ void aout_FifoSet( aout_instance_t * p_aout, aout_fifo_t * p_fifo,
(void)p_aout;
AOUT_ASSERT_FIFO_LOCKED;
aout_DateSet( &p_fifo->end_date, date );
date_Set( &p_fifo->end_date, date );
p_buffer = p_fifo->p_first;
while ( p_buffer != NULL )
{
......@@ -411,7 +411,7 @@ void aout_FifoMoveDates( aout_instance_t * p_aout, aout_fifo_t * p_fifo,
(void)p_aout;
AOUT_ASSERT_FIFO_LOCKED;
aout_DateMove( &p_fifo->end_date, difference );
date_Move( &p_fifo->end_date, difference );
p_buffer = p_fifo->p_first;
while ( p_buffer != NULL )
{
......@@ -428,7 +428,7 @@ mtime_t aout_FifoNextStart( aout_instance_t * p_aout, aout_fifo_t * p_fifo )
{
(void)p_aout;
AOUT_ASSERT_FIFO_LOCKED;
return aout_DateGet( &p_fifo->end_date );
return date_Get( &p_fifo->end_date );
}
/*****************************************************************************
......@@ -483,65 +483,6 @@ void aout_FifoDestroy( aout_instance_t * p_aout, aout_fifo_t * p_fifo )
p_fifo->pp_last = &p_fifo->p_first;
}
/*
* Date management (internal and external)
*/
/*****************************************************************************
* aout_DateInit : set the divider of an audio_date_t
*****************************************************************************/
void aout_DateInit( audio_date_t * p_date, uint32_t i_divider )
{
p_date->date = 0;
p_date->i_divider = i_divider;
p_date->i_remainder = 0;
}
/*****************************************************************************
* aout_DateSet : set the date of an audio_date_t
*****************************************************************************/
void aout_DateSet( audio_date_t * p_date, mtime_t new_date )
{
p_date->date = new_date;
p_date->i_remainder = 0;
}
/*****************************************************************************
* aout_DateMove : move forwards or backwards the date of an audio_date_t
*****************************************************************************/
void aout_DateMove( audio_date_t * p_date, mtime_t difference )
{
p_date->date += difference;
}
/*****************************************************************************
* aout_DateGet : get the date of an audio_date_t
*****************************************************************************/
mtime_t aout_DateGet( const audio_date_t * p_date )
{
return p_date->date;
}
/*****************************************************************************
* aout_DateIncrement : increment the date and return the result, taking
* into account rounding errors
*****************************************************************************/
mtime_t aout_DateIncrement( audio_date_t * p_date, uint32_t i_nb_samples )
{
mtime_t i_dividend = INT64_C(1000000) * i_nb_samples;
assert( p_date->i_divider > 0 ); /* uninitialized audio_data_t ? */
p_date->date += i_dividend / p_date->i_divider;
p_date->i_remainder += (int)(i_dividend % p_date->i_divider);
if ( p_date->i_remainder >= p_date->i_divider )
{
/* This is Bresenham algorithm. */
p_date->date++;
p_date->i_remainder -= p_date->i_divider;
}
return p_date->date;
}
/*****************************************************************************
* aout_CheckChannelReorder : Check if we need to do some channel re-ordering
*****************************************************************************/
......
......@@ -75,7 +75,7 @@ static int MixBuffer( aout_instance_t * p_aout )
int i, i_first_input = 0;
aout_buffer_t * p_output_buffer;
mtime_t start_date, end_date;
audio_date_t exact_start_date;
date_t exact_start_date;
if ( p_aout->mixer.b_error )
{
......@@ -102,9 +102,8 @@ static int MixBuffer( aout_instance_t * p_aout )
aout_lock_input_fifos( p_aout );
/* Retrieve the date of the next buffer. */
memcpy( &exact_start_date, &p_aout->output.fifo.end_date,
sizeof(audio_date_t) );
start_date = aout_DateGet( &exact_start_date );
exact_start_date = p_aout->output.fifo.end_date;
start_date = date_Get( &exact_start_date );
if ( start_date != 0 && start_date < mdate() )
{
......@@ -114,7 +113,7 @@ static int MixBuffer( aout_instance_t * p_aout )
msg_Warn( p_aout, "output PTS is out of range (%"PRId64"), clearing out",
mdate() - start_date );
aout_FifoSet( p_aout, &p_aout->output.fifo, 0 );
aout_DateSet( &exact_start_date, 0 );
date_Set( &exact_start_date, 0 );
start_date = 0;
}
......@@ -152,7 +151,7 @@ static int MixBuffer( aout_instance_t * p_aout )
if ( !start_date || start_date < p_buffer->start_date )
{
aout_DateSet( &exact_start_date, p_buffer->start_date );
date_Set( &exact_start_date, p_buffer->start_date );
start_date = p_buffer->start_date;
}
}
......@@ -164,8 +163,8 @@ static int MixBuffer( aout_instance_t * p_aout )
return -1;
}
}
aout_DateIncrement( &exact_start_date, p_aout->output.i_nb_samples );
end_date = aout_DateGet( &exact_start_date );
date_Increment( &exact_start_date, p_aout->output.i_nb_samples );
end_date = date_Get( &exact_start_date );
/* Check that start_date and end_date are available for all input
* streams. */
......@@ -280,7 +279,7 @@ static int MixBuffer( aout_instance_t * p_aout )
/* Is it really the best way to do it ? */
aout_lock_output_fifo( p_aout );
aout_FifoSet( p_aout, &p_aout->output.fifo, 0 );
aout_DateSet( &exact_start_date, 0 );
date_Set( &exact_start_date, 0 );
aout_unlock_output_fifo( p_aout );
break;
}
......
......@@ -11,11 +11,6 @@ aout_ChannelReorder
aout_ChannelsRestart
aout_CheckChannelExtraction
aout_CheckChannelReorder
aout_DateGet
aout_DateIncrement
aout_DateInit
aout_DateMove
aout_DateSet
aout_EnableFilter
aout_FifoFirstDate
aout_FifoPop
......
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