diff --git a/tests/check/elements/audiomixer.c b/tests/check/elements/audiomixer.c index dd2ae2ae14..e8ad5e3d6f 100644 --- a/tests/check/elements/audiomixer.c +++ b/tests/check/elements/audiomixer.c @@ -55,97 +55,63 @@ test_teardown (void) main_loop = NULL; } -/* make sure downstream gets a CAPS event before buffers are sent */ -GST_START_TEST (test_caps) + +/* some test helpers */ + +static GstElement * +setup_pipeline (GstElement * audiomixer, gint num_srcs) { - GstElement *pipeline, *src, *audiomixer, *sink; - GstStateChangeReturn state_res; + GstElement *pipeline, *src, *sink; + gint i; + + pipeline = gst_pipeline_new ("pipeline"); + if (!audiomixer) { + audiomixer = gst_element_factory_make ("audiomixer", "audiomixer"); + } + + sink = gst_element_factory_make ("fakesink", "sink"); + gst_bin_add_many (GST_BIN (pipeline), audiomixer, sink, NULL); + gst_element_link (audiomixer, sink); + + for (i = 0; i < num_srcs; i++) { + src = gst_element_factory_make ("audiotestsrc", NULL); + g_object_set (src, "wave", 4, NULL); /* silence */ + gst_bin_add (GST_BIN (pipeline), src); + gst_element_link (src, audiomixer); + } + return pipeline; +} + +static GstCaps * +get_element_sink_pad_caps (GstElement * pipeline, const gchar * element_name) +{ + GstElement *sink; GstCaps *caps; GstPad *pad; - /* build pipeline */ - pipeline = gst_pipeline_new ("pipeline"); - - src = gst_element_factory_make ("audiotestsrc", "src1"); - g_object_set (src, "wave", 4, NULL); /* silence */ - audiomixer = gst_element_factory_make ("audiomixer", "audiomixer"); - sink = gst_element_factory_make ("fakesink", "sink"); - gst_bin_add_many (GST_BIN (pipeline), src, audiomixer, sink, NULL); - - fail_unless (gst_element_link_many (src, audiomixer, sink, NULL)); - - /* prepare playing */ - state_res = gst_element_set_state (pipeline, GST_STATE_PAUSED); - fail_unless_equals_int (state_res, GST_STATE_CHANGE_ASYNC); - - /* wait for preroll */ - state_res = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); - fail_unless_equals_int (state_res, GST_STATE_CHANGE_SUCCESS); - - /* check caps on fakesink */ + sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); pad = gst_element_get_static_pad (sink, "sink"); caps = gst_pad_get_current_caps (pad); - fail_unless (caps != NULL); - gst_caps_unref (caps); gst_object_unref (pad); + gst_object_unref (sink); - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); + return caps; } -GST_END_TEST; - -/* check that caps set on the property are honoured */ -GST_START_TEST (test_filter_caps) +static void +set_state_and_wait (GstElement * pipeline, GstState state) { - GstElement *pipeline, *src, *audiomixer, *sink; GstStateChangeReturn state_res; - GstCaps *filter_caps, *caps; - GstPad *pad; - filter_caps = gst_caps_new_simple ("audio/x-raw", - "format", G_TYPE_STRING, GST_AUDIO_NE (F32), - "layout", G_TYPE_STRING, "interleaved", - "rate", G_TYPE_INT, 44100, "channels", G_TYPE_INT, 1, - "channel-mask", GST_TYPE_BITMASK, (guint64) 0x04, NULL); - - /* build pipeline */ - pipeline = gst_pipeline_new ("pipeline"); - - src = gst_element_factory_make ("audiotestsrc", NULL); - g_object_set (src, "wave", 4, NULL); /* silence */ - audiomixer = gst_element_factory_make ("audiomixer", NULL); - g_object_set (audiomixer, "caps", filter_caps, NULL); - sink = gst_element_factory_make ("fakesink", "sink"); - gst_bin_add_many (GST_BIN (pipeline), src, audiomixer, sink, NULL); - - fail_unless (gst_element_link_many (src, audiomixer, sink, NULL)); - - /* prepare playing */ - state_res = gst_element_set_state (pipeline, GST_STATE_PAUSED); - fail_unless_equals_int (state_res, GST_STATE_CHANGE_ASYNC); + /* prepare paused/playing */ + state_res = gst_element_set_state (pipeline, state); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* wait for preroll */ state_res = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE); - fail_unless_equals_int (state_res, GST_STATE_CHANGE_SUCCESS); - - /* check caps on fakesink */ - pad = gst_element_get_static_pad (sink, "sink"); - caps = gst_pad_get_current_caps (pad); - fail_unless (caps != NULL); - GST_INFO_OBJECT (pipeline, "received caps: %" GST_PTR_FORMAT, caps); - fail_unless (gst_caps_is_equal_fixed (caps, filter_caps)); - gst_caps_unref (caps); - gst_object_unref (pad); - - gst_element_set_state (pipeline, GST_STATE_NULL); - gst_object_unref (pipeline); - - gst_caps_unref (filter_caps); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); } -GST_END_TEST; - static gboolean set_playing (GstElement * element) { @@ -157,6 +123,20 @@ set_playing (GstElement * element) return FALSE; } +static void +play_and_wait (GstElement * pipeline) +{ + GstStateChangeReturn state_res; + + g_idle_add ((GSourceFunc) set_playing, pipeline); + + GST_INFO ("running main loop"); + g_main_loop_run (main_loop); + + state_res = gst_element_set_state (pipeline, GST_STATE_NULL); + ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); +} + static void message_received (GstBus * bus, GstMessage * message, GstPipeline * bin) { @@ -194,6 +174,64 @@ message_received (GstBus * bus, GstMessage * message, GstPipeline * bin) } +/* make sure downstream gets a CAPS event before buffers are sent */ +GST_START_TEST (test_caps) +{ + GstElement *pipeline; + GstCaps *caps; + + /* build pipeline */ + pipeline = setup_pipeline (NULL, 1); + + /* prepare playing */ + set_state_and_wait (pipeline, GST_STATE_PAUSED); + + /* check caps on fakesink */ + caps = get_element_sink_pad_caps (pipeline, "sink"); + fail_unless (caps != NULL); + gst_caps_unref (caps); + + gst_element_set_state (pipeline, GST_STATE_NULL); + gst_object_unref (pipeline); +} + +GST_END_TEST; + +/* check that caps set on the property are honoured */ +GST_START_TEST (test_filter_caps) +{ + GstElement *pipeline, *audiomixer; + GstCaps *filter_caps, *caps; + + filter_caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, GST_AUDIO_NE (F32), + "layout", G_TYPE_STRING, "interleaved", + "rate", G_TYPE_INT, 44100, "channels", G_TYPE_INT, 1, + "channel-mask", GST_TYPE_BITMASK, (guint64) 0x04, NULL); + + /* build pipeline */ + audiomixer = gst_element_factory_make ("audiomixer", NULL); + g_object_set (audiomixer, "caps", filter_caps, NULL); + pipeline = setup_pipeline (audiomixer, 1); + + /* prepare playing */ + set_state_and_wait (pipeline, GST_STATE_PAUSED); + + /* check caps on fakesink */ + caps = get_element_sink_pad_caps (pipeline, "sink"); + fail_unless (caps != NULL); + GST_INFO_OBJECT (pipeline, "received caps: %" GST_PTR_FORMAT, caps); + fail_unless (gst_caps_is_equal_fixed (caps, filter_caps)); + gst_caps_unref (caps); + + gst_element_set_state (pipeline, GST_STATE_NULL); + gst_object_unref (pipeline); + + gst_caps_unref (filter_caps); +} + +GST_END_TEST; + static GstFormat format = GST_FORMAT_UNDEFINED; static gint64 position = -1; @@ -222,7 +260,6 @@ GST_START_TEST (test_event) GstElement *bin, *src1, *src2, *audiomixer, *sink; GstBus *bus; GstEvent *seek_event; - GstStateChangeReturn state_res; gboolean res; GstPad *srcpad, *sinkpad; GstStreamConsistency *chk_1, *chk_2, *chk_3; @@ -285,24 +322,13 @@ GST_START_TEST (test_event) GST_INFO ("starting test"); /* prepare playing */ - state_res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); - - /* wait for completion */ - state_res = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + set_state_and_wait (bin, GST_STATE_PAUSED); res = gst_element_send_event (bin, seek_event); fail_unless (res == TRUE, NULL); /* run pipeline */ - g_idle_add ((GSourceFunc) set_playing, bin); - - GST_INFO ("running main loop"); - g_main_loop_run (main_loop); - - state_res = gst_element_set_state (bin, GST_STATE_NULL); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + play_and_wait (bin); ck_assert_int_eq (position, 2 * GST_SECOND); @@ -322,7 +348,7 @@ static GstEvent *play_seek_event = NULL; static void test_play_twice_message_received (GstBus * bus, GstMessage * message, - GstPipeline * bin) + GstElement * bin) { gboolean res; GstStateChangeReturn state_res; @@ -334,25 +360,16 @@ test_play_twice_message_received (GstBus * bus, GstMessage * message, case GST_MESSAGE_SEGMENT_DONE: play_count++; if (play_count == 1) { - state_res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY); + state_res = gst_element_set_state (bin, GST_STATE_READY); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* prepare playing again */ - state_res = gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + set_state_and_wait (bin, GST_STATE_PAUSED); - /* wait for completion */ - state_res = - gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, - GST_CLOCK_TIME_NONE); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); - - res = gst_element_send_event (GST_ELEMENT (bin), - gst_event_ref (play_seek_event)); + res = gst_element_send_event (bin, gst_event_ref (play_seek_event)); fail_unless (res == TRUE, NULL); - state_res = - gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); + state_res = gst_element_set_state (bin, GST_STATE_PLAYING); ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); } else { g_main_loop_quit (main_loop); @@ -367,35 +384,20 @@ test_play_twice_message_received (GstBus * bus, GstMessage * message, GST_START_TEST (test_play_twice) { - GstElement *bin, *src1, *src2, *audiomixer, *sink; + GstElement *bin, *audiomixer; GstBus *bus; gboolean res; - GstStateChangeReturn state_res; GstPad *srcpad; GstStreamConsistency *consist; GST_INFO ("preparing test"); /* build pipeline */ - bin = gst_pipeline_new ("pipeline"); + audiomixer = gst_element_factory_make ("audiomixer", "audiomixer"); + bin = setup_pipeline (audiomixer, 2); bus = gst_element_get_bus (bin); gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH); - src1 = gst_element_factory_make ("audiotestsrc", "src1"); - g_object_set (src1, "wave", 4, NULL); /* silence */ - src2 = gst_element_factory_make ("audiotestsrc", "src2"); - g_object_set (src2, "wave", 4, NULL); /* silence */ - audiomixer = gst_element_factory_make ("audiomixer", "audiomixer"); - sink = gst_element_factory_make ("fakesink", "sink"); - gst_bin_add_many (GST_BIN (bin), src1, src2, audiomixer, sink, NULL); - - res = gst_element_link (src1, audiomixer); - fail_unless (res == TRUE, NULL); - res = gst_element_link (src2, audiomixer); - fail_unless (res == TRUE, NULL); - res = gst_element_link (audiomixer, sink); - fail_unless (res == TRUE, NULL); - srcpad = gst_element_get_static_pad (audiomixer, "src"); consist = gst_consistency_checker_new (srcpad); gst_object_unref (srcpad); @@ -416,14 +418,7 @@ GST_START_TEST (test_play_twice) GST_INFO ("starting test"); /* prepare playing */ - state_res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); - - /* wait for completion */ - state_res = - gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, - GST_CLOCK_TIME_NONE); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + set_state_and_wait (bin, GST_STATE_PAUSED); res = gst_element_send_event (bin, gst_event_ref (play_seek_event)); fail_unless (res == TRUE, NULL); @@ -431,12 +426,7 @@ GST_START_TEST (test_play_twice) GST_INFO ("seeked"); /* run pipeline */ - g_idle_add ((GSourceFunc) set_playing, bin); - - g_main_loop_run (main_loop); - - state_res = gst_element_set_state (bin, GST_STATE_NULL); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + play_and_wait (bin); ck_assert_int_eq (play_count, 2); @@ -452,7 +442,7 @@ GST_END_TEST; GST_START_TEST (test_play_twice_then_add_and_play_again) { - GstElement *bin, *src1, *src2, *src3, *audiomixer, *sink; + GstElement *bin, *src, *audiomixer; GstBus *bus; gboolean res; GstStateChangeReturn state_res; @@ -463,29 +453,15 @@ GST_START_TEST (test_play_twice_then_add_and_play_again) GST_INFO ("preparing test"); /* build pipeline */ - bin = gst_pipeline_new ("pipeline"); + audiomixer = gst_element_factory_make ("audiomixer", "audiomixer"); + bin = setup_pipeline (audiomixer, 2); bus = gst_element_get_bus (bin); gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH); - src1 = gst_element_factory_make ("audiotestsrc", "src1"); - g_object_set (src1, "wave", 4, NULL); /* silence */ - src2 = gst_element_factory_make ("audiotestsrc", "src2"); - g_object_set (src2, "wave", 4, NULL); /* silence */ - audiomixer = gst_element_factory_make ("audiomixer", "audiomixer"); - sink = gst_element_factory_make ("fakesink", "sink"); - gst_bin_add_many (GST_BIN (bin), src1, src2, audiomixer, sink, NULL); - srcpad = gst_element_get_static_pad (audiomixer, "src"); consist = gst_consistency_checker_new (srcpad); gst_object_unref (srcpad); - res = gst_element_link (src1, audiomixer); - fail_unless (res == TRUE, NULL); - res = gst_element_link (src2, audiomixer); - fail_unless (res == TRUE, NULL); - res = gst_element_link (audiomixer, sink); - fail_unless (res == TRUE, NULL); - play_seek_event = gst_event_new_seek (1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, (GstClockTime) 0, @@ -504,14 +480,7 @@ GST_START_TEST (test_play_twice_then_add_and_play_again) GST_INFO ("starting test-loop %d", i); /* prepare playing */ - state_res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); - - /* wait for completion */ - state_res = - gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, - GST_CLOCK_TIME_NONE); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + set_state_and_wait (bin, GST_STATE_PAUSED); res = gst_element_send_event (bin, gst_event_ref (play_seek_event)); fail_unless (res == TRUE, NULL); @@ -519,22 +488,17 @@ GST_START_TEST (test_play_twice_then_add_and_play_again) GST_INFO ("seeked"); /* run pipeline */ - g_idle_add ((GSourceFunc) set_playing, bin); - - g_main_loop_run (main_loop); - - state_res = gst_element_set_state (bin, GST_STATE_READY); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + play_and_wait (bin); ck_assert_int_eq (play_count, 2); /* plug another source */ if (i == 0) { - src3 = gst_element_factory_make ("audiotestsrc", "src3"); - g_object_set (src3, "wave", 4, NULL); /* silence */ - gst_bin_add (GST_BIN (bin), src3); + src = gst_element_factory_make ("audiotestsrc", NULL); + g_object_set (src, "wave", 4, NULL); /* silence */ + gst_bin_add (GST_BIN (bin), src); - res = gst_element_link (src3, audiomixer); + res = gst_element_link (src, audiomixer); fail_unless (res == TRUE, NULL); } @@ -555,23 +519,6 @@ GST_START_TEST (test_play_twice_then_add_and_play_again) GST_END_TEST; -static void -test_live_seeking_eos_message_received (GstBus * bus, GstMessage * message, - GstPipeline * bin) -{ - GST_INFO ("bus message from \"%" GST_PTR_FORMAT "\": %" GST_PTR_FORMAT, - GST_MESSAGE_SRC (message), message); - - switch (message->type) { - case GST_MESSAGE_EOS: - g_main_loop_quit (main_loop); - break; - default: - g_assert_not_reached (); - break; - } -} - static GstElement * test_live_seeking_try_audiosrc (const gchar * factory_name) { @@ -681,8 +628,7 @@ GST_START_TEST (test_live_seeking) g_signal_connect (bus, "message::error", (GCallback) message_received, bin); g_signal_connect (bus, "message::warning", (GCallback) message_received, bin); - g_signal_connect (bus, "message::eos", - (GCallback) test_live_seeking_eos_message_received, bin); + g_signal_connect (bus, "message::eos", (GCallback) message_received, bin); srcpad = gst_element_get_static_pad (audiomixer, "src"); consist = gst_consistency_checker_new (srcpad); @@ -696,14 +642,7 @@ GST_START_TEST (test_live_seeking) GST_INFO ("starting test-loop %d", i); /* prepare playing */ - state_res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); - - /* wait for completion */ - state_res = - gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, - GST_CLOCK_TIME_NONE); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + set_state_and_wait (bin, GST_STATE_PAUSED); res = gst_element_send_event (bin, gst_event_ref (play_seek_event)); fail_unless (res == TRUE, NULL); @@ -711,14 +650,7 @@ GST_START_TEST (test_live_seeking) GST_INFO ("seeked"); /* run pipeline */ - g_idle_add ((GSourceFunc) set_playing, bin); - - GST_INFO ("playing"); - - g_main_loop_run (main_loop); - - state_res = gst_element_set_state (bin, GST_STATE_NULL); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + play_and_wait (bin); gst_consistency_checker_reset (consist); } @@ -779,14 +711,7 @@ GST_START_TEST (test_add_pad) GST_INFO ("starting test"); /* prepare playing */ - state_res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); - - /* wait for completion */ - state_res = - gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, - GST_CLOCK_TIME_NONE); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + set_state_and_wait (bin, GST_STATE_PAUSED); /* add other element */ gst_bin_add_many (GST_BIN (bin), src2, NULL); @@ -800,12 +725,7 @@ GST_START_TEST (test_add_pad) ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* now play all */ - g_idle_add ((GSourceFunc) set_playing, bin); - - g_main_loop_run (main_loop); - - state_res = gst_element_set_state (bin, GST_STATE_NULL); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + play_and_wait (bin); /* cleanup */ gst_bus_remove_signal_watch (bus); @@ -879,12 +799,7 @@ GST_START_TEST (test_remove_pad) ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); /* now play all */ - g_idle_add ((GSourceFunc) set_playing, bin); - - g_main_loop_run (main_loop); - - state_res = gst_element_set_state (bin, GST_STATE_NULL); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + play_and_wait (bin); /* cleanup */ gst_bus_remove_signal_watch (bus); @@ -1091,14 +1006,7 @@ GST_START_TEST (test_duration_is_max) GST_BASE_SRC (src[2])->segment.duration = 2000; /* set to playing */ - state_res = gst_element_set_state (bin, GST_STATE_PLAYING); - fail_unless (state_res != GST_STATE_CHANGE_FAILURE, NULL); - - /* wait for completion */ - state_res = - gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, - GST_CLOCK_TIME_NONE); - fail_unless (state_res != GST_STATE_CHANGE_FAILURE, NULL); + set_state_and_wait (bin, GST_STATE_PLAYING); res = gst_element_query_duration (GST_ELEMENT (bin), format, &duration); fail_unless (res, NULL); @@ -1148,14 +1056,7 @@ GST_START_TEST (test_duration_unknown_overrides) GST_BASE_SRC (src[2])->segment.duration = 2000; /* set to playing */ - state_res = gst_element_set_state (bin, GST_STATE_PLAYING); - fail_unless (state_res != GST_STATE_CHANGE_FAILURE, NULL); - - /* wait for completion */ - state_res = - gst_element_get_state (GST_ELEMENT (bin), NULL, NULL, - GST_CLOCK_TIME_NONE); - fail_unless (state_res != GST_STATE_CHANGE_FAILURE, NULL); + set_state_and_wait (bin, GST_STATE_PLAYING); res = gst_element_query_duration (GST_ELEMENT (bin), format, &duration); fail_unless (res, NULL); @@ -1196,34 +1097,18 @@ loop_segment_done (GstBus * bus, GstMessage * message, GstElement * bin) GST_START_TEST (test_loop) { - GstElement *bin, *src1, *src2, *audiomixer, *sink; + GstElement *bin; GstBus *bus; GstEvent *seek_event; - GstStateChangeReturn state_res; gboolean res; GST_INFO ("preparing test"); /* build pipeline */ - bin = gst_pipeline_new ("pipeline"); + bin = setup_pipeline (NULL, 2); bus = gst_element_get_bus (bin); gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH); - src1 = gst_element_factory_make ("audiotestsrc", "src1"); - g_object_set (src1, "wave", 4, NULL); /* silence */ - src2 = gst_element_factory_make ("audiotestsrc", "src2"); - g_object_set (src2, "wave", 4, NULL); /* silence */ - audiomixer = gst_element_factory_make ("audiomixer", "audiomixer"); - sink = gst_element_factory_make ("fakesink", "sink"); - gst_bin_add_many (GST_BIN (bin), src1, src2, audiomixer, sink, NULL); - - res = gst_element_link (src1, audiomixer); - fail_unless (res == TRUE, NULL); - res = gst_element_link (src2, audiomixer); - fail_unless (res == TRUE, NULL); - res = gst_element_link (audiomixer, sink); - fail_unless (res == TRUE, NULL); - seek_event = gst_event_new_seek (1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, (GstClockTime) 0, @@ -1238,23 +1123,15 @@ GST_START_TEST (test_loop) GST_INFO ("starting test"); /* prepare playing */ - state_res = gst_element_set_state (bin, GST_STATE_PAUSED); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); - - /* wait for completion */ - state_res = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE); - ck_assert_int_ne (state_res, GST_STATE_CHANGE_FAILURE); + set_state_and_wait (bin, GST_STATE_PAUSED); res = gst_element_send_event (bin, seek_event); fail_unless (res == TRUE, NULL); /* run pipeline */ - g_idle_add ((GSourceFunc) set_playing, bin); + play_and_wait (bin); - GST_INFO ("running main loop"); - g_main_loop_run (main_loop); - - state_res = gst_element_set_state (bin, GST_STATE_NULL); + fail_unless (looped); /* cleanup */ gst_bus_remove_signal_watch (bus);