proxysink: Fix GstProxySrc leak

Clear weak pointer to peer src when disposing.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1552>
This commit is contained in:
Seungha Yang 2022-07-07 02:17:56 +09:00
parent 37fdaaf8ff
commit 8aeb8ea58f

View file

@ -57,6 +57,7 @@ G_DEFINE_TYPE (GstProxySink, gst_proxy_sink, GST_TYPE_ELEMENT);
GST_ELEMENT_REGISTER_DEFINE (proxysink, "proxysink", GST_RANK_NONE,
GST_TYPE_PROXY_SINK);
static void gst_proxy_sink_dispose (GObject * object);
static gboolean gst_proxy_sink_sink_query (GstPad * pad, GstObject * parent,
GstQuery * query);
static GstFlowReturn gst_proxy_sink_sink_chain (GstPad * pad,
@ -76,10 +77,13 @@ static gboolean gst_proxy_sink_query (GstElement * element, GstQuery * query);
static void
gst_proxy_sink_class_init (GstProxySinkClass * klass)
{
GstElementClass *gstelement_class = (GstElementClass *) klass;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
GST_DEBUG_CATEGORY_INIT (gst_proxy_sink_debug, "proxysink", 0, "proxy sink");
object_class->dispose = gst_proxy_sink_dispose;
gstelement_class->change_state = gst_proxy_sink_change_state;
gstelement_class->send_event = gst_proxy_sink_send_event;
gstelement_class->query = gst_proxy_sink_query;
@ -109,6 +113,16 @@ gst_proxy_sink_init (GstProxySink * self)
GST_OBJECT_FLAG_SET (self, GST_ELEMENT_FLAG_SINK);
}
static void
gst_proxy_sink_dispose (GObject * object)
{
GstProxySink *self = GST_PROXY_SINK (object);
g_weak_ref_clear (&self->proxysrc);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static GstStateChangeReturn
gst_proxy_sink_change_state (GstElement * element, GstStateChange transition)
{