[vlc-devel] [vlc-commits] vout: add vout_Pause

Thomas Guillem thomas at gllm.fr
Sat May 11 16:58:06 CEST 2019



On Sat, May 11, 2019, at 09:13, Rémi Denis-Courmont wrote:
> Le vendredi 10 mai 2019, 10:51:27 EEST Thomas Guillem a écrit :
> > 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.
> 
> What for? AFAICT, that'sexactly what vout_StopDisplay() does already. It just 
> needs to be exposed.

But it will stop the vd plugin. You don't want that when you recycle the same vout (window + vd) in case two video with same chrpma/size are played in a raw. 

> 
> > 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=be5856e51f84237c700
> > > 8c1ea9385be2b0b28d849
> > ---
> > 
> >  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)
> 
> How are accesses to paused synchronized here ?!
> 
> > +        {
> >              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.
> >   *
> > 
> > _______________________________________________
> > vlc-commits mailing list
> > vlc-commits at videolan.org
> > https://mailman.videolan.org/listinfo/vlc-commits
> 
> 
> -- 
> Rémi Denis-Courmont
> 
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list