gst/playback/gstplaybasebin.c: Catch async errors when starting up the subtitle bin, so we can stop waiting and conti...

Original commit message from CVS:
* 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.
This commit is contained in:
Tim-Philipp Müller 2006-10-18 12:57:54 +00:00
parent 1fff311824
commit 453f06075c
3 changed files with 48 additions and 5 deletions

View file

@ -1,3 +1,14 @@
2006-10-18 Tim-Philipp Müller <tim at centricular dot net>
* 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 <tim at centricular dot net> 2006-10-18 Tim-Philipp Müller <tim at centricular dot net>
* tests/check/Makefile.am: * tests/check/Makefile.am:

View file

@ -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 /* construct and run the source and decoder elements until we found
* all the streams or until a preroll queue has been filled. * 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); sret = gst_element_set_state (subbin, GST_STATE_PAUSED);
if (sret != GST_STATE_CHANGE_FAILURE) { 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); GROUP_LOCK (play_base_bin);
GST_DEBUG ("waiting for subtitle to complete..."); GST_DEBUG ("waiting for subtitle to complete...");
while (!play_base_bin->subtitle_done) while (!play_base_bin->subtitle_done)
@ -1858,6 +1885,10 @@ setup_source (GstPlayBaseBin * play_base_bin, gchar ** new_location)
GST_DEBUG ("group done !"); GST_DEBUG ("group done !");
GROUP_UNLOCK (play_base_bin); 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 || if (!play_base_bin->building_group ||
play_base_bin->building_group->type[GST_STREAM_TYPE_TEXT - play_base_bin->building_group->type[GST_STREAM_TYPE_TEXT -
1].npads == 0) { 1].npads == 0) {

View file

@ -69,7 +69,6 @@ GST_START_TEST (test_sink_usage_video_only_stream)
GST_END_TEST; GST_END_TEST;
#if 0
/* this tests async error handling when setting up the subbin */ /* this tests async error handling when setting up the subbin */
GST_START_TEST (test_suburi_error_unknowntype) GST_START_TEST (test_suburi_error_unknowntype)
{ {
@ -101,7 +100,6 @@ GST_START_TEST (test_suburi_error_unknowntype)
} }
GST_END_TEST; GST_END_TEST;
#endif
GST_START_TEST (test_suburi_error_invalidfile) GST_START_TEST (test_suburi_error_invalidfile)
{ {
@ -285,9 +283,12 @@ GST_PLUGIN_DEFINE_STATIC
GST_VERSION_MINOR, GST_VERSION_MINOR,
"playbin-test-elements", "playbin-test-elements",
"static elements for the playbin unit test", "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 */ #endif /* GST_DISABLE_LOADSAVE_REGISTRY */
static Suite *playbin_suite (void)
static Suite *
playbin_suite (void)
{ {
Suite *s = suite_create ("playbin"); Suite *s = suite_create ("playbin");
TCase *tc_chain = tcase_create ("general"); 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_sink_usage_video_only_stream);
tcase_add_test (tc_chain, test_suburi_error_wrongproto); 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_invalidfile);
/* tcase_add_test (tc_chain, test_suburi_error_unknowntype); */ tcase_add_test (tc_chain, test_suburi_error_unknowntype);
#endif #endif
return s; return s;