VLC 4.0.0-dev
Loading...
Searching...
No Matches
vlc_tick.h File Reference
Include dependency graph for vlc_tick.h:

Go to the source code of this file.

Data Structures

struct  date_t
 Timestamps without long-term rounding errors. More...

Macros

#define VLC_TICK_MIN   INT64_MIN
#define VLC_TICK_MAX   INT64_MAX
#define VLC_TICK_FROM_SEC(sec)
#define SEC_FROM_VLC_TICK(vtk)
#define vlc_tick_from_sec(sec)
#define VLC_TICK_FROM_MS(ms)
#define MS_FROM_VLC_TICK(vtk)
#define VLC_TICK_FROM_US(us)
#define US_FROM_VLC_TICK(vtk)
#define VLC_TICK_FROM_NS(ns)
#define NS_FROM_VLC_TICK(vtk)
#define MSFTIME_FROM_SEC(sec)
#define MSFTIME_FROM_MS(sec)
#define VLC_TICK_FROM_MSFTIME(msft)
#define MSFTIME_FROM_VLC_TICK(vtk)
#define vlc_tick_from_timeval(tv)
#define vlc_tick_from_timespec(tv)
#define MSTRTIME_MAX_SIZE   22

Typedefs

typedef int64_t vlc_tick_t
 High precision date or time interval.
typedef int64_t msftime_t

Functions

static vlc_tick_t vlc_tick_from_seci (int64_t sec)
static vlc_tick_t vlc_tick_from_secf (double secf)
static double secf_from_vlc_tick (vlc_tick_t vtk)
static vlc_tick_t vlc_tick_rate_duration (float frame_rate)
static vlc_tick_t vlc_tick_from_samples (int64_t samples, unsigned samp_rate)
static int64_t samples_from_vlc_tick (vlc_tick_t t, unsigned samp_rate)
static vlc_tick_t vlc_tick_from_frac (uint64_t num, uint64_t den)
struct timespecvlc_tick_to_timespec (struct timespec *restrict ts, vlc_tick_t tick)
 Converts a VLC tick to a POSIX time specification.
char * vlc_tick_to_str (char *psz_buffer, vlc_tick_t ticks)
 Convert seconds to a time in the format h:mm:ss.
void date_Init (date_t *restrict date, uint32_t num, uint32_t den)
 Initializes a date_t.
void date_Change (date_t *restrict date, uint32_t num, uint32_t den)
 Changes the rate of a date_t.
static void date_Set (date_t *restrict date, vlc_tick_t value)
 Sets the exact timestamp of a date_t.
static vlc_tick_t date_Get (const date_t *restrict date)
 Gets the current timestamp from a date_t.
vlc_tick_t date_Increment (date_t *restrict date, uint32_t count)
 Increments a date.
vlc_tick_t date_Decrement (date_t *restrict date, uint32_t count)
 Decrements a date.
uint64_t vlc_ntp_time (void)
 Gets the current wallclock time as 64-bit NTP timestamp.

Macro Definition Documentation

◆ MS_FROM_VLC_TICK

◆ MSFTIME_FROM_MS

#define MSFTIME_FROM_MS ( sec)
Value:
(INT64_C(10000) * (sec)) /* milliseconds in msftime_t */

◆ MSFTIME_FROM_SEC

#define MSFTIME_FROM_SEC ( sec)
Value:
(INT64_C(10000000) * (sec)) /* seconds in msftime_t */

◆ MSFTIME_FROM_VLC_TICK

#define MSFTIME_FROM_VLC_TICK ( vtk)
Value:
((vtk) / (CLOCK_FREQ / INT64_C(10000000))

Referenced by vlc_timer_schedule().

◆ MSTRTIME_MAX_SIZE

#define MSTRTIME_MAX_SIZE   22

◆ NS_FROM_VLC_TICK

#define NS_FROM_VLC_TICK ( vtk)
Value:
((vtk) / (CLOCK_FREQ / (INT64_C(1000000000))))

Referenced by vlc_tick_to_timespec().

◆ SEC_FROM_VLC_TICK

#define SEC_FROM_VLC_TICK ( vtk)
Value:
((vtk) / CLOCK_FREQ)

Referenced by SetStopStart(), and vlc_tick_to_str().

◆ US_FROM_VLC_TICK

#define US_FROM_VLC_TICK ( vtk)
Value:
((vtk) / (CLOCK_FREQ / INT64_C(1000000)))

Referenced by vlm_ControlMediaInstanceGets(), and vlm_ControlMediaInstanceGetTimePosition().

◆ VLC_TICK_FROM_MS

◆ VLC_TICK_FROM_MSFTIME

#define VLC_TICK_FROM_MSFTIME ( msft)
Value:
((msft) * (CLOCK_FREQ / INT64_C(10000000))

Referenced by mdate_perf_100ns(), and mdate_wall().

◆ VLC_TICK_FROM_NS

#define VLC_TICK_FROM_NS ( ns)
Value:
((ns) * (CLOCK_FREQ / (INT64_C(1000000000))))

◆ VLC_TICK_FROM_SEC

◆ vlc_tick_from_sec

#define vlc_tick_from_sec ( sec)
Value:
_Generic((sec), \
double: vlc_tick_from_secf(sec), \
float: vlc_tick_from_secf(sec), \
default: vlc_tick_from_seci(sec) )
static vlc_tick_t vlc_tick_from_secf(double secf)
Definition vlc_tick.h:80
static vlc_tick_t vlc_tick_from_seci(int64_t sec)
Definition vlc_tick.h:75

Referenced by OpenSDP(), OpenURL(), vlc_player_input_NavigationFallback(), vlc_tick_from_frac(), and vlc_tick_now().

◆ vlc_tick_from_timespec

#define vlc_tick_from_timespec ( tv)
Value:
(vlc_tick_from_sec( (tv)->tv_sec ) + VLC_TICK_FROM_NS( (tv)->tv_nsec ))
#define vlc_tick_from_sec(sec)
Definition vlc_tick.h:85
#define VLC_TICK_FROM_NS(ns)
Definition vlc_tick.h:156

Referenced by vlc_tick_now().

◆ vlc_tick_from_timeval

#define vlc_tick_from_timeval ( tv)
Value:
(vlc_tick_from_sec( (tv)->tv_sec ) + VLC_TICK_FROM_US( (tv)->tv_usec ))
#define VLC_TICK_FROM_US(us)
Definition vlc_tick.h:141

◆ VLC_TICK_FROM_US

#define VLC_TICK_FROM_US ( us)
Value:
((CLOCK_FREQ / INT64_C(1000000)) * (us))

Referenced by vlm_ControlMediaInstanceSetTimePosition().

◆ VLC_TICK_MAX

◆ VLC_TICK_MIN

Typedef Documentation

◆ msftime_t

typedef int64_t msftime_t

◆ vlc_tick_t

typedef int64_t vlc_tick_t

High precision date or time interval.

Store a high precision date or time interval. The maximum precision is the microsecond, and a 64 bits integer is used to avoid overflows (maximum time interval is then 292271 years, which should be long enough for any video). Dates are stored as microseconds since a common date (usually the epoch). Note that date and time intervals can be manipulated using regular arithmetic operators, and that no special functions are required.

Function Documentation

◆ samples_from_vlc_tick()

int64_t samples_from_vlc_tick ( vlc_tick_t t,
unsigned samp_rate )
inlinestatic

◆ secf_from_vlc_tick()

double secf_from_vlc_tick ( vlc_tick_t vtk)
inlinestatic

References CLOCK_FREQ.

◆ vlc_ntp_time()

uint64_t vlc_ntp_time ( void )

Gets the current wallclock time as 64-bit NTP timestamp.

Returns
NTP 64-bits timestamp in host byte order

References TIME_UTC, timespec_get(), timespec::tv_nsec, and timespec::tv_sec.

◆ vlc_tick_from_frac()

vlc_tick_t vlc_tick_from_frac ( uint64_t num,
uint64_t den )
inlinestatic

◆ vlc_tick_from_samples()

◆ vlc_tick_from_secf()

vlc_tick_t vlc_tick_from_secf ( double secf)
inlinestatic

References CLOCK_FREQ.

◆ vlc_tick_from_seci()

vlc_tick_t vlc_tick_from_seci ( int64_t sec)
inlinestatic

References CLOCK_FREQ.

◆ vlc_tick_rate_duration()

vlc_tick_t vlc_tick_rate_duration ( float frame_rate)
inlinestatic

References CLOCK_FREQ.

Referenced by SeekFramePrevious().

◆ vlc_tick_to_str()

char * vlc_tick_to_str ( char * psz_buffer,
vlc_tick_t ticks )

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
ticksthe time to be converted
psz_buffershould be a buffer at least MSTRTIME_MAX_SIZE characters
Returns
psz_buffer is returned so this can be used as printf parameter.

References MSTRTIME_MAX_SIZE, SEC_FROM_VLC_TICK, unlikely, and vlc_tick_to_str().

Referenced by input_title_GetName(), vlc_player_osd_Position(), and vlc_tick_to_str().

◆ vlc_tick_to_timespec()

struct timespec * vlc_tick_to_timespec ( struct timespec *restrict ts,
vlc_tick_t tick )

Converts a VLC tick to a POSIX time specification.

Parameters
ts[out] storage space for the time specification
tickVLC tick
Returns
ts

References CLOCK_FREQ, lldiv(), NS_FROM_VLC_TICK, lldiv_t::quot, and lldiv_t::rem.

Referenced by vlc_atomic_timedwait(), vlc_atomic_timedwait(), vlc_tick_sleep(), and vlc_tick_wait().