mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 11:55:39 +00:00
tests: pad: test that idle probe will block
This tests add an idle probe on an idle pad from a separate thread so that the callback is called immediatelly. This callback will sit still and then we try to push a buffer on this same pad. It verifies that the idle probe blocks data passing https://bugzilla.gnome.org/show_bug.cgi?id=747852
This commit is contained in:
parent
3d8de8a4f9
commit
d4d161a282
1 changed files with 83 additions and 0 deletions
|
@ -1144,6 +1144,88 @@ GST_START_TEST (test_pad_blocking_with_probe_type_blocking)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
static gboolean idle_probe_running;
|
||||
|
||||
static GstFlowReturn
|
||||
idletest_sink_pad_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||
{
|
||||
if (idle_probe_running)
|
||||
fail ("Should not be reached");
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
static GstPadProbeReturn
|
||||
idle_probe_wait (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
||||
{
|
||||
/* it is ok to have a probe called multiple times but it is not
|
||||
* acceptable in our scenario */
|
||||
fail_if (idle_probe_running);
|
||||
|
||||
idle_probe_running = TRUE;
|
||||
while (idle_probe_running) {
|
||||
g_usleep (10000);
|
||||
}
|
||||
|
||||
return GST_PAD_PROBE_REMOVE;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
add_idle_probe_async (GstPad * pad)
|
||||
{
|
||||
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_IDLE, idle_probe_wait, NULL, NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GST_START_TEST (test_pad_blocking_with_probe_type_idle)
|
||||
{
|
||||
GstPad *srcpad, *sinkpad;
|
||||
GThread *idle_thread, *thread;
|
||||
|
||||
srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
fail_unless (srcpad != NULL);
|
||||
sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
||||
fail_unless (sinkpad != NULL);
|
||||
|
||||
gst_pad_set_chain_function (sinkpad, idletest_sink_pad_chain);
|
||||
|
||||
fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK);
|
||||
|
||||
gst_pad_set_active (sinkpad, TRUE);
|
||||
gst_pad_set_active (srcpad, TRUE);
|
||||
|
||||
fail_unless (gst_pad_push_event (srcpad,
|
||||
gst_event_new_stream_start ("test")) == TRUE);
|
||||
fail_unless (gst_pad_push_event (srcpad,
|
||||
gst_event_new_segment (&dummy_segment)) == TRUE);
|
||||
|
||||
idle_probe_running = FALSE;
|
||||
idle_thread =
|
||||
g_thread_try_new ("gst-check", (GThreadFunc) add_idle_probe_async, srcpad,
|
||||
NULL);
|
||||
|
||||
/* wait for the idle function to signal it is being called */
|
||||
while (!idle_probe_running) {
|
||||
g_usleep (10000);
|
||||
}
|
||||
|
||||
thread = g_thread_try_new ("gst-check", (GThreadFunc) push_buffer_async,
|
||||
srcpad, NULL);
|
||||
|
||||
while (!gst_pad_is_blocking (srcpad)) {
|
||||
g_usleep (10000);
|
||||
}
|
||||
|
||||
idle_probe_running = FALSE;
|
||||
|
||||
g_thread_join (idle_thread);
|
||||
g_thread_join (thread);
|
||||
gst_object_unref (srcpad);
|
||||
gst_object_unref (sinkpad);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static gboolean pad_probe_remove_notifiy_called = FALSE;
|
||||
|
||||
static GstPadProbeReturn
|
||||
|
@ -2160,6 +2242,7 @@ gst_pad_suite (void)
|
|||
tcase_add_test (tc_chain, test_block_async);
|
||||
tcase_add_test (tc_chain, test_pad_blocking_with_probe_type_block);
|
||||
tcase_add_test (tc_chain, test_pad_blocking_with_probe_type_blocking);
|
||||
tcase_add_test (tc_chain, test_pad_blocking_with_probe_type_idle);
|
||||
tcase_add_test (tc_chain, test_pad_probe_remove);
|
||||
tcase_add_test (tc_chain, test_pad_probe_block_add_remove);
|
||||
tcase_add_test (tc_chain, test_pad_probe_block_and_drop_buffer);
|
||||
|
|
Loading…
Reference in a new issue