[vlc-commits] core: add the "auto" clock source

Thomas Guillem git at videolan.org
Mon Apr 12 07:49:43 UTC 2021


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Apr  1 15:31:49 2021 +0200| [66646d81a4b7b666b59853bd815635e13d83a4a6] | committer: Thomas Guillem

core: add the "auto" clock source

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).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=66646d81a4b7b666b59853bd815635e13d83a4a6
---

 src/clock/clock.h   |  4 ++--
 src/input/es_out.c  | 10 +++++++++-
 src/libvlc-module.c |  3 ++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/clock/clock.h b/src/clock/clock.h
index f8af2b0c18..772577616d 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 1bb1b22773..a209031406 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 0f94c65737..f0dfd1d5e2 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -539,9 +539,10 @@ 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_("Auto"),
     N_("Input (PCR)"),
     N_("Audio"),
     N_("Monotonic")



More information about the vlc-commits mailing list