vlc_mtime.h File Reference

Include dependency graph for vlc_mtime.h:

Go to the source code of this file.

Data Structures

struct  date_t

Defines

#define LAST_MDATE   ((mtime_t)((uint64_t)(-1)/2))
#define MSTRTIME_MAX_SIZE   22
#define MILLISECONDS_PER_SEC   1000
#define msecstotimestr(psz_buffer, msecs)   secstotimestr( psz_buffer, (msecs / (int) MILLISECONDS_PER_SEC) )

Functions

char * mstrtime (char *psz_buffer, mtime_t date)
 Return a date in a readable format.
mtime_t mdate (void)
 Return high precision date.
void mwait (mtime_t date)
 Wait for a date.
void msleep (mtime_t delay)
 More precise sleep().
char * secstotimestr (char *psz_buffer, int secs)
 Convert seconds to a time in the format h:mm:ss.
void date_Init (date_t *, uint32_t, uint32_t)
 Initialize a date_t.
void date_Change (date_t *, uint32_t, uint32_t)
 Change a date_t.
void date_Set (date_t *, mtime_t)
 Set the date value of a date_t.
mtime_t date_Get (const date_t *)
 Get the date of a date_t.
void date_Move (date_t *, mtime_t)
 Move forwards or backwards the date of a date_t.
mtime_t date_Increment (date_t *, uint32_t)
 Increment the date and return the result, taking into account rounding errors.
uint64_t NTPtime64 (void)
 
Returns:
NTP 64-bits timestamp in host byte order.


Define Documentation

#define LAST_MDATE   ((mtime_t)((uint64_t)(-1)/2))

#define MILLISECONDS_PER_SEC   1000

#define msecstotimestr ( psz_buffer,
msecs   )     secstotimestr( psz_buffer, (msecs / (int) MILLISECONDS_PER_SEC) )

#define MSTRTIME_MAX_SIZE   22


Function Documentation

void date_Change ( date_t p_date,
uint32_t  i_divider_n,
uint32_t  i_divider_d 
)

Change a date_t.

Parameters:
date to change
divider (sample rate) numerator
divider (sample rate) denominator

mtime_t date_Get ( const date_t p_date  ) 

Get the date of a date_t.

Parameters:
date to get
Returns:
date value

mtime_t date_Increment ( date_t p_date,
uint32_t  i_nb_samples 
)

Increment the date and return the result, taking into account rounding errors.

Parameters:
date to increment
incrementation in number of samples
Returns:
date value

void date_Init ( date_t p_date,
uint32_t  i_divider_n,
uint32_t  i_divider_d 
)

Initialize a date_t.

Parameters:
date to initialize
divider (sample rate) numerator
divider (sample rate) denominator

void date_Move ( date_t p_date,
mtime_t  i_difference 
)

Move forwards or backwards the date of a date_t.

Parameters:
date to move
difference value

void date_Set ( date_t p_date,
mtime_t  i_new_date 
)

Set the date value of a date_t.

Parameters:
date to set
date value

mtime_t mdate ( void   ) 

Return high precision date.

Use a 1 MHz clock when possible, or 1 kHz

Beware ! It doesn't reflect the actual date (since epoch), but can be the machine's uptime or anything (when monotonic clock is used)

void msleep ( mtime_t  delay  ) 

More precise sleep().

Portable usleep() function.

Parameters:
delay the amount of time to sleep

char* mstrtime ( char *  psz_buffer,
mtime_t  date 
)

Return a date in a readable format.

This function converts a mtime date into a string. psz_buffer should be a buffer long enough to store the formatted date.

Parameters:
date to be converted
psz_buffer should be a buffer at least MSTRTIME_MAX_SIZE characters
Returns:
psz_buffer is returned so this can be used as printf parameter.

void mwait ( mtime_t  date  ) 

Wait for a date.

This function uses select() and an system date function to wake up at a precise date. It should be used for process synchronization. If current date is posterior to wished date, the function returns immediately.

Parameters:
date The date to wake up at

uint64_t NTPtime64 ( void   ) 

Returns:
NTP 64-bits timestamp in host byte order.

char* secstotimestr ( char *  psz_buffer,
int  i_seconds 
)

Convert seconds to a time in the format h:mm:ss.

This function is provided for any interface function which need to print a time string in the format h:mm:ss date.

Parameters:
secs the date to be converted
psz_buffer should be a buffer at least MSTRTIME_MAX_SIZE characters
Returns:
psz_buffer is returned so this can be used as printf parameter.


Generated on Wed Aug 13 08:02:45 2008 for VLC by  doxygen 1.5.1