[vlc-devel] [PATCH 32/32] video output: request the vout with a video context

Steve Lhomme robux4 at ycbcr.xyz
Thu Sep 26 16:01:07 CEST 2019


---
 include/vlc_vout_display.h       |  4 ++--
 modules/video_output/splitter.c  |  5 +----
 src/input/decoder.c              |  5 +----
 src/input/resource.c             |  4 ++--
 src/input/resource.h             |  2 +-
 src/video_output/display.c       | 10 ++--------
 src/video_output/video_output.c  |  8 ++++----
 src/video_output/vout_internal.h |  6 +++---
 src/video_output/vout_wrapper.c  |  4 ++--
 9 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 1a6afe0da21..0448a4552e4 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -308,8 +308,8 @@ struct vout_display_t {
  */
 VLC_API
 vout_display_t *vout_display_New(vlc_object_t *, const video_format_t *,
-    const vout_display_cfg_t *, const char *module,
-    vlc_decoder_device *, const vout_display_owner_t *);
+    const vout_display_cfg_t *, vlc_video_context *, const char *module,
+    const vout_display_owner_t *);
 
 /**
  * Destroys a video output display.
diff --git a/modules/video_output/splitter.c b/modules/video_output/splitter.c
index acfe02df5a5..ece83df396d 100644
--- a/modules/video_output/splitter.c
+++ b/modules/video_output/splitter.c
@@ -290,11 +290,8 @@ static int vlc_vidsplit_Open(vout_display_t *vd,
         }
 
         vdcfg.window = part->window;
-        vlc_decoder_device *dec_device = vlc_video_context_HoldDevice(ctx);
         vout_display_t *display = vout_display_New(obj, &output->fmt, &vdcfg,
-                                                   modname, dec_device, NULL);
-        if (dec_device)
-            vlc_decoder_device_Release(dec_device);
+                                                   ctx, modname, NULL);
         if (display == NULL) {
             vout_window_Disable(part->window);
             vout_window_Delete(part->window);
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 234879bc408..75b48e8266d 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -514,10 +514,7 @@ static int ModuleThread_UpdateVideoFormat( decoder_t *p_dec, vlc_video_context *
         .dpb_size = dpb_size + p_dec->i_extra_picture_buffers + 1,
         .mouse_event = MouseEvent, .mouse_opaque = p_dec,
     };
-    vlc_decoder_device *dec_dev = p_owner->vctx ? vlc_video_context_HoldDevice(p_owner->vctx) : NULL;
-    int res = input_resource_GetDisplay( p_owner->p_resource, dec_dev, &cfg);
-    if (dec_dev) vlc_decoder_device_Release(dec_dev);
-    return res;
+    return input_resource_GetDisplay( p_owner->p_resource, p_owner->vctx, &cfg);
 }
 
 static int CreateVoutIfNeeded(struct decoder_owner *p_owner, vout_thread_t **pp_vout, vlc_decoder_device **pp_dec_dev)
diff --git a/src/input/resource.c b/src/input/resource.c
index 0e4f82138c1..e37c9e7024d 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -439,11 +439,11 @@ out:
 }
 
 int input_resource_GetDisplay(input_resource_t *p_resource,
-                              vlc_decoder_device *dec_dev,
+                              vlc_video_context *vctx,
                               const vout_configuration_t *cfg)
 {
     vlc_mutex_lock( &p_resource->lock );
-    if (vout_Request(cfg, dec_dev, p_resource->p_input)) {
+    if (vout_Request(cfg, vctx, p_resource->p_input)) {
         input_resource_PutVoutLocked(p_resource, cfg->vout, false);
         vlc_mutex_unlock(&p_resource->lock);
         return -1;
diff --git a/src/input/resource.h b/src/input/resource.h
index 5cb03e959e8..739597e6bf6 100644
--- a/src/input/resource.h
+++ b/src/input/resource.h
@@ -41,7 +41,7 @@ vout_thread_t *input_resource_GetVoutHoldDevice(input_resource_t *,
                                       const vout_configuration_t *,
                                       enum vlc_vout_order *order,
                                       vlc_decoder_device **);
-int input_resource_GetDisplay(input_resource_t *, vlc_decoder_device *, const vout_configuration_t *);
+int input_resource_GetDisplay(input_resource_t *, vlc_video_context *, const vout_configuration_t *);
 void input_resource_PutVout(input_resource_t *, vout_thread_t *);
 
 /**
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 56245be3b08..735ee9a335b 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -730,8 +730,8 @@ void vout_SetDisplayViewpoint(vout_display_t *vd,
 vout_display_t *vout_display_New(vlc_object_t *parent,
                                  const video_format_t *source,
                                  const vout_display_cfg_t *cfg,
+                                 vlc_video_context *vctx,
                                  const char *module,
-                                 vlc_decoder_device *dec_device,
                                  const vout_display_owner_t *owner)
 {
     vout_display_priv_t *osys = vlc_custom_create(parent, sizeof (*osys),
@@ -770,11 +770,9 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
     if (owner)
         vd->owner = *owner;
 
-    vlc_video_context *fake_vctx = vlc_video_context_Create(dec_device, 0, NULL);
-
     if (vlc_module_load(vd, "vout display", module, module && *module != '\0',
                         vout_display_start, vd, &osys->cfg, &vd->fmt,
-                        fake_vctx) == NULL)
+                        vctx) == NULL)
         goto error;
 
 #if defined(__OS2__)
@@ -796,12 +794,8 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
         video_format_Clean(&vd->fmt);
         goto error;
     }
-    if (fake_vctx)
-        vlc_video_context_Release(fake_vctx);
     return vd;
 error:
-    if (fake_vctx)
-        vlc_video_context_Release(fake_vctx);
     video_format_Clean(&vd->source);
     vlc_object_delete(vd);
     return NULL;
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index ec17ef78703..e9d546cceba 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1489,7 +1489,7 @@ static void ThreadProcessMouseState(vout_thread_t *vout,
         vout->p->mouse_event(m, vout->p->mouse_opaque);
 }
 
-static int vout_Start(vout_thread_t *vout, vlc_decoder_device *dec_dev, const vout_configuration_t *cfg)
+static int vout_Start(vout_thread_t *vout, vlc_video_context *vctx, const vout_configuration_t *cfg)
 {
     vout_thread_sys_t *sys = vout->p;
     assert(!sys->dummy);
@@ -1555,7 +1555,7 @@ static int vout_Start(vout_thread_t *vout, vlc_decoder_device *dec_dev, const vo
     vlc_mutex_lock(&sys->display_lock);
     vlc_mutex_unlock(&sys->window_lock);
 
-    sys->display = vout_OpenWrapper(vout, sys->splitter_name, &dcfg, dec_dev);
+    sys->display = vout_OpenWrapper(vout, sys->splitter_name, &dcfg, vctx);
     if (sys->display == NULL) {
         vlc_mutex_unlock(&sys->display_lock);
         goto error;
@@ -1978,7 +1978,7 @@ static int VoutEnsureEnabledWindow(const vout_configuration_t *cfg)
     return 0;
 }
 
-int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device *dec_dev, input_thread_t *input)
+int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input_thread_t *input)
 {
     vout_thread_t *vout = cfg->vout;
     vout_thread_sys_t *sys = vout->p;
@@ -1993,7 +1993,7 @@ int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device *dec_dev, i
     sys->clock = cfg->clock;
     sys->delay = 0;
 
-    if (vout_Start(vout, dec_dev, cfg))
+    if (vout_Start(vout, vctx, cfg))
     {
         vlc_mutex_lock(&sys->window_lock);
         vout_window_Disable(sys->display_cfg.window);
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 8ece3b9bb17..08d00d58254 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -215,11 +215,11 @@ vlc_decoder_device *vout_GetDevice(const vout_configuration_t *cfg);
  *
  * \param cfg the video configuration requested.
  * \param input used to get attachments for spu filters
- * \param dec_dev pointer to receive the decoder device reference to use with the vout or NULL
+ * \param vctx pointer to the video context to use with the vout or NULL
  * \retval 0 on success
  * \retval -1 on error
  */
-int vout_Request(const vout_configuration_t *cfg, vlc_decoder_device *dec_dev, input_thread_t *input);
+int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input_thread_t *input);
 
 /**
  * Disables a vout.
@@ -267,7 +267,7 @@ void vout_IntfDeinit(vlc_object_t *);
 
 /* */
 vout_display_t *vout_OpenWrapper(vout_thread_t *, const char *,
-                     const vout_display_cfg_t *, vlc_decoder_device *);
+                     const vout_display_cfg_t *, vlc_video_context *);
 void vout_CloseWrapper(vout_thread_t *, vout_display_t *vd);
 
 /* */
diff --git a/src/video_output/vout_wrapper.c b/src/video_output/vout_wrapper.c
index db2d36e67c0..e75b10b1202 100644
--- a/src/video_output/vout_wrapper.c
+++ b/src/video_output/vout_wrapper.c
@@ -56,7 +56,7 @@ static void VoutViewpointMoved(void *sys, const vlc_viewpoint_t *vp)
  *****************************************************************************/
 vout_display_t *vout_OpenWrapper(vout_thread_t *vout,
                      const char *splitter_name, const vout_display_cfg_t *cfg,
-                     vlc_decoder_device *dec_device)
+                     vlc_video_context *vctx)
 {
     vout_thread_sys_t *sys = vout->p;
     vout_display_t *vd;
@@ -74,7 +74,7 @@ vout_display_t *vout_OpenWrapper(vout_thread_t *vout,
         modlist = "splitter,none";
 
     vd = vout_display_New(VLC_OBJECT(vout), &sys->original, cfg,
-                          modlist, sys->dec_device, &owner);
+                          vctx, modlist, &owner);
     free(modlistbuf);
 
     if (vd == NULL)
-- 
2.17.1



More information about the vlc-devel mailing list