[vlc-commits] vout: add vout_Pause

Thomas Guillem git at videolan.org
Fri May 10 09:51:27 CEST 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon May  6 17:45:37 2019 +0200| [be5856e51f84237c7008c1ea9385be2b0b28d849] | committer: Thomas Guillem

vout: add vout_Pause

vout_Pause will clean variables that are used by the current owner (clock,
mouse) and put the vout to sleep. On a Next vout_Request, if the vout is
re-used, vout_Resume will store new owner variables and resume the thread.

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

 src/video_output/video_output.c  | 53 +++++++++++++++++++++++++++++++++++++---
 src/video_output/vout_internal.h |  3 +++
 2 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index ea1d90705a..7751d5f34d 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1274,8 +1274,11 @@ static void vout_FlushUnlocked(vout_thread_t *vout, bool below,
     picture_fifo_Flush(vout->p->decoder_fifo, date, below);
     vout_FilterFlush(vout->p->display);
 
-    vlc_clock_Reset(vout->p->clock);
-    vlc_clock_SetDelay(vout->p->clock, vout->p->delay);
+    if (vout->p->clock)
+    {
+        vlc_clock_Reset(vout->p->clock);
+        vlc_clock_SetDelay(vout->p->clock, vout->p->delay);
+    }
 
     vlc_mutex_lock(&vout->p->spu_lock);
     if (vout->p->spu)
@@ -1606,10 +1609,14 @@ noreturn static void *Thread(void *object)
         } else {
             deadline = VLC_TICK_INVALID;
         }
-        while (!vout_control_Pop(&sys->control, &cmd, deadline)) {
+
+        while (!vout_control_Pop(&sys->control, &cmd, deadline) || sys->paused)
+        {
             int canc = vlc_savecancel();
             ThreadControl(vout, cmd);
             vlc_restorecancel(canc);
+            if (sys->paused)
+                deadline = INT64_MAX;
         }
 
         int canc = vlc_savecancel();
@@ -1658,9 +1665,45 @@ static void vout_StopDisplay(vout_thread_t *vout)
     spu_Detach(sys->spu);
     sys->mouse_event = NULL;
     sys->clock = NULL;
+    sys->paused = false;
     video_format_Clean(&sys->original);
 }
 
+static void vout_Resume(vout_thread_t *vout, const vout_configuration_t *cfg,
+                        input_thread_t *input)
+{
+    vout_thread_sys_t *sys = vout->p;
+
+    vout_control_Hold(&sys->control);
+    assert(sys->paused);
+
+    sys->clock = cfg->clock;
+    if (input != NULL)
+        spu_Attach(sys->spu, input);
+    sys->mouse_event = cfg->mouse_event;
+    sys->mouse_opaque = cfg->mouse_opaque;
+
+    sys->delay = sys->spu_delay = 0;
+    sys->rate = sys->spu_rate = 1.f;
+    sys->delay = sys->spu_delay = 0;
+
+    sys->paused = false;
+    vout_control_Release(&sys->control);
+}
+
+void vout_Pause(vout_thread_t *vout)
+{
+    vout_thread_sys_t *sys = vout->p;
+
+    vout_control_Hold(&sys->control);
+    vout_FlushUnlocked(vout, true, INT64_MAX);
+    vout_FlushSubpictureChannel(vout, -1);
+    sys->mouse_event = NULL;
+    sys->clock = NULL;
+    sys->paused = true;
+    vout_control_Release(&sys->control);
+}
+
 void vout_Stop(vout_thread_t *vout)
 {
     vout_thread_sys_t *sys = vout->p;
@@ -1766,6 +1809,7 @@ vout_thread_t *vout_Create(vlc_object_t *object)
     vlc_mutex_init(&sys->spu_lock);
     sys->spu = spu_Create(vout, vout);
 
+    sys->paused = false;
     vout_control_Init(&sys->control);
 
     sys->title.show     = var_InheritBool(vout, "video-title-show");
@@ -1834,7 +1878,8 @@ int vout_Request(const vout_configuration_t *cfg, input_thread_t *input)
     if (video_format_IsSimilar(&original, &sys->original)) {
         if (cfg->dpb_size <= sys->dpb_size) {
             video_format_Clean(&original);
-            /* It is assumed that the SPU input matches input already. */
+
+            vout_Resume(vout, cfg, input);
             return 0;
         }
         msg_Warn(vout, "DPB need to be increased");
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 295c35d61c..20b220e872 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -74,6 +74,7 @@ struct vout_thread_sys_t
     vlc_tick_t      spu_delay;
 
     /* */
+    bool            paused;
     video_format_t  original;   /* Original format ie coming from the decoder */
     struct {
         struct {
@@ -215,6 +216,8 @@ int vout_Request(const vout_configuration_t *cfg, input_thread_t *input);
  */
 void vout_Stop(vout_thread_t *);
 
+void vout_Pause(vout_thread_t *vout);
+
 /**
  * Destroys a vout.
  *



More information about the vlc-commits mailing list