-
-/*
- * 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;
-}
-