update for activation changes

This commit is contained in:
Wim Taymans 2011-11-21 13:35:34 +01:00
parent 3233f09adf
commit 8fc2a21775
3 changed files with 55 additions and 56 deletions

View file

@ -1783,10 +1783,8 @@ static GstFlowReturn gst_ogg_demux_chain (GstPad * pad, GstObject * parent,
GstBuffer * buffer); GstBuffer * buffer);
static gboolean gst_ogg_demux_sink_activate (GstPad * sinkpad, static gboolean gst_ogg_demux_sink_activate (GstPad * sinkpad,
GstObject * parent); GstObject * parent);
static gboolean gst_ogg_demux_sink_activate_pull (GstPad * sinkpad, static gboolean gst_ogg_demux_sink_activate_mode (GstPad * sinkpad,
GstObject * parent, gboolean active); GstObject * parent, GstPadMode mode, gboolean active);
static gboolean gst_ogg_demux_sink_activate_push (GstPad * sinkpad,
GstObject * parent, gboolean active);
static GstStateChangeReturn gst_ogg_demux_change_state (GstElement * element, static GstStateChangeReturn gst_ogg_demux_change_state (GstElement * element,
GstStateChange transition); GstStateChange transition);
@ -1828,10 +1826,8 @@ gst_ogg_demux_init (GstOggDemux * ogg)
gst_pad_set_event_function (ogg->sinkpad, gst_ogg_demux_sink_event); gst_pad_set_event_function (ogg->sinkpad, gst_ogg_demux_sink_event);
gst_pad_set_chain_function (ogg->sinkpad, gst_ogg_demux_chain); gst_pad_set_chain_function (ogg->sinkpad, gst_ogg_demux_chain);
gst_pad_set_activate_function (ogg->sinkpad, gst_ogg_demux_sink_activate); gst_pad_set_activate_function (ogg->sinkpad, gst_ogg_demux_sink_activate);
gst_pad_set_activatepull_function (ogg->sinkpad, gst_pad_set_activatemode_function (ogg->sinkpad,
gst_ogg_demux_sink_activate_pull); gst_ogg_demux_sink_activate_mode);
gst_pad_set_activatepush_function (ogg->sinkpad,
gst_ogg_demux_sink_activate_push);
gst_element_add_pad (GST_ELEMENT (ogg), ogg->sinkpad); gst_element_add_pad (GST_ELEMENT (ogg), ogg->sinkpad);
ogg->chain_lock = g_mutex_new (); ogg->chain_lock = g_mutex_new ();
@ -4327,51 +4323,46 @@ gst_ogg_demux_sink_activate (GstPad * sinkpad, GstObject * parent)
goto activate_push; goto activate_push;
GST_DEBUG_OBJECT (sinkpad, "activating pull"); GST_DEBUG_OBJECT (sinkpad, "activating pull");
return gst_pad_activate_pull (sinkpad, TRUE); return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
activate_push: activate_push:
{ {
GST_DEBUG_OBJECT (sinkpad, "activating push"); GST_DEBUG_OBJECT (sinkpad, "activating push");
return gst_pad_activate_push (sinkpad, TRUE); return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
} }
} }
/* this function gets called when we activate ourselves in push mode.
* We cannot seek (ourselves) in the stream */
static gboolean static gboolean
gst_ogg_demux_sink_activate_push (GstPad * sinkpad, GstObject * parent, gst_ogg_demux_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
gboolean active) GstPadMode mode, gboolean active)
{ {
gboolean res;
GstOggDemux *ogg; GstOggDemux *ogg;
ogg = GST_OGG_DEMUX (parent); ogg = GST_OGG_DEMUX (parent);
ogg->pullmode = FALSE; switch (mode) {
ogg->resync = FALSE; case GST_PAD_MODE_PUSH:
ogg->pullmode = FALSE;
ogg->resync = FALSE;
res = TRUE;
break;
case GST_PAD_MODE_PULL:
if (active) {
ogg->need_chains = TRUE;
ogg->pullmode = TRUE;
return TRUE; res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_ogg_demux_loop,
} sinkpad);
} else {
/* this function gets called when we activate ourselves in pull mode. res = gst_pad_stop_task (sinkpad);
* We can perform random access to the resource and we start a task }
* to start reading */ break;
static gboolean default:
gst_ogg_demux_sink_activate_pull (GstPad * sinkpad, GstObject * parent, res = FALSE;
gboolean active) break;
{
GstOggDemux *ogg;
ogg = GST_OGG_DEMUX (parent);
if (active) {
ogg->need_chains = TRUE;
ogg->pullmode = TRUE;
return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_ogg_demux_loop,
sinkpad);
} else {
return gst_pad_stop_task (sinkpad);
} }
return res;
} }
static GstStateChangeReturn static GstStateChangeReturn

View file

@ -293,8 +293,8 @@ static void gst_audio_encoder_set_property (GObject * object,
static void gst_audio_encoder_get_property (GObject * object, static void gst_audio_encoder_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec); guint prop_id, GValue * value, GParamSpec * pspec);
static gboolean gst_audio_encoder_sink_activate_push (GstPad * pad, static gboolean gst_audio_encoder_sink_activate_mode (GstPad * pad,
GstObject * parent, gboolean active); GstObject * parent, GstPadMode mode, gboolean active);
static GstCaps *gst_audio_encoder_getcaps_default (GstAudioEncoder * enc, static GstCaps *gst_audio_encoder_getcaps_default (GstAudioEncoder * enc,
GstCaps * filter); GstCaps * filter);
@ -370,8 +370,8 @@ gst_audio_encoder_init (GstAudioEncoder * enc, GstAudioEncoderClass * bclass)
GST_DEBUG_FUNCPTR (gst_audio_encoder_sink_query)); GST_DEBUG_FUNCPTR (gst_audio_encoder_sink_query));
gst_pad_set_chain_function (enc->sinkpad, gst_pad_set_chain_function (enc->sinkpad,
GST_DEBUG_FUNCPTR (gst_audio_encoder_chain)); GST_DEBUG_FUNCPTR (gst_audio_encoder_chain));
gst_pad_set_activatepush_function (enc->sinkpad, gst_pad_set_activatemode_function (enc->sinkpad,
GST_DEBUG_FUNCPTR (gst_audio_encoder_sink_activate_push)); GST_DEBUG_FUNCPTR (gst_audio_encoder_sink_activate_mode));
gst_element_add_pad (GST_ELEMENT (enc), enc->sinkpad); gst_element_add_pad (GST_ELEMENT (enc), enc->sinkpad);
GST_DEBUG_OBJECT (enc, "sinkpad created"); GST_DEBUG_OBJECT (enc, "sinkpad created");
@ -1701,8 +1701,8 @@ gst_audio_encoder_activate (GstAudioEncoder * enc, gboolean active)
static gboolean static gboolean
gst_audio_encoder_sink_activate_push (GstPad * pad, GstObject * parent, gst_audio_encoder_sink_activate_mode (GstPad * pad, GstObject * parent,
gboolean active) GstPadMode mode, gboolean active)
{ {
gboolean result = TRUE; gboolean result = TRUE;
GstAudioEncoder *enc; GstAudioEncoder *enc;

View file

@ -139,8 +139,8 @@ static GstFlowReturn gst_tag_demux_chain (GstPad * pad, GstObject * parent,
static gboolean gst_tag_demux_sink_event (GstPad * pad, GstObject * parent, static gboolean gst_tag_demux_sink_event (GstPad * pad, GstObject * parent,
GstEvent * event); GstEvent * event);
static gboolean gst_tag_demux_src_activate_pull (GstPad * pad, static gboolean gst_tag_demux_src_activate_mode (GstPad * pad,
GstObject * parent, gboolean active); GstObject * parent, GstPadMode mode, gboolean active);
static GstFlowReturn gst_tag_demux_read_range (GstTagDemux * tagdemux, static GstFlowReturn gst_tag_demux_read_range (GstTagDemux * tagdemux,
GstObject * parent, guint64 offset, guint length, GstBuffer ** buffer); GstObject * parent, guint64 offset, guint length, GstBuffer ** buffer);
@ -311,8 +311,8 @@ gst_tag_demux_init (GstTagDemux * demux, GstTagDemuxClass * gclass)
GST_DEBUG_FUNCPTR (gst_tag_demux_pad_query)); GST_DEBUG_FUNCPTR (gst_tag_demux_pad_query));
gst_pad_set_event_function (demux->priv->srcpad, gst_pad_set_event_function (demux->priv->srcpad,
GST_DEBUG_FUNCPTR (gst_tag_demux_srcpad_event)); GST_DEBUG_FUNCPTR (gst_tag_demux_srcpad_event));
gst_pad_set_activatepull_function (demux->priv->srcpad, gst_pad_set_activatemode_function (demux->priv->srcpad,
GST_DEBUG_FUNCPTR (gst_tag_demux_src_activate_pull)); GST_DEBUG_FUNCPTR (gst_tag_demux_src_activate_mode));
gst_pad_set_getrange_function (demux->priv->srcpad, gst_pad_set_getrange_function (demux->priv->srcpad,
GST_DEBUG_FUNCPTR (gst_tag_demux_src_getrange)); GST_DEBUG_FUNCPTR (gst_tag_demux_src_getrange));
gst_pad_use_fixed_caps (demux->priv->srcpad); gst_pad_use_fixed_caps (demux->priv->srcpad);
@ -1129,7 +1129,7 @@ gst_tag_demux_sink_activate (GstPad * sinkpad, GstObject * parent)
if (!pull_mode) if (!pull_mode)
goto activate_push; goto activate_push;
if (!gst_pad_activate_pull (sinkpad, TRUE)) if (!gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE))
goto activate_push; goto activate_push;
/* Look for tags at start and end of file */ /* Look for tags at start and end of file */
@ -1185,7 +1185,7 @@ gst_tag_demux_sink_activate (GstPad * sinkpad, GstObject * parent)
"probability of %u", caps, probability); "probability of %u", caps, probability);
/* 4 - Deactivate pull mode */ /* 4 - Deactivate pull mode */
if (!gst_pad_activate_pull (sinkpad, FALSE)) { if (!gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, FALSE)) {
if (caps) if (caps)
gst_caps_unref (caps); gst_caps_unref (caps);
GST_DEBUG_OBJECT (demux, "Could not deactivate sinkpad after reading tags"); GST_DEBUG_OBJECT (demux, "Could not deactivate sinkpad after reading tags");
@ -1210,8 +1210,8 @@ gst_tag_demux_sink_activate (GstPad * sinkpad, GstObject * parent)
* done, otherwise switch to push */ * done, otherwise switch to push */
ret = TRUE; ret = TRUE;
if (!gst_pad_is_active (sinkpad)) { if (!gst_pad_is_active (sinkpad)) {
ret = gst_pad_activate_push (demux->priv->srcpad, TRUE); ret = gst_pad_activate_mode (demux->priv->srcpad, GST_PAD_MODE_PUSH, TRUE);
ret &= gst_pad_activate_push (sinkpad, TRUE); ret &= gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
} }
done_activate: done_activate:
@ -1226,17 +1226,25 @@ activate_push:
GST_DEBUG_OBJECT (demux, "No pull mode. Changing to push, but won't be " GST_DEBUG_OBJECT (demux, "No pull mode. Changing to push, but won't be "
"able to read end tags"); "able to read end tags");
demux->priv->state = GST_TAG_DEMUX_READ_START_TAG; demux->priv->state = GST_TAG_DEMUX_READ_START_TAG;
return gst_pad_activate_push (sinkpad, TRUE); return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
} }
} }
static gboolean static gboolean
gst_tag_demux_src_activate_pull (GstPad * pad, GstObject * parent, gst_tag_demux_src_activate_mode (GstPad * pad, GstObject * parent,
gboolean active) GstPadMode mode, gboolean active)
{ {
gboolean res = TRUE;
GstTagDemux *demux = GST_TAG_DEMUX (parent); GstTagDemux *demux = GST_TAG_DEMUX (parent);
return gst_pad_activate_pull (demux->priv->sinkpad, active); switch (mode) {
case GST_PAD_MODE_PULL:
res = gst_pad_activate_mode (demux->priv->sinkpad, mode, active);
break;
default:
break;
}
return res;
} }
static GstFlowReturn static GstFlowReturn