From 614f80cbcf0a7249d0b1505c9467bf96bc690da0 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 13 Apr 2016 00:43:18 +1000 Subject: [PATCH] gl/cocoa/eagl: don't leak GThread's when dispatching messages gst_gl_context_get_thread() returns a refed pointer, we need to unref it. --- gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m | 5 ++++- gst-libs/gst/gl/eagl/gstglwindow_eagl.m | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m index e1996cf063..495d0227e8 100644 --- a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m +++ b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m @@ -386,8 +386,9 @@ gst_gl_window_cocoa_send_message_async (GstGLWindow * window, { GstGLWindowCocoa *window_cocoa = (GstGLWindowCocoa *) window; GstGLContext *context = gst_gl_window_get_context (window); + GThread *thread = gst_gl_context_get_thread (context); - if (gst_gl_context_get_thread (context) == g_thread_self()) { + if (thread == g_thread_self()) { /* this case happens for nested calls happening from inside the GCD queue */ callback (data); if (destroy) @@ -402,6 +403,8 @@ gst_gl_window_cocoa_send_message_async (GstGLWindow * window, destroy (data); }); } + if (thread) + g_thread_unref (thread); } /* =============================================================*/ diff --git a/gst-libs/gst/gl/eagl/gstglwindow_eagl.m b/gst-libs/gst/gl/eagl/gstglwindow_eagl.m index f130cc015f..72ab1abb53 100644 --- a/gst-libs/gst/gl/eagl/gstglwindow_eagl.m +++ b/gst-libs/gst/gl/eagl/gstglwindow_eagl.m @@ -150,8 +150,9 @@ gst_gl_window_eagl_send_message_async (GstGLWindow * window, { GstGLWindowEagl *window_eagl = (GstGLWindowEagl *) window; GstGLContext *context = gst_gl_window_get_context (window); + GThread *thread = gst_gl_context_get_thread (context); - if (gst_gl_context_get_thread (context) == g_thread_self()) { + if (thread == g_thread_self()) { /* this case happens for nested calls happening from inside the GCD queue */ callback (data); if (destroy) @@ -166,6 +167,8 @@ gst_gl_window_eagl_send_message_async (GstGLWindow * window, destroy (data); }); } + if (thread) + g_thread_unref (thread); } static void