diff options
author | Haakon Sporsheim <haakon.sporsheim@tandberg.com> | 2008-05-07 15:19:47 +0000 |
---|---|---|
committer | Jan Schmidt <thaytan@noraisin.net> | 2009-05-16 01:29:18 +0100 |
commit | 4e309644e82531028d0dace0715f1803e6bfdaf6 (patch) | |
tree | 01d4374607107e35a5b7832e70155c788c676bcb /sys/directdraw | |
parent | b4633a6930097eb3e48334d67ee62d4ef9ab0a5f (diff) | |
download | gst-plugins-bad-4e309644e82531028d0dace0715f1803e6bfdaf6.tar.gz gst-plugins-bad-4e309644e82531028d0dace0715f1803e6bfdaf6.tar.bz2 gst-plugins-bad-4e309644e82531028d0dace0715f1803e6bfdaf6.zip |
[MOVED FROM GOOD] sys/directdraw/gstdirectdrawsink.c (gst_directdraw_sink_show_frame,
Original commit message from CVS:
patch by: Haakon Sporsheim <haakon.sporsheim at tandberg com>
* sys/directdraw/gstdirectdrawsink.c (gst_directdraw_sink_show_frame,
WndProc, gst_directdraw_sink_window_thread):
Improved Windows message loop and fixed window destruction issue.
When the window which DirectDraw is rendering to is destroyed, the
render/show_frame function will return GST_FLOW_ERROR.
Partially fixes #520885.
Diffstat (limited to 'sys/directdraw')
-rw-r--r-- | sys/directdraw/gstdirectdrawsink.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/sys/directdraw/gstdirectdrawsink.c b/sys/directdraw/gstdirectdrawsink.c index d049c575..a0df1c57 100644 --- a/sys/directdraw/gstdirectdrawsink.c +++ b/sys/directdraw/gstdirectdrawsink.c @@ -810,8 +810,14 @@ gst_directdraw_sink_show_frame (GstBaseSink * bsink, GstBuffer * buf) /* use last buffer */ buf = ddrawsink->last_buffer; } - if (buf == NULL) + + if (buf == NULL) { + GST_ERROR_OBJECT (ddrawsink, "No buffer to render."); + return GST_FLOW_ERROR; + } else if (!ddrawsink->video_window) { + GST_WARNING_OBJECT (ddrawsink, "No video window to render to."); return GST_FLOW_ERROR; + } /* get the video window position */ GST_OBJECT_LOCK (ddrawsink); @@ -1314,13 +1320,13 @@ WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_ERASEBKGND: return TRUE; - case WM_DESTROY: - PostQuitMessage (0); - break; case WM_CLOSE: DestroyWindow (hWnd); + case WM_DESTROY: + PostQuitMessage (0); return 0; } + return DefWindowProc (hWnd, message, wParam, lParam); } @@ -1328,6 +1334,7 @@ static gpointer gst_directdraw_sink_window_thread (GstDirectDrawSink * ddrawsink) { WNDCLASS WndClass; + MSG msg; memset (&WndClass, 0, sizeof (WNDCLASS)); WndClass.style = CS_HREDRAW | CS_VREDRAW; @@ -1357,24 +1364,21 @@ gst_directdraw_sink_window_thread (GstDirectDrawSink * ddrawsink) ReleaseSemaphore (ddrawsink->window_created_signal, 1, NULL); /* start message loop processing our default window messages */ - while (1) { - MSG msg; - - if (GetMessage (&msg, ddrawsink->video_window, 0, 0) <= 0) { - GST_CAT_LOG_OBJECT (directdrawsink_debug, ddrawsink, - "our window received WM_QUIT or error."); - /* The window could have changed, if it is not ours anymore we don't - * overwrite the current video window with NULL */ - if (ddrawsink->our_video_window) { - GST_OBJECT_LOCK (ddrawsink); - ddrawsink->video_window = NULL; - GST_OBJECT_UNLOCK (ddrawsink); - } - break; - } + while (GetMessage (&msg, NULL, 0, 0) != FALSE) { + TranslateMessage (&msg); DispatchMessage (&msg); } + GST_CAT_LOG_OBJECT (directdrawsink_debug, ddrawsink, + "our window received WM_QUIT or error."); + /* The window could have changed, if it is not ours anymore we don't + * overwrite the current video window with NULL */ + if (ddrawsink->our_video_window) { + GST_OBJECT_LOCK (ddrawsink); + ddrawsink->video_window = NULL; + GST_OBJECT_UNLOCK (ddrawsink); + } + return NULL; } |