VLC_EXPORT( mtime_t, date_Get, ( const date_t * ) );
VLC_EXPORT( void, date_Move, ( date_t *, mtime_t ) );
VLC_EXPORT( mtime_t, date_Increment, ( date_t *, uint32_t ) );
+VLC_EXPORT( mtime_t, date_Decrement, ( date_t *, uint32_t ) );
VLC_EXPORT( uint64_t, NTPtime64, ( void ) );
#endif /* !__VLC_MTIME_ */
* General utility funcions
*/
-/* decrement a date. opposite to date_Increment */
-static mtime_t date_Decrement( date_t *p_date, uint32_t i_nb_samples )
-{
- mtime_t i_dividend = (mtime_t)i_nb_samples * 1000000 * p_date->i_divider_den;
- p_date->date -= i_dividend / p_date->i_divider_num;
- unsigned u_rem_adjust = i_dividend % p_date->i_divider_num;
-
- if( p_date->i_remainder < u_rem_adjust )
- {
- /* This is Bresenham algorithm. */
- assert( p_date->i_remainder > -p_date->i_divider_num);
- p_date->date -= 1;
- p_date->i_remainder += p_date->i_divider_num;
- }
-
- p_date->i_remainder -= u_rem_adjust;
-
- return p_date->date;
-}
-
/**
* given a chain of block_t, allocate and return an array containing
* pointers to all the blocks. (Acts as a replacement for the old p_prev
config_StringUnescape
convert_xml_special_chars
date_Change
+date_Decrement
date_Get
date_Increment
date_Init
return p_date->date;
}
+/**
+ * Decrement the date and return the result, taking into account
+ * rounding errors.
+ *
+ * \param date to decrement
+ * \param decrementation in number of samples
+ * \return date value
+ */
+mtime_t date_Decrement( date_t *p_date, uint32_t i_nb_samples )
+{
+ mtime_t i_dividend = (mtime_t)i_nb_samples * 1000000 * p_date->i_divider_den;
+ p_date->date -= i_dividend / p_date->i_divider_num;
+ unsigned i_rem_adjust = i_dividend % p_date->i_divider_num;
+
+ if( p_date->i_remainder < i_rem_adjust )
+ {
+ /* This is Bresenham algorithm. */
+ assert( p_date->i_remainder > -p_date->i_divider_num);
+ p_date->date -= 1;
+ p_date->i_remainder += p_date->i_divider_num;
+ }
+
+ p_date->i_remainder -= i_rem_adjust;
+
+ return p_date->date;
+}
+
#ifndef HAVE_GETTIMEOFDAY
#ifdef WIN32