mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 20:59:44 +00:00
gst/gstpad.c: Cleanup activation code. Reset old state if activation failed.
Original commit message from CVS: * gst/gstpad.c: (pre_activate), (post_activate), (gst_pad_activate_pull), (gst_pad_activate_push): Cleanup activation code. Reset old state if activation failed.
This commit is contained in:
parent
0fd18045b1
commit
e11ddea888
2 changed files with 42 additions and 38 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2005-10-12 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/gstpad.c: (pre_activate), (post_activate),
|
||||||
|
(gst_pad_activate_pull), (gst_pad_activate_push):
|
||||||
|
Cleanup activation code. Reset old state if
|
||||||
|
activation failed.
|
||||||
|
|
||||||
2005-10-12 Wim Taymans <wim@fluendo.com>
|
2005-10-12 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
|
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
|
||||||
|
|
73
gst/gstpad.c
73
gst/gstpad.c
|
@ -531,12 +531,16 @@ pre_activate (GstPad * pad, GstActivateMode new_mode)
|
||||||
case GST_ACTIVATE_PUSH:
|
case GST_ACTIVATE_PUSH:
|
||||||
case GST_ACTIVATE_PULL:
|
case GST_ACTIVATE_PULL:
|
||||||
GST_LOCK (pad);
|
GST_LOCK (pad);
|
||||||
|
GST_DEBUG_OBJECT (pad, "setting ACTIVATE_MODE %d, unset flushing",
|
||||||
|
new_mode);
|
||||||
GST_PAD_UNSET_FLUSHING (pad);
|
GST_PAD_UNSET_FLUSHING (pad);
|
||||||
GST_PAD_ACTIVATE_MODE (pad) = new_mode;
|
GST_PAD_ACTIVATE_MODE (pad) = new_mode;
|
||||||
GST_UNLOCK (pad);
|
GST_UNLOCK (pad);
|
||||||
break;
|
break;
|
||||||
case GST_ACTIVATE_NONE:
|
case GST_ACTIVATE_NONE:
|
||||||
GST_LOCK (pad);
|
GST_LOCK (pad);
|
||||||
|
GST_DEBUG_OBJECT (pad, "setting ACTIVATE_MODE NONE, set flushing",
|
||||||
|
new_mode);
|
||||||
GST_PAD_SET_FLUSHING (pad);
|
GST_PAD_SET_FLUSHING (pad);
|
||||||
/* unlock blocked pads so element can resume and stop */
|
/* unlock blocked pads so element can resume and stop */
|
||||||
GST_PAD_BLOCK_SIGNAL (pad);
|
GST_PAD_BLOCK_SIGNAL (pad);
|
||||||
|
@ -558,6 +562,7 @@ post_activate (GstPad * pad, GstActivateMode new_mode)
|
||||||
GST_STREAM_LOCK (pad);
|
GST_STREAM_LOCK (pad);
|
||||||
/* while we're at it set activation mode */
|
/* while we're at it set activation mode */
|
||||||
GST_LOCK (pad);
|
GST_LOCK (pad);
|
||||||
|
GST_DEBUG_OBJECT (pad, "setting ACTIVATE_MODE %d", new_mode);
|
||||||
GST_PAD_ACTIVATE_MODE (pad) = new_mode;
|
GST_PAD_ACTIVATE_MODE (pad) = new_mode;
|
||||||
GST_UNLOCK (pad);
|
GST_UNLOCK (pad);
|
||||||
GST_STREAM_UNLOCK (pad);
|
GST_STREAM_UNLOCK (pad);
|
||||||
|
@ -653,6 +658,7 @@ gboolean
|
||||||
gst_pad_activate_pull (GstPad * pad, gboolean active)
|
gst_pad_activate_pull (GstPad * pad, gboolean active)
|
||||||
{
|
{
|
||||||
GstActivateMode old, new;
|
GstActivateMode old, new;
|
||||||
|
GstPad *peer;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
|
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
|
||||||
|
|
||||||
|
@ -671,17 +677,10 @@ gst_pad_activate_pull (GstPad * pad, gboolean active)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gst_pad_get_direction (pad) == GST_PAD_SINK) {
|
if (gst_pad_get_direction (pad) == GST_PAD_SINK) {
|
||||||
GstPad *peer = gst_pad_get_peer (pad);
|
if ((peer = gst_pad_get_peer (pad))) {
|
||||||
|
if (!gst_pad_activate_pull (peer, active))
|
||||||
if (peer) {
|
goto peer_failed;
|
||||||
if (!gst_pad_activate_pull (peer, active)) {
|
gst_object_unref (peer);
|
||||||
GST_LOCK (peer);
|
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
|
|
||||||
"activate_pull on peer (%s:%s) failed", GST_DEBUG_PAD_NAME (peer));
|
|
||||||
GST_UNLOCK (peer);
|
|
||||||
gst_object_unref (peer);
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -689,36 +688,39 @@ gst_pad_activate_pull (GstPad * pad, gboolean active)
|
||||||
pre_activate (pad, new);
|
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))
|
||||||
goto success;
|
|
||||||
} else {
|
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* can happen for sinks of passthrough elements */
|
/* can happen for sinks of passthrough elements */
|
||||||
goto success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
post_activate (pad, new);
|
||||||
|
|
||||||
|
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in pull mode",
|
||||||
|
active ? "activated" : "deactivated");
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
was_ok:
|
was_ok:
|
||||||
{
|
{
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "already %s in pull mode",
|
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "already %s in pull mode",
|
||||||
active ? "activated" : "deactivated");
|
active ? "activated" : "deactivated");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
peer_failed:
|
||||||
success:
|
|
||||||
{
|
{
|
||||||
post_activate (pad, new);
|
GST_LOCK (peer);
|
||||||
|
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in pull mode",
|
"activate_pull on peer (%s:%s) failed", GST_DEBUG_PAD_NAME (peer));
|
||||||
active ? "activated" : "deactivated");
|
GST_UNLOCK (peer);
|
||||||
return TRUE;
|
gst_object_unref (peer);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
failure:
|
failure:
|
||||||
{
|
{
|
||||||
GST_CAT_INFO_OBJECT (GST_CAT_PADS, pad, "failed to %s in pull mode",
|
GST_CAT_INFO_OBJECT (GST_CAT_PADS, pad, "failed to %s in pull mode",
|
||||||
active ? "activate" : "deactivate");
|
active ? "activate" : "deactivate");
|
||||||
|
pre_activate (pad, GST_ACTIVATE_NONE);
|
||||||
|
post_activate (pad, GST_ACTIVATE_NONE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -764,36 +766,31 @@ gst_pad_activate_push (GstPad * pad, gboolean active)
|
||||||
pre_activate (pad, new);
|
pre_activate (pad, new);
|
||||||
|
|
||||||
if (GST_PAD_ACTIVATEPUSHFUNC (pad)) {
|
if (GST_PAD_ACTIVATEPUSHFUNC (pad)) {
|
||||||
if (GST_PAD_ACTIVATEPUSHFUNC (pad) (pad, active)) {
|
if (!GST_PAD_ACTIVATEPUSHFUNC (pad) (pad, active)) {
|
||||||
goto success;
|
|
||||||
} else {
|
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* quite ok, element relies on state change func to prepare itself */
|
/* quite ok, element relies on state change func to prepare itself */
|
||||||
goto success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
post_activate (pad, new);
|
||||||
|
|
||||||
|
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in push mode",
|
||||||
|
active ? "activated" : "deactivated");
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
was_ok:
|
was_ok:
|
||||||
{
|
{
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "already %s in push mode",
|
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "already %s in push mode",
|
||||||
active ? "activated" : "deactivated");
|
active ? "activated" : "deactivated");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
success:
|
|
||||||
{
|
|
||||||
post_activate (pad, new);
|
|
||||||
|
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in push mode",
|
|
||||||
active ? "activated" : "deactivated");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
failure:
|
failure:
|
||||||
{
|
{
|
||||||
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");
|
||||||
|
pre_activate (pad, GST_ACTIVATE_NONE);
|
||||||
|
post_activate (pad, GST_ACTIVATE_NONE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue