[vlc-commits] input: handle control with relative audio/spu delays

Thomas Guillem git at videolan.org
Thu Sep 6 16:16:00 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Sep  6 16:15:12 2018 +0200| [c6171b42590ffe75d7aee8f9510e1708f141e42e] | committer: Thomas Guillem

input: handle control with relative audio/spu delays

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

 src/input/input.c          | 14 ++++++++++----
 src/input/input_internal.h |  4 ++++
 src/input/var.c            | 14 ++++++++------
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index f2945a635e..4fcfebcedd 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2082,14 +2082,20 @@ static bool Control( input_thread_t *p_input,
             break;
 
         case INPUT_CONTROL_SET_AUDIO_DELAY:
-            priv->i_audio_delay = param.val.i_int;
-            input_SendEventAudioDelay( p_input, param.val.i_int );
+            if( param.delay.b_absolute )
+                priv->i_audio_delay = param.delay.i_val;
+            else
+                priv->i_audio_delay += param.delay.i_val;
+            input_SendEventAudioDelay( p_input, priv->i_audio_delay );
             UpdatePtsDelay( p_input );
             break;
 
         case INPUT_CONTROL_SET_SPU_DELAY:
-            priv->i_spu_delay = param.val.i_int;
-            input_SendEventSubtitleDelay( p_input, param.val.i_int );
+            if( param.delay.b_absolute )
+                priv->i_spu_delay = param.delay.i_val;
+            else
+                priv->i_spu_delay += param.delay.i_val;
+            input_SendEventSubtitleDelay( p_input, priv->i_spu_delay );
             UpdatePtsDelay( p_input );
             break;
 
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 50e6cbf8fb..6ce7690ef3 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -92,6 +92,10 @@ typedef union
         bool b_absolute;
         float f_val;
     } pos;
+    struct {
+        bool b_absolute;
+        vlc_tick_t i_val;
+    } delay;
 } input_control_param_t;
 
 typedef struct
diff --git a/src/input/var.c b/src/input/var.c
index ad917e1476..6ffa5d878a 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -1057,14 +1057,16 @@ static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
     input_thread_t *p_input = (input_thread_t*)p_this;
     VLC_UNUSED(oldval); VLC_UNUSED(p_data);
 
+    input_control_param_t param = {
+        .delay = {
+            .b_absolute = true,
+            .i_val = newval.i_int,
+        },
+    };
     if( !strcmp( psz_cmd, "audio-delay" ) )
-    {
-        input_ControlPushHelper( p_input, INPUT_CONTROL_SET_AUDIO_DELAY, &newval );
-    }
+        input_ControlPush( p_input, INPUT_CONTROL_SET_AUDIO_DELAY, &param );
     else if( !strcmp( psz_cmd, "spu-delay" ) )
-    {
-        input_ControlPushHelper( p_input, INPUT_CONTROL_SET_SPU_DELAY, &newval );
-    }
+        input_ControlPush( p_input, INPUT_CONTROL_SET_SPU_DELAY, &param );
     return VLC_SUCCESS;
 }
 



More information about the vlc-commits mailing list