[vlc-commits] vout: assume/require a window

Rémi Denis-Courmont git at videolan.org
Sun May 20 19:52:03 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 17 21:05:20 2018 +0300| [5563c33a5cf02c9d7adb6bb6e3f6a3994282408c] | committer: Rémi Denis-Courmont

vout: assume/require a window

Since in the worst case, there will be the dummy.

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

 include/vlc_vout_display.h      |  3 +--
 src/video_output/display.c      | 16 ++++++--------
 src/video_output/display.h      |  1 -
 src/video_output/video_output.c | 49 ++++++++++++++++-------------------------
 4 files changed, 27 insertions(+), 42 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 48bf23fab9..eddf15a0da 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -391,8 +391,7 @@ static inline void vout_display_DeleteWindow(vout_display_t *vd)
 
 static inline bool vout_display_IsWindowed(vout_display_t *vd)
 {
-    return vd->cfg->window != NULL
-        && vd->cfg->window->type != VOUT_WINDOW_TYPE_DUMMY;
+    return vd->cfg->window->type != VOUT_WINDOW_TYPE_DUMMY;
 }
 
 /**
diff --git a/src/video_output/display.c b/src/video_output/display.c
index ae347f38f9..4d7362aba5 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -115,10 +115,7 @@ static vout_display_t *vout_display_New(vlc_object_t *obj,
         vd->module = NULL;
     }
 
-    if (cfg->window != NULL)
-        vout_window_SetSize(cfg->window,
-                            cfg->display.width, cfg->display.height);
-
+    vout_window_SetSize(cfg->window, cfg->display.width, cfg->display.height);
     return vd;
 }
 
@@ -636,9 +633,7 @@ static void VoutDisplayEvent(vout_display_t *vd, int event, va_list args)
 
 static void VoutDisplayDelWindow(vout_display_t *vd)
 {
-    vout_display_owner_sys_t *osys = vd->owner.sys;
-
-    vout_DeleteDisplayWindow(osys->vout);
+    (void) vd;
 }
 
 static void VoutDisplayFitWindow(vout_display_t *vd, bool default_size)
@@ -1316,8 +1311,7 @@ static void SplitterClose(vout_display_t *vd)
         vout_window_t *wnd = sys->display[i]->cfg->window;
 
         vout_DeleteDisplay(sys->display[i], NULL);
-        if (wnd != NULL)
-            vout_display_window_Delete(wnd);
+        vout_display_window_Delete(wnd);
     }
     TAB_CLEAN(sys->count, sys->display);
     free(sys->picture);
@@ -1390,6 +1384,10 @@ vout_display_t *vout_NewSplitter(vout_thread_t *vout,
         vout_display_GetDefaultDisplaySize(&cfg.width, &cfg.height,
                                            source, &ostate.cfg);
         ostate.cfg.window = vout_display_window_New(vout, &cfg);
+        if (unlikely(ostate.cfg.window == NULL)) {
+            vout_DeleteDisplay(wrapper, NULL);
+            return NULL;
+        }
 
         vout_display_t *vd = DisplayNew(vout, &output->fmt, &ostate,
                                         output->psz_module ? output->psz_module : module,
diff --git a/src/video_output/display.h b/src/video_output/display.h
index 54d69b3c83..875981e1a9 100644
--- a/src/video_output/display.h
+++ b/src/video_output/display.h
@@ -32,7 +32,6 @@ vout_display_t *vout_NewSplitter(vout_thread_t *vout,
 /* FIXME should not be there */
 void vout_SendDisplayEventMouse(vout_thread_t *, const vlc_mouse_t *);
 
-void vout_DeleteDisplayWindow(vout_thread_t *);
 void vout_SetDisplayWindowSize(vout_thread_t *, unsigned, unsigned);
 
 void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t *);
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index a7e96ce24a..36a4b0a193 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -177,13 +177,17 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
         };
 
         vout_window_t *window = vout_display_window_New(vout, &wcfg);
-        if (window != NULL)
-        {
-            if (var_InheritBool(vout, "video-wallpaper"))
-                vout_window_SetState(window, VOUT_WINDOW_STATE_BELOW);
-            else if (var_InheritBool(vout, "video-on-top"))
-                vout_window_SetState(window, VOUT_WINDOW_STATE_ABOVE);
+        if (unlikely(window == NULL)) {
+            spu_Destroy(vout->p->spu);
+            vlc_object_release(vout);
+            return NULL;
         }
+
+        if (var_InheritBool(vout, "video-wallpaper"))
+            vout_window_SetState(window, VOUT_WINDOW_STATE_BELOW);
+        else if (var_InheritBool(vout, "video-on-top"))
+            vout_window_SetState(window, VOUT_WINDOW_STATE_ABOVE);
+
         vout->p->window = window;
     } else
         vout->p->window = NULL;
@@ -618,14 +622,6 @@ static void VoutGetDisplayCfg(vout_thread_t *vout, vout_display_cfg_t *cfg)
         cfg->align.vertical = VOUT_DISPLAY_ALIGN_BOTTOM;
 }
 
-void vout_DeleteDisplayWindow(vout_thread_t *vout)
-{
-    if (vout->p->window != NULL) {
-        vout_display_window_Delete(vout->p->window);
-        vout->p->window = NULL;
-    }
-}
-
 void vout_SetDisplayWindowSize(vout_thread_t *vout,
                                unsigned width, unsigned height)
 {
@@ -635,12 +631,6 @@ void vout_SetDisplayWindowSize(vout_thread_t *vout,
     /* Request a resize of the window. If it fails, there is nothing to do.
      * If it succeeds, the window will emit a resize event later. */
         vout_window_SetSize(window, width, height);
-    else
-    if (vout->p->display.vd != NULL)
-    /* Force a resize of window-less display. This is not allowed to fail,
-     * although the display is allowed to ignore the size anyway. */
-        /* FIXME: remove this, fix MSW and OS/2 window providers */
-        vout_display_SendEventDisplaySize(vout->p->display.vd, width, height);
 }
 
 /* */
@@ -1352,13 +1342,15 @@ static void ThreadChangeFullscreen(vout_thread_t *vout, bool fullscreen)
 {
     vout_window_t *window = vout->p->window;
 
-    if (window != NULL)
-        vout_window_SetFullScreen(window, fullscreen);
+    if (window == NULL)
+        return; /* splitter! */
+
+    vout_window_SetFullScreen(window, fullscreen);
 #if defined(_WIN32) || defined(__OS2__)
     /* FIXME: remove this event */
     if (vout->p->display.vd != NULL)
         vout_display_SendEventFullscreen(vout->p->display.vd, fullscreen,
-                                         window != NULL);
+                                         true);
 #endif
 }
 
@@ -1366,13 +1358,10 @@ static void ThreadChangeWindowState(vout_thread_t *vout, unsigned state)
 {
     vout_window_t *window = vout->p->window;
 
-    if (window != NULL)
-        vout_window_SetState(window, state);
-#if defined(_WIN32) || defined(__OS2__)
-    else /* FIXME: remove this event */
-    if (vout->p->display.vd != NULL)
-        vout_display_SendWindowState(vout->p->display.vd, state);
-#endif
+    if (window == NULL)
+        return; /* splitter! */
+
+    vout_window_SetState(window, state);
 }
 
 static void ThreadTranslateMouseState(vout_thread_t *vout,



More information about the vlc-commits mailing list