[vlc-devel] [PATCH V3 08/19] clock: handle forced points
Thomas Guillem
thomas at gllm.fr
Fri Sep 6 17:20:38 CEST 2019
This won't have any effect on the clock but this will forward the forced update
point via the callback.
---
src/clock/clock.c | 10 +++++++++-
src/clock/clock.h | 2 ++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/clock/clock.c b/src/clock/clock.c
index 735a94a8af..e2295a527d 100644
--- a/src/clock/clock.c
+++ b/src/clock/clock.c
@@ -170,6 +170,10 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
vlc_mutex_lock(&main_clock->lock);
+ /* If system_now is INT64_MAX, the update is forced, don't modify anything
+ * but only notify the new clock point. */
+ if (system_now != INT64_MAX)
+ {
if (main_clock->offset != VLC_TICK_INVALID && ts != main_clock->last.stream)
{
/* We have a reference so we can update coeff */
@@ -192,6 +196,7 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
main_clock->rate = rate;
vlc_cond_broadcast(&main_clock->cond);
+ }
original_ts = vlc_clock_main_update_origin(main_clock, original_ts);
vlc_mutex_unlock(&main_clock->lock);
@@ -339,7 +344,10 @@ static vlc_tick_t vlc_clock_slave_update(vlc_clock_t *clock,
vlc_clock_main_t *main_clock = clock->owner;
vlc_mutex_lock(&main_clock->lock);
- vlc_tick_t computed = clock->to_system_locked(clock, system_now, ts, rate);
+ /* If system_now is INT64_MAX, the update is forced, don't modify anything
+ * but only notify the new clock point. */
+ vlc_tick_t computed = system_now == INT64_MAX ? INT64_MAX
+ : clock->to_system_locked(clock, system_now, ts, rate);
ts = vlc_clock_main_update_origin(main_clock, ts);
vlc_mutex_unlock(&main_clock->lock);
diff --git a/src/clock/clock.h b/src/clock/clock.h
index 96b444901f..543d032757 100644
--- a/src/clock/clock.h
+++ b/src/clock/clock.h
@@ -141,6 +141,8 @@ void vlc_clock_Delete(vlc_clock_t *clock);
/**
* This function will update the clock drift and returns the drift
+ * @param system_now valid system time or INT64_MAX is the updated point is
+ * forced (when paused for example)
* @return a valid drift relative time, VLC_TICK_INVALID if there is no drift
* (clock is master) or INT64_MAX if the clock is paused
*/
--
2.20.1
More information about the vlc-devel
mailing list