Commit graph

73 commits

Author SHA1 Message Date
Matthew Waters
126ee924c0 glwindow: don't use g_thread_join() to join the navigation thread
Using g_thread_join() in _finalize() handlers may result in a deadlock
joining the current thread when the last reference is held by a signal
handler.

e.g.:

error 'Resource deadlock avoided' during 'pthread_join (pt->system_thread, NULL)'

The backtrace looks like this:
[...]
g_thread_join ()
gst_gl_window_finalize ()
gst_gl_window_x11_finalize ()
g_object_unref ()
g_value_unset ()
g_signal_emit_valist ()
g_signal_emit ()
gst_gl_window_send_mouse_event ()
gst_gl_window_mouse_event_cb ()
g_main_dispatch ()
[..]
g_main_loop_run ()
gst_gl_window_navigation_thread ()
g_thread_proxy ()
start_thread ()
clone ()
2017-12-09 19:32:23 +00:00
Matthew Waters
792299d9ae glwindow: marshal gst_gl_window_resize through the window loop
saves having every caller do it themselves.
2017-12-09 19:32:22 +00:00
Matthew Waters
85d5489f58 glwindow: move unsetting queue_resize to _resize() instead of _draw()
Makes infinitely more sense and implementation were expecting that behaviour
anyway and would enter a resize, draw, resize, draw, ... cycle instead of only
resizing once.
2017-12-09 19:32:21 +00:00
Alessandro Decina
3d124f498a glwindow: reduce the number of GMutexes and GConds in send_message()
Don't create many short lived locks/conds in gst_gl_window_send_message. This is
a micro optimization to save a bunch of pthread_* calls which are expensive on
OSX/iOS and possibly other platforms.
2017-12-09 19:32:19 +00:00
Julien Isorce
f2cfa7fb51 gstglwindow: initialize navigation_loop to NULL
Useful when gst_gl_window.c::gst_gl_window_new is not used.
This is the case when using a custom GstGLWindow.
(ex: GstGLWindowGPUProcess from Chromium)
2017-12-09 19:32:16 +00:00
Sebastian Dröge
1403a6871f glwindow: Hide navigation specific internal API and add API to asynchronously send navigation events
Exposing the navigation thread's main context, GSourceFuncs and structs called
key_event and mouse_event is exposing a bit too much of the internals. Let's
just go with two functions to asynchronously send navigation events on the
window with the same API as the synchronous ones.
2017-12-09 19:32:13 +00:00
Sebastian Dröge
8b00b1347e glwindow: Use g_thread_join() instead of a custom condition variable for waiting for the navigation thread to finish
Also hide some internal functions and fields while we're at it and fix
a race condition with the startup condition variable.
2017-12-09 19:32:13 +00:00
Haihua Hu
9fcf5500b2 glwindow: Fix memory leak of navigation thread
When stopping the navigation thread, call g_thread_join() to release
the resources hold by it.

https://bugzilla.gnome.org/show_bug.cgi?id=758820
2017-12-09 19:32:13 +00:00
Matthew Waters
06de6998e5 gl: be consistent in gobject boilerpate
GST_GL_IS_* vs GST_IS_GL_*

git grep -l 'GST_GL_IS_' | xargs sed -i 's/GST_GL_IS_/GST_IS_GL_/g'
2017-12-09 19:32:09 +00:00
Matthew Waters
e9864e2e3e glwindow: remove unused draw_unlocked function
The functionality is provided by draw anyway and is leftover from
X11's specific threading requirements that no longer apply.
2017-12-09 19:32:08 +00:00
Jan Schmidt
6b67fdf2ef glwindow: Fix g_return_val_if_fail in a void function 2017-12-09 19:32:08 +00:00
Matthew Waters
63bbe9406a glwindow: add API to request a resize event on the next draw
- glimagesink needs to be able to resize the viewport on aspect ratio
  changes resulting from either caps changes or 3d output mode changes.
- Performing a glViewport outside the GstGLWindow::resize callback
  will not have the winsys' stack of viewports required to correctly
  place the output frame.

Provide a function to request a resize on the next draw event from the
winsys.

Also track size changes inside the base GstGLWindow class rather
than in each subclass.

https://bugzilla.gnome.org/show_bug.cgi?id=755111
2017-12-09 19:32:08 +00:00
Matthew Waters
6ccaafc0f3 glwindow: pass display to implementation's _new()
So they have to opportunity to fail if they cannot handle the
display connection.

https://bugzilla.gnome.org/show_bug.cgi?id=752743
2017-12-09 19:32:07 +00:00
Julien Isorce
210d2c2825 glwindow: move main loop/context creation back to init/finalize
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=750199
2017-12-09 19:32:03 +00:00
Matthew Waters
fea0b65eb5 glwindow: fix compiler error
gstglwindow.c:1118:544: error: 'return' with no value, in function returning non-void [-Werror]
   g_return_if_fail (GST_GL_IS_WINDOW (window));
2017-12-09 19:32:03 +00:00
Matthew Waters
6c56aba687 glwindow: handle gst_video_overlay_set_render_rectangle 2017-12-09 19:32:03 +00:00
Julien Isorce
2efeb71c83 glwindow_x11: use parent default implementation 2017-12-09 19:32:02 +00:00
Julien Isorce
01961ec44d glwindow: initialize debug in class_init
Useful if one uses gst_gl_window_x11_new directly
instead of gst_gl_window_new.
2017-12-09 19:32:02 +00:00
Julien Isorce
2472bcaaa6 glwindow: provides some default implementations to factorize with all backends 2017-12-09 19:32:02 +00:00
Matthew Waters
6445569abf glwindow: track context activation properly
We only need to deactivate/reactivate the context iff it was already
active.
2017-12-09 19:31:59 +00:00
Julien Isorce
0142f551f8 glwindow: remove unused gl_thread field 2017-12-09 19:31:58 +00:00
Edward Hervey
961e847433 gl: Fix context leaks
Introduced by a12ca13750
2017-12-09 19:31:56 +00:00
Edward Hervey
081f101f56 glwindow: Deactivate window before changing handle
When setting a new window handle, we need to ensure all implementations
will detect the change.

For that we deactivate the context before setting the window handle, then
reactivate the context

https://bugzilla.gnome.org/show_bug.cgi?id=745090
2017-12-09 19:31:55 +00:00
Sebastian Dröge
c4e75844a8 glwindow: Remove assertion in gst_gl_window_show() for subclasses not implementing it
On Android and iOS we can't create a window ourselves, so also can't just show
one. That's not a problem and an assertion is not really needed here.
2017-12-09 19:31:54 +00:00
Matthew Waters
598715fc4b glwindow: make showing a window explicit
Also fixes the cgl context always displaying a window to render to for
every GstGLContextCocoa created
2017-12-09 19:31:53 +00:00
Matthew Waters
019367c128 glwindow: remove width/height from _draw()
Depending on the platform, it was only ever implemented to 1) set a
default surface size, 2) resize based on the video frame or 3) nothing.
Instead, provide a set_preferred_size () that elements/applications
can use to request a certain size which may be ignored for
videooverlay/other cases.
2017-12-09 19:31:53 +00:00
Hyunjun Ko
db6ea1b3bd gl: Correct invalid comment text 2017-12-09 19:31:49 +00:00
Julien Isorce
af59b771fd gl: do not raise a critical msg if the backend does not handle window events
Fix "assertion 'window_class->handle_events != NULL' failed"
if not using a X11 window.
2017-12-09 19:31:49 +00:00
Lubosz Sarnecki
64dd17bde6 glimagesink: implement gst_video_overlay_handle_events
https://bugzilla.gnome.org/show_bug.cgi?id=736035
2017-12-09 19:31:49 +00:00
Tim-Philipp Müller
653c04b121 gl: fix Since marker for gst_gl_window_run_navigation() 2017-12-09 19:31:49 +00:00
Matthew Waters
35e9b5ab8b gl: sprinkle some Since markers 2017-12-09 19:31:49 +00:00
Vasilis Liaskovitis
f803a9e746 GstGLWindow: Introduce navigation thread
This thread dispatches navigation events. It is needed to avoid deadlocks
between window backend threads that emit navigation events (e.g. X11/GMainLoop
thread) and consumers of navigation events such as glimagesink, see
https://bugzilla.gnome.org/show_bug.cgi?id=733661

GstGlWindow_x11 thread is changed to invoke the navigation thread for navigation
dispatching, instead of emiting the event itself. Othe backends beside X11 do
not dispatch navigation events yet, but should use this thread when dispatching
these events in the future.

The navigation thread is currently part of GstGLWindow and not implemented in
separate subclasses / backends. This will be needed in the future.

gst_gl_window_x11_get_surface_dimensions is also changed to use a cached value
of the window's width, height. These values are now retrieved in the X11
thread, function gst_gl_window_x11_handle_event. This change is needed because
otherwise the XGetWindowAttributes gets called from the navigation thread,
leading to xlib aborting due to multithreaded access (if XInitThreads is not
called before, as is the case for gst-launch)
2017-12-09 19:31:46 +00:00
Vasilis Liaskovitis
7b1a853888 GstGLWindow, GstGLImagesink, x11: Scale navigation events on resized windows
If window is resized, GstStructure pointer values have to be rescaled to
original geometry. A get_surface_dimensions GLWindow class method is added for
this purpose and used in the navigation send_event function.

https://bugzilla.gnome.org/show_bug.cgi?id=703486
2017-12-09 19:31:45 +00:00
Sebastian Dröge
307db954fd glwindow: Constify string parameters to the send_*_event() functions 2017-12-09 19:31:44 +00:00
Vasilis Liaskovitis
6b38d58427 GstGLWindow : Add mouse-event and key-event signals for navigation
https://bugzilla.gnome.org/show_bug.cgi?id=703486
2017-12-09 19:31:44 +00:00
Matthew Waters
4a8b31afd6 glfeature: remove GST_GL_API_GLES3
instead check the gl version using gst_gl_context_check_gl_version()
2017-12-09 19:31:42 +00:00
Matthew Waters
857200ff40 gl: make all GObjects inherit from GstObject
Aids memory leak debugging with GST_TRACE=mem-live
2017-12-09 19:31:39 +00:00
Matthew Waters
6a2f2088e9 gl/window: fix string length check for eagl 2017-12-09 19:31:39 +00:00
Sebastian Dröge
3770d2a406 gl: Add support for iOS EAGL platform
https://bugzilla.gnome.org/show_bug.cgi?id=703341
2017-12-09 19:31:36 +00:00
Matthew Waters
1af7847fdc gl/window: add a dummy window class
Effective for the case where we have a platform that does not
require a native window.  We require a mainloop to run the GL
commands which is currently operated by GstGLWindow.
2017-12-09 19:31:34 +00:00
Matthew Waters
303b77eeff [890/906] x11: add display subclass
GstGLDisplayX11 holds the display connection and name.  Each thread requires
it's own X11 Display connection (initialised from name) due to the fact that
we do not want to call XInitThreads().  Doing so would result in segfaults
when integrating with GUI toolkits Gtk, Qt, etc.

The Display connection is for OpenGL platforms where a constant display is
required in order to share contexts (egl).  In the case of a wrapped context
(added later), we do not have GstGLWindow to retreive the display from so a
'master' connection is used instead.
2017-12-09 19:31:33 +00:00
Matthew Waters
253fe220df [863/906] window: hold a ref to our GstGLDisplay 2017-12-09 19:31:33 +00:00
Matthew Waters
2026f60879 [862/906] window: remove set_need_lock
No-one is using it.  The only code that did was the x11 one which
doesn't need it anymore.
2017-12-09 19:31:33 +00:00
Matthew Waters
dadce598ba [859/906] window: provide some documetation 2017-12-09 19:31:32 +00:00
Julien Isorce
e42b5bc985 [841/906] osx: allow x11/glx backend and set default runtime to cocoa/nsgl
https://bugzilla.gnome.org/show_bug.cgi?id=719757
2017-12-09 19:31:32 +00:00
Julien Isorce
6a5bd364a4 [835/906] gstglwindow: remove unused fields 2017-12-09 19:31:32 +00:00
Julien Isorce
4d6de2ce1b [834/906] gstglwindow: clear mutex 2017-12-09 19:31:32 +00:00
Julien Isorce
66d7d4712e [831/906] glimagesink: avoid to overload the drawer if already drawing
Especially if the application calls gst_video_overlay_expose a lot
2017-12-09 19:31:32 +00:00
Julien Isorce
e1eb30005c [820/906] gstglwindow: if available use wayland instead dispmanx on rpi 2017-12-09 19:31:31 +00:00
Matthew Waters
3b1ec77cf8 [818/906] window: add send_message_async vmethod
- provide a default synchronous send_message
- make context creation threadsafe again
2017-12-09 19:31:31 +00:00