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>
This commit is contained in:
Edward Hervey 2021-08-18 10:23:38 +02:00 committed by Tim-Philipp Müller
parent a3ebe6c010
commit 0b50501c43
2 changed files with 32 additions and 2 deletions

View file

@ -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)); GST_DEBUG_FUNCPTR_NAME (chainlistfunc), gst_flow_get_name (ret));
} }
pad->ABI.abi.last_flowret = ret;
RELEASE_PARENT (parent); RELEASE_PARENT (parent);
GST_PAD_STREAM_UNLOCK (pad); GST_PAD_STREAM_UNLOCK (pad);
@ -4428,6 +4430,7 @@ flushing:
{ {
GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad,
"chaining, but pad was flushing"); "chaining, but pad was flushing");
pad->ABI.abi.last_flowret = GST_FLOW_FLUSHING;
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
GST_PAD_STREAM_UNLOCK (pad); GST_PAD_STREAM_UNLOCK (pad);
gst_mini_object_unref (GST_MINI_OBJECT_CAST (data)); gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
@ -4436,6 +4439,7 @@ flushing:
eos: eos:
{ {
GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "chaining, but pad was 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_OBJECT_UNLOCK (pad);
GST_PAD_STREAM_UNLOCK (pad); GST_PAD_STREAM_UNLOCK (pad);
gst_mini_object_unref (GST_MINI_OBJECT_CAST (data)); 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", g_critical ("chain on pad %s:%s but it was not in push mode",
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
pad->ABI.abi.last_flowret = GST_FLOW_ERROR;
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
GST_PAD_STREAM_UNLOCK (pad); GST_PAD_STREAM_UNLOCK (pad);
gst_mini_object_unref (GST_MINI_OBJECT_CAST (data)); gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
@ -4455,8 +4460,6 @@ probe_handled:
/* PASSTHROUGH */ /* PASSTHROUGH */
probe_stopped: probe_stopped:
{ {
GST_OBJECT_UNLOCK (pad);
GST_PAD_STREAM_UNLOCK (pad);
/* We unref the buffer, except if the probe handled it (CUSTOM_SUCCESS_1) */ /* We unref the buffer, except if the probe handled it (CUSTOM_SUCCESS_1) */
if (!handled) if (!handled)
gst_mini_object_unref (GST_MINI_OBJECT_CAST (data)); 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)); GST_DEBUG_OBJECT (pad, "an error occurred %s", gst_flow_get_name (ret));
break; break;
} }
pad->ABI.abi.last_flowret = ret;
GST_OBJECT_UNLOCK (pad);
GST_PAD_STREAM_UNLOCK (pad);
return ret; return ret;
} }
no_parent: no_parent:
{ {
GST_DEBUG_OBJECT (pad, "No parent when chaining %" GST_PTR_FORMAT, data); 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_mini_object_unref (GST_MINI_OBJECT_CAST (data));
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
GST_PAD_STREAM_UNLOCK (pad); GST_PAD_STREAM_UNLOCK (pad);
@ -4483,6 +4490,7 @@ no_parent:
} }
no_function: no_function:
{ {
pad->ABI.abi.last_flowret = GST_FLOW_NOT_SUPPORTED;
RELEASE_PARENT (parent); RELEASE_PARENT (parent);
gst_mini_object_unref (GST_MINI_OBJECT_CAST (data)); gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
g_critical ("chain on pad %s:%s but it has no chainfunction", g_critical ("chain on pad %s:%s but it has no chainfunction",

View file

@ -2661,11 +2661,13 @@ GST_START_TEST (test_last_flow_return_push)
/* initial value is flushing */ /* initial value is flushing */
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_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 */ /* when active it goes to ok */
gst_pad_set_active (srcpad, TRUE); gst_pad_set_active (srcpad, TRUE);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK); fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
gst_pad_set_active (sinkpad, TRUE); gst_pad_set_active (sinkpad, TRUE);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
/* startup events */ /* startup events */
gst_pad_push_event (srcpad, gst_event_new_stream_start ("test")); 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; next_return = GST_FLOW_OK;
fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == 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 (srcpad) == GST_FLOW_OK);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
/* push not-linked */ /* push not-linked */
next_return = GST_FLOW_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_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 (srcpad) == GST_FLOW_NOT_LINKED);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_NOT_LINKED);
/* push not-linked */ /* push not-linked */
next_return = GST_FLOW_NOT_NEGOTIATED; 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); gst_buffer_new ()) == GST_FLOW_NOT_NEGOTIATED);
fail_unless (gst_pad_get_last_flow_return (srcpad) == fail_unless (gst_pad_get_last_flow_return (srcpad) ==
GST_FLOW_NOT_NEGOTIATED); GST_FLOW_NOT_NEGOTIATED);
fail_unless (gst_pad_get_last_flow_return (sinkpad) ==
GST_FLOW_NOT_NEGOTIATED);
/* push error */ /* push error */
next_return = GST_FLOW_ERROR; next_return = GST_FLOW_ERROR;
fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == 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 (srcpad) == GST_FLOW_ERROR);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_ERROR);
/* back to ok */ /* back to ok */
next_return = GST_FLOW_OK; next_return = GST_FLOW_OK;
fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == 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 (srcpad) == GST_FLOW_OK);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
/* unlinked push */ /* unlinked push */
gst_pad_unlink (srcpad, sinkpad); gst_pad_unlink (srcpad, sinkpad);
fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == 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 (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); gst_pad_link (srcpad, sinkpad);
fail_unless (gst_pad_push_event (srcpad, gst_event_new_eos ())); 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 (srcpad) == GST_FLOW_EOS);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_EOS);
gst_object_unref (srcpad); gst_object_unref (srcpad);
gst_object_unref (sinkpad); gst_object_unref (sinkpad);
@ -2746,17 +2757,20 @@ GST_START_TEST (test_last_flow_return_pull)
gst_pad_link (srcpad, sinkpad); gst_pad_link (srcpad, sinkpad);
/* initial value is flushing */ /* 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); fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_FLUSHING);
/* when active it goes to ok */ /* when active it goes to ok */
gst_pad_set_active (sinkpad, TRUE); gst_pad_set_active (sinkpad, TRUE);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK); fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
gst_pad_set_active (srcpad, TRUE); gst_pad_set_active (srcpad, TRUE);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
/* pull Ok */ /* pull Ok */
next_return = GST_FLOW_OK; next_return = GST_FLOW_OK;
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == 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 (sinkpad) == GST_FLOW_OK);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
gst_buffer_unref (buf); gst_buffer_unref (buf);
buf = NULL; buf = NULL;
@ -2764,11 +2778,13 @@ GST_START_TEST (test_last_flow_return_pull)
next_return = GST_FLOW_NOT_LINKED; next_return = GST_FLOW_NOT_LINKED;
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == 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 (sinkpad) == GST_FLOW_NOT_LINKED);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_NOT_LINKED);
/* pull error */ /* pull error */
next_return = GST_FLOW_ERROR; next_return = GST_FLOW_ERROR;
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == 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 (sinkpad) == GST_FLOW_ERROR);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_ERROR);
/* pull not-nego */ /* pull not-nego */
next_return = GST_FLOW_NOT_NEGOTIATED; next_return = GST_FLOW_NOT_NEGOTIATED;
@ -2776,11 +2792,14 @@ GST_START_TEST (test_last_flow_return_pull)
&buf) == GST_FLOW_NOT_NEGOTIATED); &buf) == GST_FLOW_NOT_NEGOTIATED);
fail_unless (gst_pad_get_last_flow_return (sinkpad) == fail_unless (gst_pad_get_last_flow_return (sinkpad) ==
GST_FLOW_NOT_NEGOTIATED); GST_FLOW_NOT_NEGOTIATED);
fail_unless (gst_pad_get_last_flow_return (srcpad) ==
GST_FLOW_NOT_NEGOTIATED);
/* pull ok again */ /* pull ok again */
next_return = GST_FLOW_OK; next_return = GST_FLOW_OK;
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == 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 (sinkpad) == GST_FLOW_OK);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
gst_buffer_unref (buf); gst_buffer_unref (buf);
buf = NULL; buf = NULL;
@ -2788,12 +2807,15 @@ GST_START_TEST (test_last_flow_return_pull)
gst_pad_unlink (srcpad, sinkpad); gst_pad_unlink (srcpad, sinkpad);
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == 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 (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 */ /* eos */
gst_pad_link (srcpad, sinkpad); gst_pad_link (srcpad, sinkpad);
next_return = GST_FLOW_EOS; next_return = GST_FLOW_EOS;
fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == 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 (sinkpad) == GST_FLOW_EOS);
fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_EOS);
gst_object_unref (srcpad); gst_object_unref (srcpad);
gst_object_unref (sinkpad); gst_object_unref (sinkpad);