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

Steve Lhomme robux4 at ycbcr.xyz
Tue Oct 1 13:24:20 CEST 2019


instead of the decoder device
---
 include/vlc_vout_display.h             |  5 +++--
 modules/video_output/splitter.c        |  7 ++-----
 modules/video_output/win32/direct3d9.c |  6 +++++-
 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        |  6 +++---
 10 files changed, 26 insertions(+), 33 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 1a6afe0da21..ed89eb56d22 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -307,9 +307,10 @@ struct vout_display_t {
  * Creates video output display.
  */
 VLC_API
-vout_display_t *vout_display_New(vlc_object_t *, const video_format_t *,
+vout_display_t *vout_display_New(vlc_object_t *,
+    const video_format_t *, vlc_video_context *,
     const vout_display_cfg_t *, const char *module,
-    vlc_decoder_device *, const vout_display_owner_t *);
+    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..8d6532ceb49 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);
+        vout_display_t *display = vout_display_New(obj, &output->fmt, ctx, &vdcfg,
+                                                   modname, NULL);
         if (display == NULL) {
             vout_window_Disable(part->window);
             vout_window_Delete(part->window);
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 05b38a10e01..a99bfce6d41 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -1664,8 +1664,12 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
     if (d3d9_decoder != NULL && d3d9_decoder->device != NULL)
         D3D9_CloneExternal( &sys->hd3d, d3d9_decoder->device );
 
+    d3d9_video_context_t *octx = GetD3D9ContextPrivate(context);
     HRESULT hr;
-    hr = D3D9_CreateDevice(vd, &sys->hd3d, d3d9_decoder ? d3d9_decoder->adapter : -1, &sys->d3d_dev);
+    if (octx != NULL)
+        hr = D3D9_CreateDeviceExternal(octx->dev, &sys->hd3d, &sys->d3d_dev);
+    else
+        hr = D3D9_CreateDevice(vd, &sys->hd3d, d3d9_decoder ? d3d9_decoder->adapter : -1, &sys->d3d_dev);
 
     if (FAILED(hr)) {
         msg_Err( vd, "D3D9 Creation failed! (hr=0x%lX)", hr);
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 9d0559df977..ecbfb2e0bb7 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -512,10 +512,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(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, 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 f9fb3d0e7c2..556406f7c6d 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -729,9 +729,9 @@ void vout_SetDisplayViewpoint(vout_display_t *vd,
 
 vout_display_t *vout_display_New(vlc_object_t *parent,
                                  const video_format_t *source,
+                                 vlc_video_context *vctx,
                                  const vout_display_cfg_t *cfg,
                                  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, VLC_VIDEO_CONTEXT_NONE, 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 b0a63fb6754..170c8486ce1 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1488,7 +1488,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);
@@ -1554,7 +1554,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 713751c26d7..74c29166066 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..48e1ad8a88a 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;
@@ -73,8 +73,8 @@ vout_display_t *vout_OpenWrapper(vout_thread_t *vout,
     else
         modlist = "splitter,none";
 
-    vd = vout_display_New(VLC_OBJECT(vout), &sys->original, cfg,
-                          modlist, sys->dec_device, &owner);
+    vd = vout_display_New(VLC_OBJECT(vout), &sys->original, vctx, cfg,
+                          modlist, &owner);
     free(modlistbuf);
 
     if (vd == NULL)
-- 
2.17.1



More information about the vlc-devel mailing list