gst/gstpad.c (pre_activate): Renamed from pre_activate_switch, take the mode we're going to as an arg. Go head and se...

Original commit message from CVS:
2005-10-11  Andy Wingo  <wingo@pobox.com>

* gst/gstpad.c (pre_activate): Renamed from pre_activate_switch,
take the mode we're going to as an arg. Go head and set the mode
and flushing flags now, so that if the activate function starts a
thread all the flags will be in the right state.
(post_activate): Renamed also. Just handle making sure streaming
finishes for the deactivation case, and setting the deactivated
mode.
(gst_pad_set_active): Complain loudly if deactivation fails.
(gst_pad_activate_pull): Adapt to pre/post_activate changes.
(gst_pad_activate_push): Adapt to pre/post_activate changes,
remove the terrible hack.
This commit is contained in:
Andy Wingo 2005-10-11 15:23:10 +00:00
parent 4dd6c2a587
commit 3ef37179a1
2 changed files with 60 additions and 44 deletions

View file

@ -1,3 +1,17 @@
2005-10-11 Andy Wingo <wingo@pobox.com>
* gst/gstpad.c (pre_activate): Renamed from pre_activate_switch,
take the mode we're going to as an arg. Go head and set the mode
and flushing flags now, so that if the activate function starts a
thread all the flags will be in the right state.
(post_activate): Renamed also. Just handle making sure streaming
finishes for the deactivation case, and setting the deactivated
mode.
(gst_pad_set_active): Complain loudly if deactivation fails.
(gst_pad_activate_pull): Adapt to pre/post_activate changes.
(gst_pad_activate_push): Adapt to pre/post_activate changes,
remove the terrible hack.
2005-10-11 Wim Taymans <wim@fluendo.com> 2005-10-11 Wim Taymans <wim@fluendo.com>
* gst/gstbin.c: (gst_bin_init), (gst_bin_provide_clock_func), * gst/gstbin.c: (gst_bin_init), (gst_bin_provide_clock_func),

View file

@ -525,30 +525,43 @@ gst_pad_activate_default (GstPad * pad)
} }
static void static void
pre_activate_switch (GstPad * pad, gboolean new_active) pre_activate (GstPad * pad, GstActivateMode new_mode)
{ {
if (new_active) { switch (new_mode) {
return; case GST_ACTIVATE_PUSH:
} else { case GST_ACTIVATE_PULL:
GST_LOCK (pad); GST_LOCK (pad);
GST_PAD_SET_FLUSHING (pad); GST_PAD_UNSET_FLUSHING (pad);
/* unlock blocked pads so element can resume and stop */ GST_PAD_ACTIVATE_MODE (pad) = new_mode;
GST_PAD_BLOCK_SIGNAL (pad); GST_UNLOCK (pad);
GST_UNLOCK (pad); break;
case GST_ACTIVATE_NONE:
GST_LOCK (pad);
GST_PAD_SET_FLUSHING (pad);
/* unlock blocked pads so element can resume and stop */
GST_PAD_BLOCK_SIGNAL (pad);
GST_UNLOCK (pad);
break;
} }
} }
static void static void
post_activate_switch (GstPad * pad, gboolean new_active) post_activate (GstPad * pad, GstActivateMode new_mode)
{ {
if (new_active) { switch (new_mode) {
GST_LOCK (pad); case GST_ACTIVATE_PUSH:
GST_PAD_UNSET_FLUSHING (pad); case GST_ACTIVATE_PULL:
GST_UNLOCK (pad); /* nop */
} else { break;
/* ensures that streaming stops */ case GST_ACTIVATE_NONE:
GST_STREAM_LOCK (pad); /* ensures that streaming stops */
GST_STREAM_UNLOCK (pad); GST_STREAM_LOCK (pad);
/* while we're at it set activation mode */
GST_LOCK (pad);
GST_PAD_ACTIVATE_MODE (pad) = new_mode;
GST_UNLOCK (pad);
GST_STREAM_UNLOCK (pad);
break;
} }
} }
@ -609,6 +622,13 @@ gst_pad_set_active (GstPad * pad, gboolean active)
} }
} }
if (!active && !ret) {
GST_LOCK (pad);
g_critical ("Failed to deactivate pad %s:%s, very bad",
GST_DEBUG_PAD_NAME (pad));
GST_UNLOCK (pad);
}
return ret; return ret;
} }
@ -632,7 +652,7 @@ gst_pad_set_active (GstPad * pad, gboolean active)
gboolean gboolean
gst_pad_activate_pull (GstPad * pad, gboolean active) gst_pad_activate_pull (GstPad * pad, gboolean active)
{ {
GstActivateMode old; GstActivateMode old, new;
g_return_val_if_fail (GST_IS_PAD (pad), FALSE); g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
@ -665,7 +685,8 @@ gst_pad_activate_pull (GstPad * pad, gboolean active)
} }
} }
pre_activate_switch (pad, active); new = active ? GST_ACTIVATE_PULL : GST_ACTIVATE_NONE;
pre_activate (pad, new);
if (GST_PAD_ACTIVATEPULLFUNC (pad)) { if (GST_PAD_ACTIVATEPULLFUNC (pad)) {
if (GST_PAD_ACTIVATEPULLFUNC (pad) (pad, active)) { if (GST_PAD_ACTIVATEPULLFUNC (pad) (pad, active)) {
@ -687,11 +708,7 @@ was_ok:
success: success:
{ {
GST_LOCK (pad); post_activate (pad, new);
GST_PAD_ACTIVATE_MODE (pad) =
active ? GST_ACTIVATE_PULL : GST_ACTIVATE_NONE;
GST_UNLOCK (pad);
post_activate_switch (pad, active);
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in pull mode", GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in pull mode",
active ? "activated" : "deactivated"); active ? "activated" : "deactivated");
@ -723,7 +740,7 @@ failure:
gboolean gboolean
gst_pad_activate_push (GstPad * pad, gboolean active) gst_pad_activate_push (GstPad * pad, gboolean active)
{ {
GstActivateMode old; GstActivateMode old, new;
g_return_val_if_fail (GST_IS_PAD (pad), FALSE); g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "trying to set %s in push mode", GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "trying to set %s in push mode",
@ -743,11 +760,8 @@ gst_pad_activate_push (GstPad * pad, gboolean active)
g_return_val_if_fail (old == GST_ACTIVATE_PUSH, FALSE); g_return_val_if_fail (old == GST_ACTIVATE_PUSH, FALSE);
} }
pre_activate_switch (pad, active); new = active ? GST_ACTIVATE_PUSH : GST_ACTIVATE_NONE;
pre_activate (pad, new);
/* terrible hack */
if (active)
GST_STREAM_LOCK (pad);
if (GST_PAD_ACTIVATEPUSHFUNC (pad)) { if (GST_PAD_ACTIVATEPUSHFUNC (pad)) {
if (GST_PAD_ACTIVATEPUSHFUNC (pad) (pad, active)) { if (GST_PAD_ACTIVATEPUSHFUNC (pad) (pad, active)) {
@ -769,15 +783,7 @@ was_ok:
success: success:
{ {
GST_LOCK (pad); post_activate (pad, new);
GST_PAD_ACTIVATE_MODE (pad) =
active ? GST_ACTIVATE_PUSH : GST_ACTIVATE_NONE;
GST_UNLOCK (pad);
post_activate_switch (pad, active);
/* terrible hack */
if (active)
GST_STREAM_UNLOCK (pad);
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in push mode", GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in push mode",
active ? "activated" : "deactivated"); active ? "activated" : "deactivated");
@ -786,10 +792,6 @@ success:
failure: failure:
{ {
/* terrible hack */
if (active)
GST_STREAM_UNLOCK (pad);
GST_CAT_INFO_OBJECT (GST_CAT_PADS, pad, "failed to %s in push mode", GST_CAT_INFO_OBJECT (GST_CAT_PADS, pad, "failed to %s in push mode",
active ? "activate" : "deactivate"); active ? "activate" : "deactivate");
return FALSE; return FALSE;