summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2021-08-18 10:23:38 +0200
committerTim-Philipp Müller <tim@centricular.com>2021-08-18 20:33:48 +0100
commit0b50501c43f5e708e712470acd2e7bd372ff7a12 (patch)
tree78d6e3a8daf6da075be232d4545a3eb93f9a47bd
parenta3ebe6c0106c9f49f10b47b08b5b8e548376baa6 (diff)
downloadgstreamer-0b50501c43f5e708e712470acd2e7bd372ff7a12.tar.gz
pad: Ensure last flow return is set on sink pads in push mode
The last flow return field was never updated on sink pads in push mode. This fixes it and makes it consistent. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/870>
-rw-r--r--gst/gstpad.c12
-rw-r--r--tests/check/gst/gstpad.c22
2 files changed, 32 insertions, 2 deletions
diff --git a/gst/gstpad.c b/gst/gstpad.c
index 8789f92614..83568fec25 100644
--- a/gst/gstpad.c
+++ b/gst/gstpad.c
@@ -4417,6 +4417,8 @@ gst_pad_chain_data_unchecked (GstPad * pad, GstPadProbeType type, void *data)
GST_DEBUG_FUNCPTR_NAME (chainlistfunc), gst_flow_get_name (ret));
}
+ pad->ABI.abi.last_flowret = ret;
+
RELEASE_PARENT (parent);
GST_PAD_STREAM_UNLOCK (pad);
@@ -4428,6 +4430,7 @@ flushing:
{
GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad,
"chaining, but pad was flushing");
+ pad->ABI.abi.last_flowret = GST_FLOW_FLUSHING;
GST_OBJECT_UNLOCK (pad);
GST_PAD_STREAM_UNLOCK (pad);
gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
@@ -4436,6 +4439,7 @@ flushing:
eos:
{
GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "chaining, but pad was EOS");
+ pad->ABI.abi.last_flowret = GST_FLOW_EOS;
GST_OBJECT_UNLOCK (pad);
GST_PAD_STREAM_UNLOCK (pad);
gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
@@ -4445,6 +4449,7 @@ wrong_mode:
{
g_critical ("chain on pad %s:%s but it was not in push mode",
GST_DEBUG_PAD_NAME (pad));
+ pad->ABI.abi.last_flowret = GST_FLOW_ERROR;
GST_OBJECT_UNLOCK (pad);
GST_PAD_STREAM_UNLOCK (pad);
gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
@@ -4455,8 +4460,6 @@ probe_handled:
/* PASSTHROUGH */
probe_stopped:
{
- GST_OBJECT_UNLOCK (pad);
- GST_PAD_STREAM_UNLOCK (pad);
/* We unref the buffer, except if the probe handled it (CUSTOM_SUCCESS_1) */
if (!handled)
gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
@@ -4471,11 +4474,15 @@ probe_stopped:
GST_DEBUG_OBJECT (pad, "an error occurred %s", gst_flow_get_name (ret));
break;
}
+ pad->ABI.abi.last_flowret = ret;
+ GST_OBJECT_UNLOCK (pad);
+ GST_PAD_STREAM_UNLOCK (pad);
return ret;
}
no_parent:
{
GST_DEBUG_OBJECT (pad, "No parent when chaining %" GST_PTR_FORMAT, data);
+ pad->ABI.abi.last_flowret = GST_FLOW_FLUSHING;
gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
GST_OBJECT_UNLOCK (pad);
GST_PAD_STREAM_UNLOCK (pad);
@@ -4483,6 +4490,7 @@ no_parent:
}
no_function:
{
+ pad->ABI.abi.last_flowret = GST_FLOW_NOT_SUPPORTED;
RELEASE_PARENT (parent);
gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
g_critical ("chain on pad %s:%s but it has no chainfunction",
diff --git a/tests/check/gst/gstpad.c b/tests/check/gst/gstpad.c
index 004ff1e9ae..2b99a21568 100644
--- a/tests/check/gst/gstpad.c
+++ b/tests/check/gst/gstpad.c
@@ -2661,11 +2661,13 @@ GST_START_TEST (test_last_flow_return_push)
/* initial value is flushing */
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_FLUSHING);
+ fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_FLUSHING);
/* when active it goes to ok */
gst_pad_set_active (srcpad, TRUE);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
gst_pad_set_active (sinkpad, TRUE);
+ fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
/* startup events */
gst_pad_push_event (srcpad, gst_event_new_stream_start ("test"));
@@ -2677,11 +2679,13 @@ GST_START_TEST (test_last_flow_return_push)
next_return = GST_FLOW_OK;
fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_OK);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
+ fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
/* push not-linked */
next_return = GST_FLOW_NOT_LINKED;
fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_NOT_LINKED);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_NOT_LINKED);
+ fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_NOT_LINKED);
/* push not-linked */
next_return = GST_FLOW_NOT_NEGOTIATED;
@@ -2689,25 +2693,32 @@ GST_START_TEST (test_last_flow_return_push)
gst_buffer_new ()) == GST_FLOW_NOT_NEGOTIATED);
fail_unless (gst_pad_get_last_flow_return (srcpad) ==
GST_FLOW_NOT_NEGOTIATED);
+ fail_unless (gst_pad_get_last_flow_return (sinkpad) ==
+ GST_FLOW_NOT_NEGOTIATED);
/* push error */
next_return = GST_FLOW_ERROR;
fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_ERROR);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_ERROR);
+ fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_ERROR);
/* back to ok */
next_return = GST_FLOW_OK;
fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_OK);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
+ fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
/* unlinked push */
gst_pad_unlink (srcpad, sinkpad);
fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_NOT_LINKED);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_NOT_LINKED);
+ /* The last flow ret from the peer pad shouldn't have changed */
+ fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
gst_pad_link (srcpad, sinkpad);
fail_unless (gst_pad_push_event (srcpad, gst_event_new_eos ()));
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_EOS);
+ fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_EOS);
gst_object_unref (srcpad);
gst_object_unref (sinkpad);
@@ -2746,17 +2757,20 @@ GST_START_TEST (test_last_flow_return_pull)
gst_pad_link (srcpad, sinkpad);
/* initial value is flushing */
+ fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_FLUSHING);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_FLUSHING);
/* when active it goes to ok */
gst_pad_set_active (sinkpad, TRUE);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
gst_pad_set_active (srcpad, TRUE);
+ fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
/* pull Ok */
next_return = GST_FLOW_OK;
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_OK);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
+ fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
gst_buffer_unref (buf);
buf = NULL;
@@ -2764,11 +2778,13 @@ GST_START_TEST (test_last_flow_return_pull)
next_return = GST_FLOW_NOT_LINKED;
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_NOT_LINKED);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_NOT_LINKED);
+ fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_NOT_LINKED);
/* pull error */
next_return = GST_FLOW_ERROR;
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_ERROR);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_ERROR);
+ fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_ERROR);
/* pull not-nego */
next_return = GST_FLOW_NOT_NEGOTIATED;
@@ -2776,11 +2792,14 @@ GST_START_TEST (test_last_flow_return_pull)
&buf) == GST_FLOW_NOT_NEGOTIATED);
fail_unless (gst_pad_get_last_flow_return (sinkpad) ==
GST_FLOW_NOT_NEGOTIATED);
+ fail_unless (gst_pad_get_last_flow_return (srcpad) ==
+ GST_FLOW_NOT_NEGOTIATED);
/* pull ok again */
next_return = GST_FLOW_OK;
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_OK);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
+ fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
gst_buffer_unref (buf);
buf = NULL;
@@ -2788,12 +2807,15 @@ GST_START_TEST (test_last_flow_return_pull)
gst_pad_unlink (srcpad, sinkpad);
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_NOT_LINKED);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_NOT_LINKED);
+ /* Return value for the remote pad didn't change */
+ fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
/* eos */
gst_pad_link (srcpad, sinkpad);
next_return = GST_FLOW_EOS;
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_EOS);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_EOS);
+ fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_EOS);
gst_object_unref (srcpad);
gst_object_unref (sinkpad);