[vlc-devel] [PATCH 2/4] video_output: only create a decoder device in vout_GetDevice

Steve Lhomme robux4 at ycbcr.xyz
Mon Jan 13 12:07:32 CET 2020


No need to create it conditionally in EnableWindowLocked().
---
 src/video_output/video_output.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 53c6416a620..5d583dbe0ca 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1998,8 +1998,7 @@ int vout_ChangeSource( vout_thread_t *vout, const video_format_t *original )
     return -1;
 }
 
-static int EnableWindowLocked(vout_thread_t *vout, const video_format_t *original,
-                             vlc_decoder_device **pp_dec_device)
+static int EnableWindowLocked(vout_thread_t *vout, const video_format_t *original)
 {
     vout_thread_sys_t *sys = vout->p;
 
@@ -2027,13 +2026,6 @@ static int EnableWindowLocked(vout_thread_t *vout, const video_format_t *origina
         sys->window_enabled = true;
     } else
         vout_UpdateWindowSizeLocked(vout);
-
-    if (pp_dec_device)
-    {
-        if (sys->dec_device == NULL)
-            sys->dec_device = vlc_decoder_device_Create(&vout->obj, sys->display_cfg.window);
-        *pp_dec_device = sys->dec_device ? vlc_decoder_device_Hold( sys->dec_device ) : NULL;
-    }
     return 0;
 }
 
@@ -2059,7 +2051,7 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
     }
 
     vlc_mutex_lock(&sys->window_lock);
-    if (EnableWindowLocked(vout, &original, NULL) != 0)
+    if (EnableWindowLocked(vout, &original) != 0)
     {
         /* the window was not enabled, nor the display started */
         msg_Err(vout, "failed to enable window");
@@ -2114,7 +2106,10 @@ vlc_decoder_device *vout_GetDevice(const vout_device_configuration_t *cfg)
     VoutFixFormat(&original, cfg->fmt);
 
     vlc_mutex_lock(&sys->window_lock);
-    int res = EnableWindowLocked(cfg->vout, &original, &dec_device);
+    int res = EnableWindowLocked(cfg->vout, &original);
+    if (res == 0 && sys->dec_device == NULL)
+        sys->dec_device = vlc_decoder_device_Create(&cfg->vout->obj, sys->display_cfg.window);
+    dec_device = sys->dec_device ? vlc_decoder_device_Hold( sys->dec_device ) : NULL;
     vlc_mutex_unlock(&sys->window_lock);
     video_format_Clean(&original);
     if (res != 0)
-- 
2.17.1



More information about the vlc-devel mailing list