summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPhilippe Normand <philn@igalia.com>2015-11-04 12:02:51 +0100
committerThiago Santos <thiagoss@osg.samsung.com>2015-11-06 12:32:10 -0300
commit8ae8b2723d0cf179a4f09b2f6c5f797e2d97034d (patch)
tree51758e4a46f5ddb815973d155c7109fd6996f05f /tests
parent533d0ac7f1d8dea1d2915a359225184302c74fc9 (diff)
queue2: add overrun signal
Notifies that the queue2 is full, same as queue does https://bugzilla.gnome.org/show_bug.cgi?id=733959
Diffstat (limited to 'tests')
-rw-r--r--tests/check/elements/queue2.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/check/elements/queue2.c b/tests/check/elements/queue2.c
index 18170c1b2..4970f0349 100644
--- a/tests/check/elements/queue2.c
+++ b/tests/check/elements/queue2.c
@@ -269,6 +269,77 @@ GST_START_TEST (test_filled_read)
GST_END_TEST;
+static gint overrun_count;
+
+static void
+queue_overrun (GstElement * queue, gpointer user_data)
+{
+ overrun_count++;
+ GST_DEBUG ("queue overrun %d", overrun_count);
+}
+
+static gpointer
+pull_buffer (GstPad * srcpad)
+{
+ GstBuffer *buffer = NULL;
+ gst_pad_get_range (srcpad, 0, 1024, &buffer);
+ gst_buffer_unref (buffer);
+ return NULL;
+}
+
+GST_START_TEST (test_overrun)
+{
+ GstElement *queue2;
+ GstBuffer *buffer;
+ GstPad *sinkpad, *srcpad;
+ GstSegment segment;
+ GThread *thread;
+
+ overrun_count = 0;
+ queue2 = gst_element_factory_make ("queue2", NULL);
+ sinkpad = gst_element_get_static_pad (queue2, "sink");
+ srcpad = gst_element_get_static_pad (queue2, "src");
+
+ g_signal_connect (queue2, "overrun", G_CALLBACK (queue_overrun), srcpad);
+ g_object_set (queue2, "ring-buffer-max-size", (guint64) 4 * 1024,
+ "use-buffering", FALSE,
+ "max-size-buffers", (guint) 0, "max-size-time", (guint64) 0,
+ "max-size-bytes", (guint) 4 * 1024, NULL);
+
+
+ gst_pad_activate_mode (srcpad, GST_PAD_MODE_PULL, TRUE);
+ gst_element_set_state (queue2, GST_STATE_PLAYING);
+
+ gst_segment_init (&segment, GST_FORMAT_BYTES);
+ gst_pad_send_event (sinkpad, gst_event_new_stream_start ("test"));
+ gst_pad_send_event (sinkpad, gst_event_new_segment (&segment));
+
+ /* Fill the queue */
+ buffer = gst_buffer_new_and_alloc (4 * 1024);
+ fail_unless (gst_pad_chain (sinkpad, buffer) == GST_FLOW_OK);
+
+
+ /* Make sure the queue doesn't remain full */
+ thread =
+ g_thread_try_new ("gst-check", (GThreadFunc) pull_buffer, srcpad, NULL);
+ fail_unless (thread != NULL);
+
+ /* Push a new buffer in the full queue, should trigger overrun */
+ buffer = gst_buffer_new_and_alloc (1024);
+ fail_unless (gst_pad_chain (sinkpad, buffer) == GST_FLOW_OK);
+ fail_unless (overrun_count == 1);
+
+ g_thread_join (thread);
+
+ gst_element_set_state (queue2, GST_STATE_NULL);
+
+ gst_object_unref (sinkpad);
+ gst_object_unref (srcpad);
+ gst_object_unref (queue2);
+}
+
+GST_END_TEST;
+
static Suite *
queue2_suite (void)
@@ -283,6 +354,7 @@ queue2_suite (void)
tcase_add_test (tc_chain, test_simple_shutdown_while_running);
tcase_add_test (tc_chain, test_simple_shutdown_while_running_ringbuffer);
tcase_add_test (tc_chain, test_filled_read);
+ tcase_add_test (tc_chain, test_overrun);
return s;
}