[vlc-devel] [PATCH 01/10] clock: add vlc_clock_IsMaster

Thomas Guillem thomas at gllm.fr
Tue Mar 19 17:45:16 CET 2019


---
 src/clock/clock.c | 8 ++++++++
 src/clock/clock.h | 5 +++++
 2 files changed, 13 insertions(+)

diff --git a/src/clock/clock.c b/src/clock/clock.c
index 15a6cf68e4..bc8eff55b7 100644
--- a/src/clock/clock.c
+++ b/src/clock/clock.c
@@ -551,6 +551,14 @@ void vlc_clock_main_SetMaster(vlc_clock_main_t *main_clock, vlc_clock_t *clock)
     vlc_mutex_unlock(&main_clock->lock);
 }
 
+bool vlc_clock_IsMaster(vlc_clock_t *clock)
+{
+    vlc_clock_main_t *main_clock = clock->owner;
+    vlc_mutex_lock(&main_clock->lock);
+    bool is_master = main_clock->master == clock;
+    vlc_mutex_unlock(&main_clock->lock);
+    return is_master;
+}
 
 void vlc_clock_Delete(vlc_clock_t *clock)
 {
diff --git a/src/clock/clock.h b/src/clock/clock.h
index 8f281523d8..c11a3d1234 100644
--- a/src/clock/clock.h
+++ b/src/clock/clock.h
@@ -93,6 +93,11 @@ vlc_clock_t *vlc_clock_CreateSlave(const vlc_clock_t *clock);
  */
 void vlc_clock_Delete(vlc_clock_t *clock);
 
+/**
+ * This function returns true if the current clock is the master one
+ */
+bool vlc_clock_IsMaster(vlc_clock_t *clock);
+
 /**
  * This function will update the clock drift and returns the drift
  */
-- 
2.20.1



More information about the vlc-devel mailing list