Commit 5cd24095 authored by Sebastian Dröge's avatar Sebastian Dröge
Browse files

imagefreeze: Fix race conditions in the unit test

If setting the pipeline to PLAYING before issuing the seek, buffers
are already arriving at the sink before the seek is handled and
will have the wrong timestamps and everything.

Fixes bug #625547.
parent 86403e85
......@@ -104,6 +104,9 @@ sink_handoff_cb_0_1 (GstElement * object, GstBuffer * buffer, GstPad * pad,
{
guint *n_buffers = (guint *) user_data;
if (*n_buffers == G_MAXUINT)
return;
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (buffer), 0);
fail_unless_equals_uint64 (GST_BUFFER_DURATION (buffer), GST_CLOCK_TIME_NONE);
fail_unless_equals_uint64 (GST_BUFFER_OFFSET (buffer), 0);
......@@ -118,7 +121,7 @@ GST_START_TEST (test_imagefreeze_0_1)
GstCaps *caps1, *caps2;
GstBus *bus;
GMainLoop *loop;
guint n_buffers = 0;
guint n_buffers = G_MAXUINT;
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
......@@ -137,6 +140,7 @@ GST_START_TEST (test_imagefreeze_0_1)
gst_bus_add_watch (bus, bus_handler, loop);
gst_object_unref (bus);
n_buffers = 0;
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
GST_STATE_CHANGE_SUCCESS);
......@@ -160,6 +164,9 @@ sink_handoff_cb_25_1_0ms_400ms (GstElement * object, GstBuffer * buffer,
{
guint *n_buffers = (guint *) user_data;
if (*n_buffers == G_MAXUINT)
return;
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (buffer),
*n_buffers * 40 * GST_MSECOND);
fail_unless_equals_uint64 (GST_BUFFER_DURATION (buffer), 40 * GST_MSECOND);
......@@ -175,7 +182,7 @@ GST_START_TEST (test_imagefreeze_25_1_0ms_400ms)
GstCaps *caps1, *caps2;
GstBus *bus;
GMainLoop *loop;
guint n_buffers = 0;
guint n_buffers = G_MAXUINT;
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
......@@ -194,13 +201,15 @@ GST_START_TEST (test_imagefreeze_25_1_0ms_400ms)
gst_bus_add_watch (bus, bus_handler, loop);
gst_object_unref (bus);
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PAUSED),
GST_STATE_CHANGE_SUCCESS);
fail_unless (gst_element_seek (pipeline, 1.0, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET,
400 * GST_MSECOND));
n_buffers = 0;
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
GST_STATE_CHANGE_SUCCESS);
......@@ -224,6 +233,9 @@ sink_handoff_cb_25_1_200ms_400ms (GstElement * object, GstBuffer * buffer,
{
guint *n_buffers = (guint *) user_data;
if (*n_buffers == G_MAXUINT)
return;
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (buffer),
200 * GST_MSECOND + *n_buffers * 40 * GST_MSECOND);
fail_unless_equals_uint64 (GST_BUFFER_DURATION (buffer), 40 * GST_MSECOND);
......@@ -240,7 +252,7 @@ GST_START_TEST (test_imagefreeze_25_1_200ms_400ms)
GstCaps *caps1, *caps2;
GstBus *bus;
GMainLoop *loop;
guint n_buffers = 0;
guint n_buffers = G_MAXUINT;
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
......@@ -259,13 +271,15 @@ GST_START_TEST (test_imagefreeze_25_1_200ms_400ms)
gst_bus_add_watch (bus, bus_handler, loop);
gst_object_unref (bus);
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PAUSED),
GST_STATE_CHANGE_SUCCESS);
fail_unless (gst_element_seek (pipeline, 1.0, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 200 * GST_MSECOND,
GST_SEEK_TYPE_SET, 400 * GST_MSECOND));
n_buffers = 0;
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
GST_STATE_CHANGE_SUCCESS);
......@@ -289,6 +303,9 @@ sink_handoff_cb_25_1_400ms_0ms (GstElement * object, GstBuffer * buffer,
{
guint *n_buffers = (guint *) user_data;
if (*n_buffers == G_MAXUINT)
return;
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (buffer),
400 * GST_MSECOND - (*n_buffers + 1) * 40 * GST_MSECOND);
fail_unless_equals_uint64 (GST_BUFFER_DURATION (buffer), 40 * GST_MSECOND);
......@@ -305,7 +322,7 @@ GST_START_TEST (test_imagefreeze_25_1_400ms_0ms)
GstCaps *caps1, *caps2;
GstBus *bus;
GMainLoop *loop;
guint n_buffers = 0;
guint n_buffers = G_MAXUINT;
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
......@@ -324,13 +341,15 @@ GST_START_TEST (test_imagefreeze_25_1_400ms_0ms)
gst_bus_add_watch (bus, bus_handler, loop);
gst_object_unref (bus);
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PAUSED),
GST_STATE_CHANGE_SUCCESS);
fail_unless (gst_element_seek (pipeline, -1.0, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET,
400 * GST_MSECOND));
n_buffers = 0;
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
GST_STATE_CHANGE_SUCCESS);
......@@ -354,6 +373,9 @@ sink_handoff_cb_25_1_220ms_380ms (GstElement * object, GstBuffer * buffer,
{
guint *n_buffers = (guint *) user_data;
if (*n_buffers == G_MAXUINT)
return;
if (*n_buffers == 0) {
fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (buffer),
220 * GST_MSECOND);
......@@ -381,7 +403,7 @@ GST_START_TEST (test_imagefreeze_25_1_220ms_380ms)
GstCaps *caps1, *caps2;
GstBus *bus;
GMainLoop *loop;
guint n_buffers = 0;
guint n_buffers = G_MAXUINT;
caps1 =
gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB, 640, 480, 25, 1, 1, 1);
......@@ -400,13 +422,15 @@ GST_START_TEST (test_imagefreeze_25_1_220ms_380ms)
gst_bus_add_watch (bus, bus_handler, loop);
gst_object_unref (bus);
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PAUSED),
GST_STATE_CHANGE_SUCCESS);
fail_unless (gst_element_seek (pipeline, 1.0, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 220 * GST_MSECOND,
GST_SEEK_TYPE_SET, 380 * GST_MSECOND));
n_buffers = 0;
fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
GST_STATE_CHANGE_SUCCESS);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment