mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 22:16:22 +00:00
gl/win32: Use g_io_channel_win32_new_messages() instead of our custom GSource
Removes some unneeded code duplication between here and GLib. https://bugzilla.gnome.org/show_bug.cgi?id=797184
This commit is contained in:
parent
55ec47f555
commit
cde4cfe384
6 changed files with 22 additions and 131 deletions
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ typedef struct _GstGLWindowWin32Class GstGLWindowWin32Class;
|
|||
struct _GstGLWindowWin32 {
|
||||
/*< private >*/
|
||||
GstGLWindow parent;
|
||||
|
||||
|
||||
HWND internal_win_id;
|
||||
HWND parent_win_id;
|
||||
HDC device;
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
|
||||
* 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 <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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;
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
|
||||
* 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 <glib-object.h>
|
||||
#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__ */
|
Loading…
Reference in a new issue