mpegdemux: avoid extra refs/unrefs of the demuxer

Change all the gst_pad_get_parent() calls to a cast to the
passed parent variable where appropriate, and don't unref,
including the extra unref in the
gst_flups_demux_sink_activate_push() function.
This commit is contained in:
Jan Schmidt 2012-06-11 08:33:36 +10:00
parent 429204a89e
commit 628a8ed8b1

View file

@ -899,9 +899,7 @@ static gboolean
gst_flups_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) gst_flups_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{ {
gboolean res = TRUE; gboolean res = TRUE;
GstFluPSDemux *demux; GstFluPSDemux *demux = GST_FLUPS_DEMUX (parent);
demux = GST_FLUPS_DEMUX (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START: case GST_EVENT_FLUSH_START:
@ -972,8 +970,6 @@ gst_flups_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
break; break;
} }
gst_object_unref (demux);
return res; return res;
} }
@ -1276,9 +1272,7 @@ static gboolean
gst_flups_demux_src_event (GstPad * pad, GstObject * parent, GstEvent * event) gst_flups_demux_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{ {
gboolean res = FALSE; gboolean res = FALSE;
GstFluPSDemux *demux; GstFluPSDemux *demux = GST_FLUPS_DEMUX (parent);
demux = GST_FLUPS_DEMUX (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK: case GST_EVENT_SEEK:
@ -1293,8 +1287,6 @@ gst_flups_demux_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
break; break;
} }
gst_object_unref (demux);
return res; return res;
} }
@ -1302,9 +1294,7 @@ static gboolean
gst_flups_demux_src_query (GstPad * pad, GstObject * parent, GstQuery * query) gst_flups_demux_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{ {
gboolean res = FALSE; gboolean res = FALSE;
GstFluPSDemux *demux; GstFluPSDemux *demux = GST_FLUPS_DEMUX (parent);
demux = GST_FLUPS_DEMUX (gst_pad_get_parent (pad));
GST_LOG_OBJECT (demux, "Have query of type %d on pad %" GST_PTR_FORMAT, GST_LOG_OBJECT (demux, "Have query of type %d on pad %" GST_PTR_FORMAT,
GST_QUERY_TYPE (query), pad); GST_QUERY_TYPE (query), pad);
@ -1465,16 +1455,9 @@ gst_flups_demux_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
} }
beach: beach:
gst_object_unref (demux);
return res; return res;
not_supported: not_supported:
{
gst_object_unref (demux);
return FALSE; return FALSE;
}
} }
static void static void
@ -2900,9 +2883,7 @@ static gboolean
gst_flups_demux_sink_activate_push (GstPad * sinkpad, GstObject * parent, gst_flups_demux_sink_activate_push (GstPad * sinkpad, GstObject * parent,
gboolean active) gboolean active)
{ {
GstFluPSDemux *demux; GstFluPSDemux *demux = GST_FLUPS_DEMUX (parent);
demux = GST_FLUPS_DEMUX (parent);
demux->random_access = FALSE; demux->random_access = FALSE;
@ -2916,19 +2897,15 @@ static gboolean
gst_flups_demux_sink_activate_pull (GstPad * sinkpad, GstObject * parent, gst_flups_demux_sink_activate_pull (GstPad * sinkpad, GstObject * parent,
gboolean active) gboolean active)
{ {
GstFluPSDemux *demux; GstFluPSDemux *demux = GST_FLUPS_DEMUX (parent);
demux = GST_FLUPS_DEMUX (gst_pad_get_parent (sinkpad));
if (active) { if (active) {
GST_DEBUG ("pull mode activated"); GST_DEBUG ("pull mode activated");
demux->random_access = TRUE; demux->random_access = TRUE;
gst_object_unref (demux);
return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_flups_demux_loop, return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_flups_demux_loop,
sinkpad, NULL); sinkpad, NULL);
} else { } else {
demux->random_access = FALSE; demux->random_access = FALSE;
gst_object_unref (demux);
return gst_pad_stop_task (sinkpad); return gst_pad_stop_task (sinkpad);
} }
} }
@ -2949,7 +2926,7 @@ gst_flups_demux_sink_activate_mode (GstPad * pad, GstObject * parent,
static GstFlowReturn static GstFlowReturn
gst_flups_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) gst_flups_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{ {
GstFluPSDemux *demux = GST_FLUPS_DEMUX (gst_pad_get_parent (pad)); GstFluPSDemux *demux = GST_FLUPS_DEMUX (parent);
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
guint32 avail; guint32 avail;
gboolean save, discont; gboolean save, discont;
@ -3081,8 +3058,6 @@ gst_flups_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
} }
} }
done: done:
gst_object_unref (demux);
return ret; return ret;
} }