[vlc-devel] [PATCH 07/11] kva: fix locking on WinSetWindowPos() sometimes

KO Myung-Hun komh78 at gmail.com
Wed Jan 20 09:49:29 UTC 2021


---
 modules/video_output/kva.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/modules/video_output/kva.c b/modules/video_output/kva.c
index 998a833e5e..38fa658329 100644
--- a/modules/video_output/kva.c
+++ b/modules/video_output/kva.c
@@ -129,6 +129,7 @@ static MRESULT EXPENTRY WndProc       ( HWND, ULONG, MPARAM, MPARAM );
 #define WM_VLC_MANAGE               ( WM_USER + 1 )
 #define WM_VLC_FULLSCREEN_CHANGE    ( WM_USER + 2 )
 #define WM_VLC_SIZE_CHANGE          ( WM_USER + 3 )
+#define WM_VLC_SET_POS              ( WM_USER + 4 )
 
 #define TID_HIDE_MOUSE  0x1010
 
@@ -352,6 +353,10 @@ static int Open ( vout_display_t *vd, const vout_display_cfg_t *cfg,
         return VLC_EGENERIC;
     }
 
+    /* Sometimes WinSetWindowPos() causes locking. To avoid this,
+     * post a message here */
+    WinPostMsg( sys->client, WM_VLC_SET_POS, 0, 0 );
+
     return VLC_SUCCESS;
 }
 
@@ -476,7 +481,6 @@ static int OpenDisplay( vout_display_t *vd, video_format_t *fmt )
     bool b_hw_accel = 0;
     FOURCC i_kva_fourcc;
     int i_chroma_shift;
-    RECTL rcl;
     int w, h;
 
     msg_Dbg( vd, "render chroma = %4.4s", ( const char * )&fmt->i_chroma );
@@ -609,16 +613,6 @@ static int OpenDisplay( vout_display_t *vd, video_format_t *fmt )
         sys->client_rect.yTop    = sys->client_rect.yBottom + h;
     }
 
-    rcl = sys->client_rect;
-
-    WinCalcFrameRect( sys->frame, &rcl, FALSE);
-
-    WinSetWindowPos( sys->frame, HWND_TOP,
-                     rcl.xLeft, rcl.yBottom,
-                     rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom,
-                     SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_SHOW |
-                     SWP_ACTIVATE );
-
     return VLC_SUCCESS;
 }
 
@@ -1089,6 +1083,19 @@ static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
             WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE );
             break;
 
+        /* Set position */
+        case WM_VLC_SET_POS :
+            rcl = sys->client_rect;
+
+            WinCalcFrameRect( sys->frame, &rcl, FALSE);
+
+            WinSetWindowPos( sys->frame, HWND_TOP,
+                             rcl.xLeft, rcl.yBottom,
+                             rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom,
+                             SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_SHOW |
+                             SWP_ACTIVATE );
+            break;
+
         default :
             return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     }
-- 
2.22.0



More information about the vlc-devel mailing list