GStreamer: fix memory leaks.

Many GStreamer objects were not properly managed or never released.

Change-Id: I38b3854e8b9e2264b5b647f331d3bb16b886e2d6
Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
This commit is contained in:
Yoann Lopes
2014-03-20 19:20:24 +01:00
committed by The Qt Project
parent 60ba0afbde
commit 023c6ebcb9
20 changed files with 134 additions and 41 deletions

View File

@@ -48,6 +48,7 @@
#include <private/gstvideoconnector_p.h>
#include <private/qgstutils_p.h>
#include <private/playlistfileparser_p.h>
#include <private/qgstutils_p.h>
#include <gst/gstvalue.h>
#include <gst/base/gstbasesrc.h>
@@ -157,17 +158,20 @@ QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent)
}
}
m_videoOutputBin = gst_bin_new("video-output-bin");
gst_object_ref(GST_OBJECT(m_videoOutputBin));
m_videoIdentity = GST_ELEMENT(g_object_new(gst_video_connector_get_type(), 0));
m_videoIdentity = GST_ELEMENT(g_object_new(gst_video_connector_get_type(), 0)); // floating ref
g_signal_connect(G_OBJECT(m_videoIdentity), "connection-failed", G_CALLBACK(insertColorSpaceElement), (gpointer)this);
m_colorSpace = gst_element_factory_make("ffmpegcolorspace", "ffmpegcolorspace-vo");
gst_object_ref(GST_OBJECT(m_colorSpace));
// might not get a parent, take ownership to avoid leak
qt_gst_object_ref_sink(GST_OBJECT(m_colorSpace));
m_nullVideoSink = gst_element_factory_make("fakesink", NULL);
g_object_set(G_OBJECT(m_nullVideoSink), "sync", true, NULL);
gst_object_ref(GST_OBJECT(m_nullVideoSink));
m_videoOutputBin = gst_bin_new("video-output-bin");
// might not get a parent, take ownership to avoid leak
qt_gst_object_ref_sink(GST_OBJECT(m_videoOutputBin));
gst_bin_add_many(GST_BIN(m_videoOutputBin), m_videoIdentity, m_nullVideoSink, NULL);
gst_element_link(m_videoIdentity, m_nullVideoSink);
@@ -238,6 +242,8 @@ void QGstreamerPlayerSession::configureAppSrcElement(GObject* object, GObject *o
if (!self->appsrc()->setup(appsrc))
qWarning()<<"Could not setup appsrc element";
g_object_unref(G_OBJECT(appsrc));
}
#endif