mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
Test that removing probes from within the probe functions works.
Original commit message from CVS: (test_buffer_probe_once): Test that removing probes from within the probe functions works.
This commit is contained in:
parent
dbeb99cc27
commit
7be2b34bc6
3 changed files with 154 additions and 0 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
* check/gst/gstutils.c (test_buffer_probe_n_times): Add tests for
|
||||
data and event probes on the same pad.
|
||||
(test_buffer_probe_once): Test that removing probes from within
|
||||
the probe functions works.
|
||||
|
||||
2005-09-21 Andy Wingo <wingo@pobox.com>
|
||||
|
||||
|
|
|
@ -92,6 +92,81 @@ GST_START_TEST (test_buffer_probe_n_times)
|
|||
g_assert (n_data_probes == 12); /* duh */
|
||||
} GST_END_TEST;
|
||||
|
||||
static int n_data_probes_once = 0;
|
||||
static int n_buffer_probes_once = 0;
|
||||
static int n_event_probes_once = 0;
|
||||
|
||||
static gboolean
|
||||
data_probe_once (GstPad * pad, GstMiniObject * obj, guint * data)
|
||||
{
|
||||
n_data_probes_once++;
|
||||
g_assert (GST_IS_MINI_OBJECT (obj));
|
||||
|
||||
gst_pad_remove_data_probe (pad, *data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
buffer_probe_once (GstPad * pad, GstBuffer * obj, guint * data)
|
||||
{
|
||||
n_buffer_probes_once++;
|
||||
g_assert (GST_IS_BUFFER (obj));
|
||||
|
||||
gst_pad_remove_buffer_probe (pad, *data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_probe_once (GstPad * pad, GstEvent * obj, guint * data)
|
||||
{
|
||||
n_event_probes_once++;
|
||||
g_assert (GST_IS_EVENT (obj));
|
||||
|
||||
gst_pad_remove_event_probe (pad, *data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GST_START_TEST (test_buffer_probe_once)
|
||||
{
|
||||
GstElement *pipeline, *fakesrc, *fakesink;
|
||||
GstBus *bus;
|
||||
GstMessage *message;
|
||||
GstPad *pad;
|
||||
guint id1, id2, id3;
|
||||
|
||||
pipeline = gst_element_factory_make ("pipeline", NULL);
|
||||
fakesrc = gst_element_factory_make ("fakesrc", NULL);
|
||||
fakesink = gst_element_factory_make ("fakesink", NULL);
|
||||
|
||||
g_object_set (fakesrc, "num-buffers", (int) 10, NULL);
|
||||
|
||||
gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL);
|
||||
gst_element_link (fakesrc, fakesink);
|
||||
|
||||
pad = gst_element_get_pad (fakesink, "sink");
|
||||
id1 = gst_pad_add_data_probe (pad, G_CALLBACK (data_probe_once), &id1);
|
||||
id2 = gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe_once), &id2);
|
||||
id3 = gst_pad_add_event_probe (pad, G_CALLBACK (event_probe_once), &id3);
|
||||
gst_object_unref (pad);
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
|
||||
bus = gst_element_get_bus (pipeline);
|
||||
message = gst_bus_poll (bus, GST_MESSAGE_EOS, -1);
|
||||
gst_message_unref (message);
|
||||
gst_object_unref (bus);
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||
gst_object_unref (pipeline);
|
||||
|
||||
g_assert (n_buffer_probes_once == 1); /* can we hit it and quit? */
|
||||
g_assert (n_event_probes_once == 1); /* i said, can we hit it and quit? */
|
||||
g_assert (n_data_probes_once == 1); /* let's hit it and quit!!! */
|
||||
} GST_END_TEST;
|
||||
|
||||
Suite *
|
||||
gst_utils_suite (void)
|
||||
{
|
||||
|
@ -100,6 +175,7 @@ gst_utils_suite (void)
|
|||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, test_buffer_probe_n_times);
|
||||
tcase_add_test (tc_chain, test_buffer_probe_once);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,81 @@ GST_START_TEST (test_buffer_probe_n_times)
|
|||
g_assert (n_data_probes == 12); /* duh */
|
||||
} GST_END_TEST;
|
||||
|
||||
static int n_data_probes_once = 0;
|
||||
static int n_buffer_probes_once = 0;
|
||||
static int n_event_probes_once = 0;
|
||||
|
||||
static gboolean
|
||||
data_probe_once (GstPad * pad, GstMiniObject * obj, guint * data)
|
||||
{
|
||||
n_data_probes_once++;
|
||||
g_assert (GST_IS_MINI_OBJECT (obj));
|
||||
|
||||
gst_pad_remove_data_probe (pad, *data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
buffer_probe_once (GstPad * pad, GstBuffer * obj, guint * data)
|
||||
{
|
||||
n_buffer_probes_once++;
|
||||
g_assert (GST_IS_BUFFER (obj));
|
||||
|
||||
gst_pad_remove_buffer_probe (pad, *data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_probe_once (GstPad * pad, GstEvent * obj, guint * data)
|
||||
{
|
||||
n_event_probes_once++;
|
||||
g_assert (GST_IS_EVENT (obj));
|
||||
|
||||
gst_pad_remove_event_probe (pad, *data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GST_START_TEST (test_buffer_probe_once)
|
||||
{
|
||||
GstElement *pipeline, *fakesrc, *fakesink;
|
||||
GstBus *bus;
|
||||
GstMessage *message;
|
||||
GstPad *pad;
|
||||
guint id1, id2, id3;
|
||||
|
||||
pipeline = gst_element_factory_make ("pipeline", NULL);
|
||||
fakesrc = gst_element_factory_make ("fakesrc", NULL);
|
||||
fakesink = gst_element_factory_make ("fakesink", NULL);
|
||||
|
||||
g_object_set (fakesrc, "num-buffers", (int) 10, NULL);
|
||||
|
||||
gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL);
|
||||
gst_element_link (fakesrc, fakesink);
|
||||
|
||||
pad = gst_element_get_pad (fakesink, "sink");
|
||||
id1 = gst_pad_add_data_probe (pad, G_CALLBACK (data_probe_once), &id1);
|
||||
id2 = gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe_once), &id2);
|
||||
id3 = gst_pad_add_event_probe (pad, G_CALLBACK (event_probe_once), &id3);
|
||||
gst_object_unref (pad);
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
|
||||
bus = gst_element_get_bus (pipeline);
|
||||
message = gst_bus_poll (bus, GST_MESSAGE_EOS, -1);
|
||||
gst_message_unref (message);
|
||||
gst_object_unref (bus);
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||
gst_object_unref (pipeline);
|
||||
|
||||
g_assert (n_buffer_probes_once == 1); /* can we hit it and quit? */
|
||||
g_assert (n_event_probes_once == 1); /* i said, can we hit it and quit? */
|
||||
g_assert (n_data_probes_once == 1); /* let's hit it and quit!!! */
|
||||
} GST_END_TEST;
|
||||
|
||||
Suite *
|
||||
gst_utils_suite (void)
|
||||
{
|
||||
|
@ -100,6 +175,7 @@ gst_utils_suite (void)
|
|||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, test_buffer_probe_n_times);
|
||||
tcase_add_test (tc_chain, test_buffer_probe_once);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue