diff --git a/ChangeLog b/ChangeLog index 76efa6f4a2..875c6c1ae2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-10-18 Tim-Philipp Müller + + * gst/playback/gstplaybasebin.c: (subbin_startup_sync_msg), + (setup_source): + Catch async errors when starting up the subtitle bin, so we can + stop waiting and continue with the main film instead of hanging + forever. Fixes #339366. + + * tests/check/elements/playbin.c: (playbin_suite): + Enable unit test for the above. + 2006-10-18 Tim-Philipp Müller * tests/check/Makefile.am: diff --git a/gst/playback/gstplaybasebin.c b/gst/playback/gstplaybasebin.c index 42bd66a723..000f3d82a8 100644 --- a/gst/playback/gstplaybasebin.c +++ b/gst/playback/gstplaybasebin.c @@ -1785,6 +1785,25 @@ remove_source (GstPlayBaseBin * bin) } } +static GstBusSyncReply +subbin_startup_sync_msg (GstBus * bus, GstMessage * msg, gpointer user_data) +{ + if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) { + GstPlayBaseBin *play_base_bin; + + play_base_bin = GST_PLAY_BASE_BIN (user_data); + if (!play_base_bin->subtitle_done) { + GST_WARNING_OBJECT (play_base_bin, "error starting up subtitle bin: %" + GST_PTR_FORMAT, msg); + play_base_bin->subtitle_done = TRUE; + GST_DEBUG_OBJECT (play_base_bin, "signal group done"); + GROUP_SIGNAL (play_base_bin); + GST_DEBUG_OBJECT (play_base_bin, "signaled group done"); + } + } + return GST_BUS_PASS; +} + /* construct and run the source and decoder elements until we found * all the streams or until a preroll queue has been filled. */ @@ -1851,6 +1870,14 @@ setup_source (GstPlayBaseBin * play_base_bin, gchar ** new_location) sret = gst_element_set_state (subbin, GST_STATE_PAUSED); if (sret != GST_STATE_CHANGE_FAILURE) { + GstBus *bus; + + /* since subbin is still a stand-alone bin, we need to add a custom bus + * to intercept error messages, so we can stop waiting and continue */ + bus = gst_bus_new (); + gst_element_set_bus (subbin, bus); + gst_bus_set_sync_handler (bus, subbin_startup_sync_msg, play_base_bin); + GROUP_LOCK (play_base_bin); GST_DEBUG ("waiting for subtitle to complete..."); while (!play_base_bin->subtitle_done) @@ -1858,6 +1885,10 @@ setup_source (GstPlayBaseBin * play_base_bin, gchar ** new_location) GST_DEBUG ("group done !"); GROUP_UNLOCK (play_base_bin); + gst_bus_set_sync_handler (bus, NULL, NULL); + gst_element_set_bus (subbin, NULL); + gst_object_unref (bus); + if (!play_base_bin->building_group || play_base_bin->building_group->type[GST_STREAM_TYPE_TEXT - 1].npads == 0) { diff --git a/tests/check/elements/playbin.c b/tests/check/elements/playbin.c index efce926435..4cebbe2a64 100644 --- a/tests/check/elements/playbin.c +++ b/tests/check/elements/playbin.c @@ -69,7 +69,6 @@ GST_START_TEST (test_sink_usage_video_only_stream) GST_END_TEST; -#if 0 /* this tests async error handling when setting up the subbin */ GST_START_TEST (test_suburi_error_unknowntype) { @@ -101,7 +100,6 @@ GST_START_TEST (test_suburi_error_unknowntype) } GST_END_TEST; -#endif GST_START_TEST (test_suburi_error_invalidfile) { @@ -285,9 +283,12 @@ GST_PLUGIN_DEFINE_STATIC GST_VERSION_MINOR, "playbin-test-elements", "static elements for the playbin unit test", - plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN); + #endif /* GST_DISABLE_LOADSAVE_REGISTRY */ - static Suite *playbin_suite (void) + +static Suite * +playbin_suite (void) { Suite *s = suite_create ("playbin"); TCase *tc_chain = tcase_create ("general"); @@ -298,7 +299,7 @@ GST_PLUGIN_DEFINE_STATIC tcase_add_test (tc_chain, test_sink_usage_video_only_stream); tcase_add_test (tc_chain, test_suburi_error_wrongproto); tcase_add_test (tc_chain, test_suburi_error_invalidfile); - /* tcase_add_test (tc_chain, test_suburi_error_unknowntype); */ + tcase_add_test (tc_chain, test_suburi_error_unknowntype); #endif return s;