summaryrefslogtreecommitdiff
path: root/sys/d3dvideosink/d3dhelpers.c
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-11-30 19:53:28 +0200
committerSebastian Dröge <sebastian@centricular.com>2015-12-01 15:08:44 +0200
commit8fb07fa326deb68c2bd13c95d3a67a3f08472fb8 (patch)
tree40a5dd909a4a3e37d0c99bb5f1082122467ae39e /sys/d3dvideosink/d3dhelpers.c
parentc3762420f708399b41628bf65f6ffd0d1f2d8a3a (diff)
downloadgstreamer-plugins-bad-8fb07fa326deb68c2bd13c95d3a67a3f08472fb8.tar.gz
d3dvideosink: Don't try to recreate swapchain while the window is minimized
It will fail and cause the sink to crash. Instead wait until the window is visible again before checking if the swapchain really has to be recreated. https://bugzilla.gnome.org/show_bug.cgi?id=741608
Diffstat (limited to 'sys/d3dvideosink/d3dhelpers.c')
-rw-r--r--sys/d3dvideosink/d3dhelpers.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/sys/d3dvideosink/d3dhelpers.c b/sys/d3dvideosink/d3dhelpers.c
index 4030cd600..5091c0638 100644
--- a/sys/d3dvideosink/d3dhelpers.c
+++ b/sys/d3dvideosink/d3dhelpers.c
@@ -1393,6 +1393,9 @@ d3d_resize_swap_chain (GstD3DVideoSink * sink)
gboolean ret = FALSE;
HRESULT hr;
gboolean need_new = FALSE;
+ int clip_ret;
+ HDC handle_hdc;
+ RECT clip_rectangle;
g_return_val_if_fail (sink != NULL, FALSE);
klass = GST_D3DVIDEOSINK_GET_CLASS (sink);
@@ -1411,6 +1414,16 @@ d3d_resize_swap_chain (GstD3DVideoSink * sink)
CHECK_D3D_DEVICE (klass, sink, end);
CHECK_D3D_SWAPCHAIN (sink, end);
+ handle_hdc = GetDC (sink->d3d.window_handle);
+ clip_ret = GetClipBox (handle_hdc, &clip_rectangle);
+ ReleaseDC (sink->d3d.window_handle, handle_hdc);
+ if (clip_ret == NULLREGION) {
+ GST_DEBUG_OBJECT (sink, "Window is hidden, not resizing swapchain");
+ UNLOCK_CLASS (sink, klass);
+ UNLOCK_SINK (sink);
+ return TRUE;
+ }
+
d3d_get_hwnd_window_size (sink->d3d.window_handle, &w, &h);
ZeroMemory (&d3d_pp, sizeof (d3d_pp));
@@ -2004,7 +2017,12 @@ d3d_wnd_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_SIZE:{
if (proc)
ret = CallWindowProc (proc, hWnd, message, wParam, lParam);
- d3d_resize_swap_chain (sink);
+
+ /* Don't resize if the window is being minimized. Recreating the
+ * swap chain will fail if the window is minimized
+ */
+ if (wParam != SIZE_MINIMIZED)
+ d3d_resize_swap_chain (sink);
goto end;
}
case WM_KEYDOWN: