[vlc-devel] [PATCH 2/6] clock: store the full list of clocks on the main one
Thomas Guillem
thomas at gllm.fr
Thu Sep 26 16:38:10 CEST 2019
This will be used by the next commit.
---
src/clock/clock.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/clock/clock.c b/src/clock/clock.c
index d1fa1848d0..a2fd968d15 100644
--- a/src/clock/clock.c
+++ b/src/clock/clock.c
@@ -23,6 +23,7 @@
#include <vlc_common.h>
#include <vlc_aout.h>
+#include <vlc_list.h>
#include <assert.h>
#include "clock.h"
#include "clock_internal.h"
@@ -33,6 +34,7 @@ struct vlc_clock_main_t
vlc_cond_t cond;
vlc_clock_t *master;
+ struct vlc_list slaves;
unsigned rc;
@@ -72,6 +74,7 @@ struct vlc_clock_t
const struct vlc_clock_cbs *cbs;
void *cbs_data;
+ struct vlc_list node;
};
static vlc_tick_t main_stream_to_system(vlc_clock_main_t *main_clock,
@@ -390,6 +393,8 @@ vlc_clock_main_t *vlc_clock_main_New(void)
main_clock->output_dejitter = AOUT_MAX_PTS_ADVANCE * 2;
main_clock->abort = false;
+ vlc_list_init(&main_clock->slaves);
+
AvgInit(&main_clock->coeff_avg, 10);
return main_clock;
@@ -469,6 +474,7 @@ void vlc_clock_main_Delete(vlc_clock_main_t *main_clock)
vlc_mutex_destroy(&main_clock->lock);
vlc_cond_destroy(&main_clock->cond);
assert(main_clock->rc == 1);
+ assert(vlc_list_is_empty(&main_clock->slaves));
free(main_clock);
}
@@ -590,6 +596,7 @@ vlc_clock_t *vlc_clock_main_CreateSlave(vlc_clock_main_t *main_clock,
vlc_mutex_lock(&main_clock->lock);
vlc_clock_set_slave_callbacks(clock);
main_clock->rc++;
+ vlc_list_append(&clock->node, &main_clock->slaves);
vlc_mutex_unlock(&main_clock->lock);
return clock;
@@ -623,6 +630,8 @@ void vlc_clock_Delete(vlc_clock_t *clock)
vlc_clock_main_reset(main_clock);
main_clock->master = NULL;
}
+ else
+ vlc_list_remove(&clock->node);
main_clock->rc--;
vlc_mutex_unlock(&main_clock->lock);
free(clock);
--
2.20.1
More information about the vlc-devel
mailing list