[vlc-commits] vout: win32: drawable: simplify the known hwnd filling

Steve Lhomme git at videolan.org
Mon May 11 09:14:07 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu May  7 14:04:26 2020 +0200| [c5352fb4f8917199b5acac2840f1de65fb9a6a12] | committer: Steve Lhomme

vout: win32: drawable: simplify the known hwnd filling

No need to reset val to 0/NULL each time.

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

 modules/video_output/drawable.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/modules/video_output/drawable.c b/modules/video_output/drawable.c
index 7417900bc7..ad82afadd9 100644
--- a/modules/video_output/drawable.c
+++ b/modules/video_output/drawable.c
@@ -107,24 +107,20 @@ static int Open(vout_window_t *wnd)
             if (used[n] == val)
             {
                 msg_Warn (wnd, "HWND 0x%p is busy", val);
-                val = 0;
-                goto skip;
+                vlc_mutex_unlock (&serializer);
+                return VLC_EGENERIC;
             }
 
     tab = realloc (used, sizeof (*used) * (n + 2));
-    if (likely(tab != NULL))
-    {
-        used = tab;
-        used[n] = val;
-        used[n + 1] = 0;
+    if (unlikely(tab == NULL)) {
+        vlc_mutex_unlock (&serializer);
+        return VLC_ENOMEM;
     }
-    else
-        val = 0;
-skip:
-    vlc_mutex_unlock (&serializer);
+    used = tab;
+    used[n] = val;
+    used[n + 1] = 0;
 
-    if (val == 0)
-        return VLC_EGENERIC;
+    vlc_mutex_unlock (&serializer);
 
     wnd->type = VOUT_WINDOW_TYPE_HWND;
     wnd->handle.hwnd = (void *)val;



More information about the vlc-commits mailing list