mtime.c File Reference

Include dependency graph for mtime.c:


Data Structures

struct  timespec

Defines

#define _POSIX_CLOCK_SELECTION   (-1)
#define CLOCK_MONOTONIC   CLOCK_REALTIME

Functions

char * mstrtime (char *psz_buffer, mtime_t date)
 Return a date in a readable format.
char * secstotimestr (char *psz_buffer, int i_seconds)
 Convert seconds to a time in the format h:mm:ss.
static unsigned mprec (void)
 Return a value that is no bigger than the clock precision (possibly zero).
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().
void date_Init (date_t *p_date, uint32_t i_divider_n, uint32_t i_divider_d)
 Initialize a date_t.
void date_Change (date_t *p_date, uint32_t i_divider_n, uint32_t i_divider_d)
 Change a date_t.
void date_Set (date_t *p_date, mtime_t i_new_date)
 Set the date value of a date_t.
mtime_t date_Get (const date_t *p_date)
 Get the date of a date_t.
void date_Move (date_t *p_date, mtime_t i_difference)
 Move forwards or backwards the date of a date_t.
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.
uint64_t NTPtime64 (void)
 
Returns:
NTP 64-bits timestamp in host byte order.


Define Documentation

#define _POSIX_CLOCK_SELECTION   (-1)

#define CLOCK_MONOTONIC   CLOCK_REALTIME


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)

static unsigned mprec ( void   )  [inline, static]

Return a value that is no bigger than the clock precision (possibly zero).

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:05:40 2008 for VLC by  doxygen 1.5.1