[vlc-devel] [PATCH 08/14] Move spu_delay to spu and match with spu clocks

Roland Bewick roland.bewick at gmail.com
Sat May 11 08:32:12 CEST 2019


---
 src/video_output/video_output.c     | 9 ++-------
 src/video_output/vout_internal.h    | 3 +--
 src/video_output/vout_subpictures.c | 7 +++++++
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 2b7d707064..1c8747e6d3 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1321,8 +1321,6 @@ static void vout_FlushUnlocked(vout_thread_t *vout, bool below,
     if (vout->p->spu)
     {
         spu_clock_ResetAll(vout->p->spu);
-        /* TODO: Move spu_delay into spu_t and move below logic into ResetAll */
-        /*spu_clock_SetDelay(vout->p->spu, vout->p->spu_delay, clock);*/
     }
     vlc_mutex_unlock(&vout->p->spu_lock);
 }
@@ -1389,7 +1387,6 @@ void vout_ChangeSpuDelay(vout_thread_t *vout, vlc_tick_t delay,
     vlc_mutex_lock(&vout->p->spu_lock);
     if (vout->p->spu)
         spu_clock_SetDelay(vout->p->spu, delay, clock);
-    vout->p->spu_delay = delay;
     vlc_mutex_unlock(&vout->p->spu_lock);
 }
 
@@ -1730,9 +1727,8 @@ static void vout_Resume(vout_thread_t *vout, const vout_configuration_t *cfg,
     sys->mouse_event = cfg->mouse_event;
     sys->mouse_opaque = cfg->mouse_opaque;
 
-    sys->delay = sys->spu_delay = 0;
+    sys->delay = 0;
     sys->rate = sys->spu_rate = 1.f;
-    sys->delay = sys->spu_delay = 0;
 
     sys->paused = false;
     vout_control_Release(&sys->control);
@@ -1994,10 +1990,9 @@ int vout_Request(const vout_configuration_t *cfg, input_thread_t *input)
     } else
         vout_UpdateWindowSize(vout);
 
-    sys->delay = sys->spu_delay = 0;
+    sys->delay = 0;
     sys->rate = sys->spu_rate = 1.f;
     sys->clock = cfg->clock;
-    sys->delay = sys->spu_delay = 0;
 
     vlc_mutex_unlock(&sys->window_lock);
 
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 591dc090c3..d60cf7e19b 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -71,9 +71,8 @@ struct vout_thread_sys_t
 
     vlc_clock_t     *clock;
     float           rate;
-    float           spu_rate;
+    float           spu_rate;  /* TODO: Move to spu_private_t */
     vlc_tick_t      delay;
-    vlc_tick_t      spu_delay;
 
     /* */
     bool            paused;
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index 206b9e74ce..4050e9ea09 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -79,7 +79,9 @@ struct spu_private_t {
     vlc_mutex_t  lock;            /* lock to protect all followings fields */
     input_thread_t *input;
 
+    /* TODO: Extract primary/secondary dependent members to a new object? */
     vlc_clock_t *clocks[SPU_MAX_CLOCKS];  /* one for each selected sub track */
+    vlc_tick_t   delays[SPU_MAX_CLOCKS];   /* delays applied to clocks above */
 
     spu_heap_t   heap;
 
@@ -1437,6 +1439,7 @@ spu_t *spu_Create(vlc_object_t *object, vout_thread_t *vout)
     for (int i = 0; i < SPU_MAX_CLOCKS; i++)
     {
         sys->clocks[i] = NULL;
+        sys->delays[i] = 0;
     }
     sys->text = NULL;
     sys->scale = NULL;
@@ -1580,7 +1583,10 @@ void spu_clock_ResetAll(spu_t *spu)
     for (int i = 0; i < SPU_MAX_CLOCKS; i++)
     {
         if (spu->p->clocks[i])
+        {
             vlc_clock_Reset(spu->p->clocks[i]);
+            vlc_clock_SetDelay(spu->p->clocks[i], spu->p->delays[i]);
+        }
     }
 }
 
@@ -1591,6 +1597,7 @@ void spu_clock_SetDelay(spu_t *spu, vlc_tick_t delay, vlc_clock_t *clock)
         if (spu->p->clocks[i] == clock)
         {
             vlc_clock_SetDelay(spu->p->clocks[i], delay);
+            spu->p->delays[i] = delay;
             return;
         }
     }
-- 
2.11.0



More information about the vlc-devel mailing list