diff --git a/gst-libs/gst/gl/meson.build b/gst-libs/gst/gl/meson.build index b08e4d417d..ab82067cbf 100644 --- a/gst-libs/gst/gl/meson.build +++ b/gst-libs/gst/gl/meson.build @@ -636,7 +636,6 @@ if need_platform_wgl != 'no' and need_win_win32 != 'no' gl_includes += [compat_includes] gl_platform_deps += gdi_dep gl_sources += [ - 'win32/win32_message_source.c', 'win32/gstglwindow_win32.c', 'win32/gstglwindow_win32.c', 'win32/gstglcontext_wgl.c', diff --git a/gst-libs/gst/gl/win32/Makefile.am b/gst-libs/gst/gl/win32/Makefile.am index ed3cc6320d..1c4a07cd9d 100644 --- a/gst-libs/gst/gl/win32/Makefile.am +++ b/gst-libs/gst/gl/win32/Makefile.am @@ -3,12 +3,10 @@ noinst_LTLIBRARIES = libgstgl-win32.la libgstgl_win32_la_SOURCES = \ - gstglwindow_win32.c \ - win32_message_source.c + gstglwindow_win32.c noinst_HEADERS = \ - gstglwindow_win32.h \ - win32_message_source.h + gstglwindow_win32.h if USE_WGL libgstgl_win32_la_SOURCES += gstglcontext_wgl.c diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32.c b/gst-libs/gst/gl/win32/gstglwindow_win32.c index bbaa7b0830..67fc0b6bf3 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32.c +++ b/gst-libs/gst/gl/win32/gstglwindow_win32.c @@ -24,7 +24,6 @@ #endif #include "gstglwindow_win32.h" -#include "win32_message_source.h" LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); @@ -40,6 +39,7 @@ struct _GstGLWindowWin32Private { gint preferred_width; gint preferred_height; + GIOChannel *msg_io_channel; }; #define GST_CAT_DEFAULT gst_gl_window_win32_debug @@ -101,12 +101,19 @@ gst_gl_window_win32_new (GstGLDisplay * display) return window; } -static void -msg_cb (GstGLWindowWin32 * window_win32, MSG * msg, gpointer user_data) +static gboolean +msg_cb (GIOChannel * source, GIOCondition condition, gpointer data) { + MSG msg; + + if (!PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) + return G_SOURCE_CONTINUE; + GST_TRACE ("handle message"); - TranslateMessage (msg); - DispatchMessage (msg); + TranslateMessage (&msg); + DispatchMessage (&msg); + + return G_SOURCE_CONTINUE; } gboolean @@ -117,9 +124,11 @@ gst_gl_window_win32_open (GstGLWindow * window, GError ** error) if (!GST_GL_WINDOW_CLASS (parent_class)->open (window, error)) return FALSE; - window_win32->msg_source = win32_message_source_new (window_win32); - g_source_set_callback (window_win32->msg_source, (GSourceFunc) msg_cb, - NULL, NULL); + window_win32->priv->msg_io_channel = g_io_channel_win32_new_messages (0); + window_win32->msg_source = + g_io_create_watch (window_win32->priv->msg_io_channel, G_IO_IN); + g_source_set_callback (window_win32->msg_source, (GSourceFunc) msg_cb, NULL, + NULL); g_source_attach (window_win32->msg_source, window->main_context); return TRUE; @@ -145,6 +154,8 @@ gst_gl_window_win32_close (GstGLWindow * window) g_source_destroy (window_win32->msg_source); g_source_unref (window_win32->msg_source); window_win32->msg_source = NULL; + g_io_channel_unref (window_win32->priv->msg_io_channel); + window_win32->priv->msg_io_channel = NULL; GST_GL_WINDOW_CLASS (parent_class)->close (window); } diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32.h b/gst-libs/gst/gl/win32/gstglwindow_win32.h index 8a6ca68248..485333c08e 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32.h +++ b/gst-libs/gst/gl/win32/gstglwindow_win32.h @@ -43,7 +43,7 @@ typedef struct _GstGLWindowWin32Class GstGLWindowWin32Class; struct _GstGLWindowWin32 { /*< private >*/ GstGLWindow parent; - + HWND internal_win_id; HWND parent_win_id; HDC device; diff --git a/gst-libs/gst/gl/win32/win32_message_source.c b/gst-libs/gst/gl/win32/win32_message_source.c deleted file mode 100644 index fd785f8278..0000000000 --- a/gst-libs/gst/gl/win32/win32_message_source.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2012 Matthew Waters - * Copyright (C) 2015 Collabora ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include "win32_message_source.h" - -typedef struct _Win32MessageSource -{ - GSource source; - GPollFD pfd; - GstGLWindowWin32 *window; -} Win32MessageSource; - -static gboolean -win32_message_source_check (GSource * base) -{ - MSG msg; - - return PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE); -} - -static gboolean -win32_message_source_dispatch (GSource * base, GSourceFunc callback, - gpointer user_data) -{ - Win32MessageSource *source = (Win32MessageSource *) base; - Win32MessageSourceFunc func = (Win32MessageSourceFunc) callback; - MSG msg; - - if (!PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) - return G_SOURCE_CONTINUE; - - if (func) - func (source->window, &msg, user_data); - - return G_SOURCE_CONTINUE; -} - -static GSourceFuncs win32_message_source_funcs = { - NULL, - win32_message_source_check, - win32_message_source_dispatch, - NULL -}; - -GSource * -win32_message_source_new (GstGLWindowWin32 * window_win32) -{ - Win32MessageSource *source; - - source = (Win32MessageSource *) - g_source_new (&win32_message_source_funcs, sizeof (Win32MessageSource)); - source->window = window_win32; - source->pfd.fd = G_WIN32_MSG_HANDLE; - source->pfd.events = G_IO_IN; - g_source_add_poll (&source->source, &source->pfd); - - return &source->source; -} diff --git a/gst-libs/gst/gl/win32/win32_message_source.h b/gst-libs/gst/gl/win32/win32_message_source.h deleted file mode 100644 index eef3eac4d4..0000000000 --- a/gst-libs/gst/gl/win32/win32_message_source.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2012 Matthew Waters - * Copyright (C) 2015 Collabora ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __WIN32_MESSAGE_SOURCE_H__ -#define __WIN32_MESSAGE_SOURCE_H__ - -#include -#include "gstglwindow_win32.h" - -typedef void (*Win32MessageSourceFunc) (GstGLWindowWin32 *window_win32, - MSG *msg, gpointer user_data); - -GSource * -win32_message_source_new (GstGLWindowWin32 *window_win32); - -#endif /* __WIN32_MESSAGE_SOURCE_H__ */