[vlc-commits] [Git][videolan/vlc][master] 3 commits: wgl: signal what happened on MakeCurrent error
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Oct 22 06:27:56 UTC 2021
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
550cd559 by Alexandre Janniaux at 2021-10-22T05:17:12+00:00
wgl: signal what happened on MakeCurrent error
When MakeCurrent fails, there was not much information. Since it can
fails in location where we want to release OpenGL resources, it was hard
to track it down to a wgl failure.
In case of failure, this patch details the last error message available.
- - - - -
03d997b1 by Alexandre Janniaux at 2021-10-22T05:17:12+00:00
wgl: fix failing wglMakeCurrent
The context and original HDC is from the decoder thread. Close() is
called from the vout_thread when the vout is being stopped.
This leads to one of the following error when stopping the media player:
- error 2004: The requested transformation operation is not supported.
- error 6: The handle is invalid
Those errors means that either the hDC is still in use in another thread
or that the hDC is not valid anymore.
Since this was happening on Close(), there was no way to make it fail
gracefully.
Getting a new DC when making the context current, thus in the closing
thread too, fix the error by ensuring thread-safety with those objects.
- - - - -
d5102812 by Alexandre Janniaux at 2021-10-22T05:17:12+00:00
wgl: ensure context is not current
...after checking GPU affinity.
- - - - -
1 changed file:
- modules/video_output/win32/wgl.c
Changes:
=====================================
modules/video_output/win32/wgl.c
=====================================
@@ -106,6 +106,7 @@ static void CreateGPUAffinityDC(vlc_gl_t *gl, UINT nVidiaAffinity) {
PFNWGLCREATEAFFINITYDCNVPROC fncCreateAffinityDCNV = (PFNWGLCREATEAFFINITYDCNVPROC)wglGetProcAddress("wglCreateAffinityDCNV");
/* delete the temporary GL context */
+ wglMakeCurrent(NULL, NULL);
wglDeleteContext(hGLRC);
/* see if we have the extensions */
@@ -146,6 +147,7 @@ static void DestroyGPUAffinityDC(vlc_gl_t *gl) {
PFNWGLDELETEDCNVPROC fncDeleteDCNV = (PFNWGLDELETEDCNVPROC)wglGetProcAddress("wglDeleteDCNV");
/* delete the temporary GL context */
+ wglMakeCurrent(NULL, NULL);
wglDeleteContext(hGLRC);
/* see if we have the extensions */
@@ -289,14 +291,33 @@ static void *OurGetProcAddress(vlc_gl_t *gl, const char *name)
static int MakeCurrent(vlc_gl_t *gl)
{
vout_display_sys_t *sys = gl->sys;
- bool success = wglMakeCurrent(sys->hGLDC, sys->hGLRC);
- return success ? VLC_SUCCESS : VLC_EGENERIC;
+
+ /* After painting with a common DC, the ReleaseDC function must be called
+ * to release the DC. Class and private DCs do not have to be released.
+ * ReleaseDC must be called from the same thread that called GetDC. The
+ * number of DCs is limited only by available memory. */
+
+ HDC winDC = GetDC(sys->hvideownd);
+ assert(winDC != NULL);
+
+ bool success = wglMakeCurrent(winDC, sys->hGLRC);
+ ReleaseDC(sys->hvideownd, winDC);
+
+ if (likely(success))
+ return VLC_SUCCESS;
+
+ /* vlc_gl_MakeCurrent should never fail. */
+
+ DWORD dw = GetLastError();
+ msg_Err(gl, "Cannot make wgl current, error %lx", dw);
+
+ return VLC_EGENERIC;
}
static void ReleaseCurrent(vlc_gl_t *gl)
{
vout_display_sys_t *sys = gl->sys;
- wglMakeCurrent (sys->hGLDC, NULL);
+ wglMakeCurrent(NULL, NULL);
}
static const char *GetExtensionsString(vlc_gl_t *gl)
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/858640bbef133997031308b4bfa7a46b29992dee...d5102812dab5e94b1c8da2b71faf8db7601063d3
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/858640bbef133997031308b4bfa7a46b29992dee...d5102812dab5e94b1c8da2b71faf8db7601063d3
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list