Title: [195735] trunk/Source/WebCore
- Revision
- 195735
- Author
- [email protected]
- Date
- 2016-01-28 01:06:30 -0800 (Thu, 28 Jan 2016)
Log Message
[GStreamer] MediaPlayerPrivateGStreamerBase::handleSyncMessage leaks GstContext
https://bugs.webkit.org/show_bug.cgi?id=153580
Reviewed by Philippe Normand.
When we creates GstContext using gst_context_new it increases refcount itself.
And the refcount of GstContext is increased when it is passed to
gst_element_set_context, also. Therefore We should unref GstContext after
using it to prevent GstContext leaks.
* platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
(WTF::adoptGRef): Added for GstContext.
(WTF::refGPtr<GstContext>): Ditto
(WTF::derefGPtr<GstContext>): Ditto
* platform/graphics/gstreamer/GRefPtrGStreamer.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::handleSyncMessage):
Use GRefPtr<GstContext> to handle currect refcounting
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (195734 => 195735)
--- trunk/Source/WebCore/ChangeLog 2016-01-28 08:52:44 UTC (rev 195734)
+++ trunk/Source/WebCore/ChangeLog 2016-01-28 09:06:30 UTC (rev 195735)
@@ -1,3 +1,24 @@
+2016-01-28 Gwang Yoon Hwang <[email protected]>
+
+ [GStreamer] MediaPlayerPrivateGStreamerBase::handleSyncMessage leaks GstContext
+ https://bugs.webkit.org/show_bug.cgi?id=153580
+
+ Reviewed by Philippe Normand.
+
+ When we creates GstContext using gst_context_new it increases refcount itself.
+ And the refcount of GstContext is increased when it is passed to
+ gst_element_set_context, also. Therefore We should unref GstContext after
+ using it to prevent GstContext leaks.
+
+ * platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
+ (WTF::adoptGRef): Added for GstContext.
+ (WTF::refGPtr<GstContext>): Ditto
+ (WTF::derefGPtr<GstContext>): Ditto
+ * platform/graphics/gstreamer/GRefPtrGStreamer.h:
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+ (WebCore::MediaPlayerPrivateGStreamerBase::handleSyncMessage):
+ Use GRefPtr<GstContext> to handle currect refcounting
+
2016-01-27 Alex Christensen <[email protected]>
Fix clean CMake build after r195711.
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp (195734 => 195735)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp 2016-01-28 08:52:44 UTC (rev 195734)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp 2016-01-28 09:06:30 UTC (rev 195735)
@@ -103,7 +103,25 @@
gst_caps_unref(ptr);
}
+template <> GRefPtr<GstContext> adoptGRef(GstContext* ptr)
+{
+ ASSERT(!g_object_is_floating(G_OBJECT(ptr)));
+ return GRefPtr<GstContext>(ptr, GRefPtrAdopt);
+}
+template <> GstContext* refGPtr<GstContext>(GstContext* ptr)
+{
+ if (ptr)
+ gst_context_ref(ptr);
+ return ptr;
+}
+
+template <> void derefGPtr<GstContext>(GstContext* ptr)
+{
+ if (ptr)
+ gst_context_unref(ptr);
+}
+
template <> GRefPtr<GstTask> adoptGRef(GstTask* ptr)
{
ASSERT(!g_object_is_floating(G_OBJECT(ptr)));
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h (195734 => 195735)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h 2016-01-28 08:52:44 UTC (rev 195734)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h 2016-01-28 09:06:30 UTC (rev 195735)
@@ -27,6 +27,7 @@
typedef struct _GstPad GstPad;
typedef struct _GstPadTemplate GstPadTemplate;
typedef struct _GstCaps GstCaps;
+typedef struct _GstContext GstContext;
typedef struct _GstTask GstTask;
typedef struct _GstBus GstBus;
typedef struct _GstElementFactory GstElementFactory;
@@ -58,6 +59,10 @@
template<> GstCaps* refGPtr<GstCaps>(GstCaps* ptr);
template<> void derefGPtr<GstCaps>(GstCaps* ptr);
+template<> GRefPtr<GstContext> adoptGRef(GstContext* ptr);
+template<> GstContext* refGPtr<GstContext>(GstContext* ptr);
+template<> void derefGPtr<GstContext>(GstContext* ptr);
+
template<> GRefPtr<GstTask> adoptGRef(GstTask* ptr);
template<> GstTask* refGPtr<GstTask>(GstTask* ptr);
template<> void derefGPtr<GstTask>(GstTask* ptr);
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (195734 => 195735)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2016-01-28 08:52:44 UTC (rev 195734)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2016-01-28 09:06:30 UTC (rev 195735)
@@ -220,17 +220,17 @@
return false;
if (!g_strcmp0(contextType, GST_GL_DISPLAY_CONTEXT_TYPE)) {
- GstContext* displayContext = gst_context_new(GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
- gst_context_set_gl_display(displayContext, m_glDisplay.get());
- gst_element_set_context(GST_ELEMENT(message->src), displayContext);
+ GRefPtr<GstContext> displayContext = adoptGRef(gst_context_new(GST_GL_DISPLAY_CONTEXT_TYPE, TRUE));
+ gst_context_set_gl_display(displayContext.get(), m_glDisplay.get());
+ gst_element_set_context(GST_ELEMENT(message->src), displayContext.get());
return true;
}
if (!g_strcmp0(contextType, "gst.gl.app_context")) {
- GstContext* appContext = gst_context_new("gst.gl.app_context", TRUE);
- GstStructure* structure = gst_context_writable_structure(appContext);
+ GRefPtr<GstContext> appContext = adoptGRef(gst_context_new("gst.gl.app_context", TRUE));
+ GstStructure* structure = gst_context_writable_structure(appContext.get());
gst_structure_set(structure, "context", GST_GL_TYPE_CONTEXT, m_glContext.get(), nullptr);
- gst_element_set_context(GST_ELEMENT(message->src), appContext);
+ gst_element_set_context(GST_ELEMENT(message->src), appContext.get());
return true;
}
#else
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes