[vlc-devel] [PATCH v4 7/9] core: add the "input" clock source

Thomas Guillem thomas at gllm.fr
Thu Apr 1 14:00:30 UTC 2021


The "--clock-master=input" option (disabled by default) allow to setup
the input_clock_t as the master clock. This will restore the VLC 3.0
behavior and use PCR update points as the clock source. Therefore, audio
and video tracks will be altered to catch-up with the input.
---
 src/clock/clock.h   |  1 +
 src/input/es_out.c  | 16 +++++++++++++++-
 src/libvlc-module.c |  5 ++++-
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/clock/clock.h b/src/clock/clock.h
index e7373391697..f8af2b0c18f 100644
--- a/src/clock/clock.h
+++ b/src/clock/clock.h
@@ -23,6 +23,7 @@
 enum vlc_clock_master_source
 {
     VLC_CLOCK_MASTER_AUDIO = 0,
+    VLC_CLOCK_MASTER_INPUT,
     VLC_CLOCK_MASTER_MONOTONIC,
     VLC_CLOCK_MASTER_DEFAULT = VLC_CLOCK_MASTER_AUDIO,
 };
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 99bfd8aa59a..1bb1b227730 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -284,6 +284,7 @@ clock_source_Inherit(vlc_object_t *obj)
         { "0", VLC_CLOCK_MASTER_AUDIO }, /* legacy option */
         { "1", VLC_CLOCK_MASTER_MONOTONIC }, /* legacy option */
         { "audio", VLC_CLOCK_MASTER_AUDIO },
+        { "input", VLC_CLOCK_MASTER_INPUT },
         { "monotonic", VLC_CLOCK_MASTER_MONOTONIC },
     };
 
@@ -1391,6 +1392,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, input_source_t *source, in
 {
     es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
     input_thread_t    *p_input = p_sys->p_input;
+    input_thread_private_t *priv = input_priv(p_input);
 
     /* Sticky groups will be attached to any existing programs, no need to
      * create one. */
@@ -1419,7 +1421,18 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, input_source_t *source, in
         return NULL;
     }
 
-    p_pgrm->p_input_clock = input_clock_New( NULL, p_sys->rate );
+    vlc_clock_t *p_master_clock = NULL;
+    switch( p_sys->clock_source )
+    {
+        case VLC_CLOCK_MASTER_INPUT:
+            p_pgrm->p_master_clock = p_master_clock =
+                vlc_clock_main_CreateMaster( p_pgrm->p_main_clock, NULL, NULL );
+            break;
+        default:
+            break;
+    }
+
+    p_pgrm->p_input_clock = input_clock_New( p_master_clock, p_sys->rate );
     if( !p_pgrm->p_input_clock )
     {
         vlc_clock_main_Delete( p_pgrm->p_main_clock );
@@ -2207,6 +2220,7 @@ static void EsOutCreateDecoder( es_out_t *out, es_out_id_t *p_es )
             clock_source_cat = AUDIO_ES;
             break;
         case VLC_CLOCK_MASTER_MONOTONIC:
+        case VLC_CLOCK_MASTER_INPUT:
             clock_source_cat = UNKNOWN_ES;
             break;
         default:
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index e073ee27eca..360d6a0d5a2 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -539,9 +539,12 @@ static const char *const screensaver_texts[] = {
 #define CLOCK_MASTER_TEXT N_("Clock master source")
 
 static const char *const ppsz_clock_master_values[] = {
-    "audio", "monotonic",
+    "input", "audio", "monotonic",
 };
 static const char *const ppsz_clock_master_descriptions[] = {
+    N_("All tracks are driven by the input clock, via PCR updates from the "
+        "demuxer. This restore the VLC 3.0 clock behavior: both audio and "
+        "video tracks can be altered to catch up with the input."),
     N_("If an audio track is playing, the audio output will drive the clock"
         "(Fallback to Monotonic if there is no audio tracks)."),
     N_("All tracks are driven by the monotonic clock of the system.")
-- 
2.30.0



More information about the vlc-devel mailing list