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

Go to the source code of this file.

Data Structures

struct  vlc_clock_cbs
 Callbacks for the owner of the main clock. More...
 
struct  vlc_clock_event_cbs
 Event callbacks for the user of a vlc_clock_t. More...
 

Typedefs

typedef struct vlc_clock_listener_id vlc_clock_listener_id
 

Enumerations

enum  vlc_clock_master_source { VLC_CLOCK_MASTER_AUTO = 0 , VLC_CLOCK_MASTER_AUDIO , VLC_CLOCK_MASTER_INPUT , VLC_CLOCK_MASTER_MONOTONIC }
 

Functions

vlc_clock_main_tvlc_clock_main_New (struct vlc_logger *parent_logger, struct vlc_tracer *parent_tracer)
 This function creates the vlc_clock_main_t of the program.
 
void vlc_clock_main_Delete (vlc_clock_main_t *main_clock)
 Destroy the clock main.
 
void vlc_clock_main_Lock (vlc_clock_main_t *main_clock)
 Lock the main_clock mutex.
 
void vlc_clock_main_Unlock (vlc_clock_main_t *main_clock)
 Unlock the main_clock mutex.
 
void vlc_clock_main_Reset (vlc_clock_main_t *main_clock)
 Reset the vlc_clock_main_t.
 
void vlc_clock_main_SetFirstPcr (vlc_clock_main_t *main_clock, vlc_tick_t system_now, vlc_tick_t ts)
 Set the first PCR point.
 
void vlc_clock_main_SetInputDejitter (vlc_clock_main_t *main_clock, vlc_tick_t delay)
 Set the input dejitter.
 
void vlc_clock_main_SetDejitter (vlc_clock_main_t *main_clock, vlc_tick_t dejitter)
 This function sets the dejitter delay to absorb the clock jitter.
 
void vlc_clock_main_ChangePause (vlc_clock_main_t *clock, vlc_tick_t system_now, bool paused)
 This function allows changing the pause status.
 
vlc_clock_tvlc_clock_main_CreateMaster (vlc_clock_main_t *main_clock, const char *track_str_id, const struct vlc_clock_cbs *cbs, void *cbs_data)
 This function creates a new master vlc_clock_t interface.
 
vlc_clock_tvlc_clock_main_CreateInputMaster (vlc_clock_main_t *main_clock)
 This function creates a new input master vlc_clock_t interface.
 
vlc_clock_tvlc_clock_main_CreateSlave (vlc_clock_main_t *main_clock, const char *track_str_id, enum es_format_category_e cat, const struct vlc_clock_cbs *cbs, void *cbs_data)
 This function creates a new slave vlc_clock_t interface.
 
vlc_clock_tvlc_clock_CreateSlave (const vlc_clock_t *clock, enum es_format_category_e cat)
 This function creates a new slave vlc_clock_t interface.
 
void vlc_clock_Delete (vlc_clock_t *clock)
 This function free the resources allocated by vlc_clock*Create*()
 
vlc_tick_t vlc_clock_Update (vlc_clock_t *clock, vlc_tick_t system_now, vlc_tick_t ts, double rate)
 This function will update the clock drift and returns the drift.
 
vlc_tick_t vlc_clock_UpdateVideo (vlc_clock_t *clock, vlc_tick_t system_now, vlc_tick_t ts, double rate, unsigned frame_rate, unsigned frame_rate_base)
 This function will update the video clock drift and returns the drift.
 
void vlc_clock_Reset (vlc_clock_t *clock)
 This function resets the clock drift.
 
vlc_tick_t vlc_clock_SetDelay (vlc_clock_t *clock, vlc_tick_t ts_delay)
 This functions change the clock delay.
 
void vlc_clock_Lock (vlc_clock_t *clock)
 Lock the clock mutex.
 
void vlc_clock_Unlock (vlc_clock_t *clock)
 Unlock the clock mutex.
 
bool vlc_clock_IsPaused (vlc_clock_t *clock)
 Indicate if the clock is paused.
 
int vlc_clock_Wait (vlc_clock_t *clock, vlc_tick_t system_deadline)
 Wait for a timestamp expressed in system time.
 
void vlc_clock_Wake (vlc_clock_t *clock)
 Wake up any vlc_clock_Wait()
 
vlc_clock_listener_idvlc_clock_AddListener (vlc_clock_t *clock, const struct vlc_clock_event_cbs *cbs, void *data)
 Add a listener for events.
 
void vlc_clock_RemoveListener (vlc_clock_t *clock, vlc_clock_listener_id *listener_id)
 Remove a event listener callback.
 
vlc_tick_t vlc_clock_ConvertToSystem (vlc_clock_t *clock, vlc_tick_t system_now, vlc_tick_t ts, double rate)
 This function converts a timestamp from stream to system.
 

Typedef Documentation

◆ vlc_clock_listener_id

Enumeration Type Documentation

◆ vlc_clock_master_source

Enumerator
VLC_CLOCK_MASTER_AUTO 
VLC_CLOCK_MASTER_AUDIO 
VLC_CLOCK_MASTER_INPUT 
VLC_CLOCK_MASTER_MONOTONIC 

Function Documentation

◆ vlc_clock_AddListener()

vlc_clock_listener_id * vlc_clock_AddListener ( vlc_clock_t clock,
const struct vlc_clock_event_cbs cbs,
void *  data 
)

Add a listener for events.

Parameters
clockthe locked clock used by the source
cbsvalid pointer to register events
dataopaque data used by cbs
Returns
a valid listener id, or NULL in case of allocation error

References vlc_clock_listener_id::cbs, vlc_clock_listener_id::clock, vlc_clock_listener_id::data, vlc_clock_main_t::listeners, vlc_clock_main_t::lock, vlc_clock_t::owner, vlc_mutex_assert, and vlc_vector_push.

Referenced by vout_Request().

◆ vlc_clock_ConvertToSystem()

vlc_tick_t vlc_clock_ConvertToSystem ( vlc_clock_t clock,
vlc_tick_t  system_now,
vlc_tick_t  ts,
double  rate 
)

This function converts a timestamp from stream to system.

Parameters
clockthe locked clock used by the source
Returns
the valid system time

References AssertLocked(), vlc_clock_t::ops, and vlc_clock_ops::to_system.

Referenced by ModuleThread_GetDisplayDate(), PreparePicture(), PrerenderPicture(), RenderPicture(), spu_channel_UpdateDates(), spu_PutSubpicture(), stream_Silence(), UpdateCurrentPicture(), vlc_aout_stream_ChangePause(), and vlc_aout_stream_Play().

◆ vlc_clock_CreateSlave()

vlc_clock_t * vlc_clock_CreateSlave ( const vlc_clock_t clock,
enum es_format_category_e  cat 
)

This function creates a new slave vlc_clock_t interface.

You must use vlc_clock_Delete to free it.

Parameters
main_clockthe locked main_clock

References vlc_clock_t::owner, vlc_clock_t::track_str_id, and vlc_clock_main_CreateSlave().

Referenced by aout_filter_GetVout().

◆ vlc_clock_Delete()

void vlc_clock_Delete ( vlc_clock_t clock)

◆ vlc_clock_IsPaused()

bool vlc_clock_IsPaused ( vlc_clock_t clock)

Indicate if the clock is paused.

The clock mutex must be locked.

Parameters
clockthe locked clock used by the source
Return values
trueif the clock is paused
falseif the clock is not paused

References AssertLocked(), vlc_clock_t::owner, vlc_clock_main_t::pause_date, and VLC_TICK_INVALID.

Referenced by RenderPicture().

◆ vlc_clock_Lock()

◆ vlc_clock_main_ChangePause()

void vlc_clock_main_ChangePause ( vlc_clock_main_t clock,
vlc_tick_t  system_now,
bool  paused 
)

This function allows changing the pause status.

Parameters
main_clockthe locked main_clock

Only apply a delay if the clock has a reference point to avoid messing up the timings if the stream was paused then seeked

References vlc_clock_main_t::cond, vlc_clock_main_t::first_pcr, vlc_clock_main_t::last, vlc_clock_main_t::lock, vlc_clock_main_t::offset, vlc_clock_main_t::pause_date, clock_point_t::system, vlc_cond_broadcast(), vlc_mutex_assert, VLC_TICK_INVALID, and vlc_clock_main_t::wait_sync_ref.

Referenced by EsOutProgramChangePause().

◆ vlc_clock_main_CreateInputMaster()

vlc_clock_t * vlc_clock_main_CreateInputMaster ( vlc_clock_main_t main_clock)

This function creates a new input master vlc_clock_t interface.

Once the input master is created, the current or future master clock created from vlc_clock_main_CreateMaster() will be demoted as slave.

Warning
There can be only one input master at a given time.

You must use vlc_clock_Delete to free it.

Parameters
main_clockthe locked main_clock

References vlc_clock_main_t::input_master, vlc_clock_main_t::lock, vlc_clock_main_t::master, master_ops, vlc_clock_main_t::offset, vlc_clock_t::ops, vlc_clock_main_t::rc, slave_ops, vlc_clock_main_Create(), vlc_mutex_assert, and VLC_TICK_INVALID.

Referenced by EsOutProgramHandleClockSource().

◆ vlc_clock_main_CreateMaster()

vlc_clock_t * vlc_clock_main_CreateMaster ( vlc_clock_main_t main_clock,
const char *  track_str_id,
const struct vlc_clock_cbs cbs,
void *  cbs_data 
)

This function creates a new master vlc_clock_t interface.

Warning
There can be only one master at a given time.

You must use vlc_clock_Delete to free it.

Parameters
main_clockthe locked main_clock

References vlc_clock_main_t::input_master, vlc_clock_main_t::lock, vlc_clock_main_t::master, master_ops, vlc_clock_t::ops, vlc_clock_main_t::rc, slave_ops, vlc_clock_main_Create(), and vlc_mutex_assert.

Referenced by EsOutCreateDecoder().

◆ vlc_clock_main_CreateSlave()

vlc_clock_t * vlc_clock_main_CreateSlave ( vlc_clock_main_t main_clock,
const char *  track_str_id,
enum es_format_category_e  cat,
const struct vlc_clock_cbs cbs,
void *  cbs_data 
)

This function creates a new slave vlc_clock_t interface.

You must use vlc_clock_Delete to free it.

Parameters
main_clockthe locked main_clock

References AUDIO_ES, vlc_clock_main_t::lock, vlc_clock_t::ops, vlc_clock_main_t::rc, slave_ops, SPU_ES, VIDEO_ES, vlc_clock_main_Create(), and vlc_mutex_assert.

Referenced by EsOutCreateDecoder(), EsOutProgramHandleClockSource(), sout_ClockCreate(), and vlc_clock_CreateSlave().

◆ vlc_clock_main_Delete()

void vlc_clock_main_Delete ( vlc_clock_main_t main_clock)

Destroy the clock main.

Parameters
main_clockthe unlocked main_clock

References vlc_clock_main_t::listeners, vlc_clock_main_t::logger, vlc_clock_main_t::rc, vlc_clock_main_t::size, vlc_LogDestroy(), and vlc_vector_destroy.

Referenced by EsOutProgramAdd(), ProgramDelete(), and sout_ClockMainDelete().

◆ vlc_clock_main_Lock()

void vlc_clock_main_Lock ( vlc_clock_main_t main_clock)

Lock the main_clock mutex.

All vlc_clock_main_t functions must be called with the lock held, except vlc_clock_main_Delete()

Parameters
main_clockthe unlocked main_clock

References vlc_clock_main_t::lock, and vlc_mutex_lock().

Referenced by EsOutCreateDecoder(), EsOutDecodersStopBuffering(), EsOutProgramAdd(), EsOutProgramChangePause(), EsOutProgramHandleClockSource(), EsOutVaPrivControlLocked(), sout_ClockCreate(), and sout_ClockMainSetFirstPcr().

◆ vlc_clock_main_New()

◆ vlc_clock_main_Reset()

void vlc_clock_main_Reset ( vlc_clock_main_t main_clock)

◆ vlc_clock_main_SetDejitter()

void vlc_clock_main_SetDejitter ( vlc_clock_main_t main_clock,
vlc_tick_t  dejitter 
)

This function sets the dejitter delay to absorb the clock jitter.

Also used as the maximum delay before the synchro is considered to kick in.

Parameters
main_clockthe locked main_clock

References vlc_clock_main_t::lock, vlc_clock_main_t::output_dejitter, and vlc_mutex_assert.

Referenced by EsOutProgramAdd().

◆ vlc_clock_main_SetFirstPcr()

void vlc_clock_main_SetFirstPcr ( vlc_clock_main_t main_clock,
vlc_tick_t  system_now,
vlc_tick_t  ts 
)

◆ vlc_clock_main_SetInputDejitter()

void vlc_clock_main_SetInputDejitter ( vlc_clock_main_t main_clock,
vlc_tick_t  delay 
)

Set the input dejitter.

Parameters
main_clockthe locked main_clock

References vlc_clock_main_t::input_dejitter, vlc_clock_main_t::lock, and vlc_mutex_assert.

Referenced by EsOutProgramAdd(), and EsOutVaPrivControlLocked().

◆ vlc_clock_main_Unlock()

◆ vlc_clock_RemoveListener()

void vlc_clock_RemoveListener ( vlc_clock_t clock,
vlc_clock_listener_id listener_id 
)

Remove a event listener callback.

Parameters
clockthe locked clock used by the source
listener_idlistener id returned by vlc_clock_AddListener()

References vlc_clock_main_t::listeners, vlc_clock_main_t::lock, vlc_clock_t::owner, vlc_assert_unreachable, vlc_mutex_assert, vlc_vector_foreach, and vlc_vector_remove.

Referenced by vout_ReleaseDisplay(), and vout_Request().

◆ vlc_clock_Reset()

void vlc_clock_Reset ( vlc_clock_t clock)

This function resets the clock drift.

Parameters
clockthe locked clock used by the source

References AssertLocked(), vlc_clock_t::ops, and vlc_clock_ops::reset.

Referenced by aout_FiltersPipelineResetClock(), ClockListenerReset(), spu_ClearChannel(), stream_Reset(), and vout_FlushUnlocked().

◆ vlc_clock_SetDelay()

vlc_tick_t vlc_clock_SetDelay ( vlc_clock_t clock,
vlc_tick_t  ts_delay 
)

This functions change the clock delay.

It returns the amount of time the clock owner need to wait in order to reach the time introduced by the new positive delay.

Parameters
clockthe locked clock used by the source

References AssertLocked(), vlc_clock_t::ops, and vlc_clock_ops::set_delay.

Referenced by aout_FiltersPipelineSetClockDelay(), spu_ClearChannel(), spu_SetClockDelay(), stream_Reset(), vlc_aout_stream_Play(), vout_ChangeDelay(), and vout_FlushUnlocked().

◆ vlc_clock_Unlock()

◆ vlc_clock_Update()

vlc_tick_t vlc_clock_Update ( vlc_clock_t clock,
vlc_tick_t  system_now,
vlc_tick_t  ts,
double  rate 
)

This function will update the clock drift and returns the drift.

Parameters
clockthe locked clock used by the source
system_nowvalid system time or VLC_TICK_MAX is the updated point is forced (when paused for example)
tsthe timestamp in media time for the updated point
ratethe current playback speed
Returns
a valid drift relative time, VLC_TICK_INVALID if there is no drift (clock is master)

References AssertLocked(), vlc_clock_t::ops, and vlc_clock_ops::update.

Referenced by ClockListenerUpdate(), stream_Synchronize(), vlc_aout_stream_NotifyTiming(), and vlc_aout_stream_Play().

◆ vlc_clock_UpdateVideo()

vlc_tick_t vlc_clock_UpdateVideo ( vlc_clock_t clock,
vlc_tick_t  system_now,
vlc_tick_t  ts,
double  rate,
unsigned  frame_rate,
unsigned  frame_rate_base 
)

This function will update the video clock drift and returns the drift.

Same behavior than vlc_clock_Update() except that the video is passed to the clock, this will be used for clock update callbacks.

References AssertLocked(), vlc_clock_t::ops, and vlc_clock_ops::update.

Referenced by RenderPicture().

◆ vlc_clock_Wait()

int vlc_clock_Wait ( vlc_clock_t clock,
vlc_tick_t  system_deadline 
)

Wait for a timestamp expressed in system time.

The wait will be interrupted (signaled) on clock state changes which could invalidate the computed deadline. In that case, the caller must recompute the new deadline and call it again.

Parameters
clockthe locked clock used by the source
Returns
0 if the condition was signaled, an error code in case of timeout

References AssertLocked(), vlc_clock_main_t::cond, vlc_clock_main_t::lock, vlc_clock_t::owner, and vlc_cond_timedwait().

Referenced by RenderPicture().

◆ vlc_clock_Wake()

void vlc_clock_Wake ( vlc_clock_t clock)

Wake up any vlc_clock_Wait()

Parameters
clockthe locked clock used by the source

References AssertLocked(), vlc_clock_main_t::cond, vlc_clock_t::owner, and vlc_cond_broadcast().

Referenced by VoutRenderWakeUpUrgent().