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

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


The "--clock-master=auto" option will select the input as the clock
source when the input can't pace (live content), and will fallback to
the "audio" source otherwise (most common case).
---
 src/clock/clock.h   |  4 ++--
 src/input/es_out.c  | 10 +++++++++-
 src/libvlc-module.c |  4 +++-
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/clock/clock.h b/src/clock/clock.h
index f8af2b0c18f..772577616d6 100644
--- a/src/clock/clock.h
+++ b/src/clock/clock.h
@@ -22,10 +22,10 @@
 
 enum vlc_clock_master_source
 {
-    VLC_CLOCK_MASTER_AUDIO = 0,
+    VLC_CLOCK_MASTER_AUTO= 0,
+    VLC_CLOCK_MASTER_AUDIO,
     VLC_CLOCK_MASTER_INPUT,
     VLC_CLOCK_MASTER_MONOTONIC,
-    VLC_CLOCK_MASTER_DEFAULT = VLC_CLOCK_MASTER_AUDIO,
 };
 
 typedef struct vlc_clock_main_t vlc_clock_main_t;
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 1bb1b227730..a209031406d 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 },
+        { "auto", VLC_CLOCK_MASTER_AUTO },
         { "input", VLC_CLOCK_MASTER_INPUT },
         { "monotonic", VLC_CLOCK_MASTER_MONOTONIC },
     };
@@ -302,7 +303,7 @@ clock_source_Inherit(vlc_object_t *obj)
     return entry->val;
 
 default_val:
-    return VLC_CLOCK_MASTER_DEFAULT;
+    return VLC_CLOCK_MASTER_AUTO;
 }
 
 static inline int EsOutGetClosedCaptionsChannel( const es_format_t *p_fmt )
@@ -1424,6 +1425,12 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, input_source_t *source, in
     vlc_clock_t *p_master_clock = NULL;
     switch( p_sys->clock_source )
     {
+        case VLC_CLOCK_MASTER_AUTO:
+            if (priv->b_can_pace_control)
+                break;
+            msg_Dbg( p_input, "The input can't pace, selecting the input (PCR) as the "
+                     "clock source" );
+            /* Fall-through */
         case VLC_CLOCK_MASTER_INPUT:
             p_pgrm->p_master_clock = p_master_clock =
                 vlc_clock_main_CreateMaster( p_pgrm->p_main_clock, NULL, NULL );
@@ -2216,6 +2223,7 @@ static void EsOutCreateDecoder( es_out_t *out, es_out_id_t *p_es )
     enum es_format_category_e clock_source_cat;
     switch( p_sys->clock_source )
     {
+        case VLC_CLOCK_MASTER_AUTO:
         case VLC_CLOCK_MASTER_AUDIO:
             clock_source_cat = AUDIO_ES;
             break;
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 360d6a0d5a2..2f7da3661c6 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -539,9 +539,11 @@ static const char *const screensaver_texts[] = {
 #define CLOCK_MASTER_TEXT N_("Clock master source")
 
 static const char *const ppsz_clock_master_values[] = {
-    "input", "audio", "monotonic",
+    "auto", "input", "audio", "monotonic",
 };
 static const char *const ppsz_clock_master_descriptions[] = {
+    N_("Select the best clock source: input if the access can't be paced (when"
+        "playing live content), or audio otherwise (most likely)"),
     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."),
-- 
2.30.0



More information about the vlc-devel mailing list