[vlc-devel] [PATCH 09/17] clock: remove monotonic fallback
Thomas Guillem
thomas at gllm.fr
Mon Feb 15 10:15:04 UTC 2021
The clock is always driven by the input clock by default.
---
src/clock/clock.c | 106 +++++-----------------------------------------
1 file changed, 10 insertions(+), 96 deletions(-)
diff --git a/src/clock/clock.c b/src/clock/clock.c
index c4160e9701b..32e1a6c721e 100644
--- a/src/clock/clock.c
+++ b/src/clock/clock.c
@@ -52,8 +52,6 @@ struct vlc_clock_main_t
vlc_tick_t pause_date;
- unsigned wait_sync_ref_priority;
- clock_point_t wait_sync_ref; /* When the master */
clock_point_t first_pcr;
vlc_tick_t output_dejitter; /* Delay used to absorb the output clock jitter */
vlc_tick_t input_dejitter; /* Delay used to absorb the input jitter */
@@ -72,7 +70,6 @@ struct vlc_clock_t
vlc_clock_main_t *owner;
vlc_tick_t delay;
- unsigned priority;
const struct vlc_clock_cbs *cbs;
void *cbs_data;
@@ -94,9 +91,7 @@ static void vlc_clock_main_reset(vlc_clock_main_t *main_clock)
main_clock->rate = 1.0f;
main_clock->offset = VLC_TICK_INVALID;
- main_clock->wait_sync_ref_priority = UINT_MAX;
- main_clock->wait_sync_ref =
- main_clock->last = clock_point_Create(VLC_TICK_INVALID, VLC_TICK_INVALID);
+ main_clock->last = clock_point_Create(VLC_TICK_INVALID, VLC_TICK_INVALID);
vlc_cond_broadcast(&main_clock->cond);
}
@@ -158,12 +153,6 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
main_clock->coeff = AvgGet(&main_clock->coeff_avg);
}
}
- else
- {
- main_clock->wait_sync_ref_priority = UINT_MAX;
- main_clock->wait_sync_ref =
- clock_point_Create(VLC_TICK_INVALID, VLC_TICK_INVALID);
- }
main_clock->offset = system_now - ts * main_clock->coeff / rate;
@@ -242,51 +231,18 @@ static vlc_tick_t vlc_clock_master_set_delay(vlc_clock_t *clock, vlc_tick_t dela
return delta;
}
-static vlc_tick_t
-vlc_clock_monotonic_to_system_locked(vlc_clock_t *clock, vlc_tick_t now,
- vlc_tick_t ts, double rate)
-{
- vlc_clock_main_t *main_clock = clock->owner;
-
- if (clock->priority < main_clock->wait_sync_ref_priority)
- {
- /* XXX: This input_delay calculation is needed until we (finally) get
- * ride of the input clock. This code is adapted from input_clock.c and
- * is used to introduce the same delay than the input clock (first PTS
- * - first PCR). */
- const vlc_tick_t pcr_delay =
- main_clock->first_pcr.system == VLC_TICK_INVALID ? 0 :
- (ts - main_clock->first_pcr.stream) / rate +
- main_clock->first_pcr.system - now;
-
- const vlc_tick_t input_delay = main_clock->input_dejitter + pcr_delay;
-
- const vlc_tick_t delay =
- __MAX(input_delay, main_clock->output_dejitter);
-
- main_clock->wait_sync_ref_priority = clock->priority;
- main_clock->wait_sync_ref = clock_point_Create(now + delay, ts);
- }
- return (ts - main_clock->wait_sync_ref.stream) / rate
- + main_clock->wait_sync_ref.system;
-}
-
static vlc_tick_t vlc_clock_slave_to_system_locked(vlc_clock_t *clock,
vlc_tick_t now,
vlc_tick_t ts, double rate)
{
+ (void) now;
vlc_clock_main_t *main_clock = clock->owner;
if (main_clock->pause_date != VLC_TICK_INVALID)
return INT64_MAX;
vlc_tick_t system = main_stream_to_system(main_clock, ts);
if (system == VLC_TICK_INVALID)
- {
- /* We don't have a master sync point, let's fallback to a monotonic ref
- * point */
- system = vlc_clock_monotonic_to_system_locked(clock, now, ts, rate);
- }
-
+ return VLC_TICK_INVALID;
return system + (clock->delay - main_clock->delay) * rate;
}
@@ -294,15 +250,11 @@ static vlc_tick_t vlc_clock_master_to_system_locked(vlc_clock_t *clock,
vlc_tick_t now,
vlc_tick_t ts, double rate)
{
+ (void) now;
vlc_clock_main_t *main_clock = clock->owner;
vlc_tick_t system = main_stream_to_system(main_clock, ts);
if (system == VLC_TICK_INVALID)
- {
- /* We don't have a master sync point, let's fallback to a monotonic ref
- * point */
- system = vlc_clock_monotonic_to_system_locked(clock, now, ts, rate);
- }
-
+ return VLC_TICK_INVALID;
return system + clock->delay * rate;
}
@@ -336,14 +288,6 @@ static vlc_tick_t vlc_clock_slave_update(vlc_clock_t *clock,
static void vlc_clock_slave_reset(vlc_clock_t *clock)
{
- vlc_clock_main_t *main_clock = clock->owner;
- vlc_mutex_lock(&main_clock->lock);
- main_clock->wait_sync_ref_priority = UINT_MAX;
- main_clock->wait_sync_ref =
- clock_point_Create(VLC_TICK_INVALID, VLC_TICK_INVALID);
-
- vlc_mutex_unlock(&main_clock->lock);
-
vlc_clock_on_update(clock, VLC_TICK_INVALID, VLC_TICK_INVALID, 1.0f, 0, 0);
}
@@ -404,9 +348,7 @@ vlc_clock_main_t *vlc_clock_main_New(void)
main_clock->first_pcr =
clock_point_Create(VLC_TICK_INVALID, VLC_TICK_INVALID);
- main_clock->wait_sync_ref_priority = UINT_MAX;
- main_clock->wait_sync_ref = main_clock->last =
- clock_point_Create(VLC_TICK_INVALID, VLC_TICK_INVALID);
+ main_clock->last = clock_point_Create(VLC_TICK_INVALID, VLC_TICK_INVALID);
main_clock->pause_date = VLC_TICK_INVALID;
main_clock->input_dejitter = DEFAULT_PTS_DELAY;
@@ -441,12 +383,7 @@ void vlc_clock_main_SetFirstPcr(vlc_clock_main_t *main_clock,
{
vlc_mutex_lock(&main_clock->lock);
if (main_clock->first_pcr.system == VLC_TICK_INVALID)
- {
main_clock->first_pcr = clock_point_Create(system_now, ts);
- main_clock->wait_sync_ref_priority = UINT_MAX;
- main_clock->wait_sync_ref =
- clock_point_Create(VLC_TICK_INVALID, VLC_TICK_INVALID);
- }
vlc_mutex_unlock(&main_clock->lock);
}
@@ -488,8 +425,7 @@ void vlc_clock_main_ChangePause(vlc_clock_main_t *main_clock, vlc_tick_t now,
}
if (main_clock->first_pcr.system != VLC_TICK_INVALID)
main_clock->first_pcr.system += delay;
- if (main_clock->wait_sync_ref.system != VLC_TICK_INVALID)
- main_clock->wait_sync_ref.system += delay;
+
main_clock->pause_date = VLC_TICK_INVALID;
vlc_cond_broadcast(&main_clock->cond);
}
@@ -573,7 +509,6 @@ static void vlc_clock_set_slave_callbacks(vlc_clock_t *clock)
}
static vlc_clock_t *vlc_clock_main_Create(vlc_clock_main_t *main_clock,
- unsigned priority,
const struct vlc_clock_cbs *cbs,
void *cbs_data)
{
@@ -585,7 +520,6 @@ static vlc_clock_t *vlc_clock_main_Create(vlc_clock_main_t *main_clock,
clock->delay = 0;
clock->cbs = cbs;
clock->cbs_data = cbs_data;
- clock->priority = priority;
assert(!cbs || cbs->on_update);
return clock;
@@ -595,8 +529,7 @@ vlc_clock_t *vlc_clock_main_CreateMaster(vlc_clock_main_t *main_clock,
const struct vlc_clock_cbs *cbs,
void *cbs_data)
{
- /* The master has always the 0 priority */
- vlc_clock_t *clock = vlc_clock_main_Create(main_clock, 0, cbs, cbs_data);
+ vlc_clock_t *clock = vlc_clock_main_Create(main_clock, cbs, cbs_data);
if (!clock)
return NULL;
@@ -615,8 +548,7 @@ vlc_clock_t *vlc_clock_main_CreateInput(vlc_clock_main_t *main_clock,
const struct vlc_clock_cbs *cbs,
void *cbs_data)
{
- /* The input has always the UINT_MAX priority (the lowest) */
- vlc_clock_t *clock = vlc_clock_main_Create(main_clock, UINT_MAX, cbs, cbs_data);
+ vlc_clock_t *clock = vlc_clock_main_Create(main_clock, cbs, cbs_data);
if (!clock)
return NULL;
@@ -638,25 +570,7 @@ vlc_clock_t *vlc_clock_main_CreateSlave(vlc_clock_main_t *main_clock,
const struct vlc_clock_cbs *cbs,
void *cbs_data)
{
- /* SPU outputs should have lower priority than VIDEO outputs since they
- * necessarily depend on a VIDEO output. This mean that a SPU reference
- * point will always be overridden by AUDIO or VIDEO outputs. Cf.
- * vlc_clock_monotonic_to_system_locked */
- unsigned priority;
- switch (cat)
- {
- case VIDEO_ES:
- case AUDIO_ES:
- priority = 1;
- break;
- case SPU_ES:
- default:
- priority = 2;
- break;
- }
-
- vlc_clock_t *clock = vlc_clock_main_Create(main_clock, priority, cbs,
- cbs_data);
+ vlc_clock_t *clock = vlc_clock_main_Create(main_clock, cbs, cbs_data);
if (!clock)
return NULL;
--
2.30.0
More information about the vlc-devel
mailing list