GNOME Bugzilla – Bug 737901
playbin: no message when current stream ends and setting next uri failed
Last modified: 2018-05-06 12:11:34 UTC
Using playbin the next uri can be set on the about-to-finish signal while the current stream is still playing. However, when the next uri is not playable an error message is send immediately on the bus. In this case I want the current stream play until the end but there is no way to tell when it does finish: no message is send and no signal is emitted. I'm sending EOS myself to the sink but I would expect playbin to do that.
Can you provide a simple testcase for this? But in general you're supposed to shut down the pipeline when an error message is received, and can't assume that anything works afterwards.
> But in general you're supposed to > shut down the pipeline when an error message is received, and can't assume that > anything works afterwards. Doesn't that depend on the error? I don't know if the next track can be played until I try it. And when I do, it's too late and I have to stop the current track? A complete testcase is difficult for me to provide. But this extract should make clear what I mean (I hope): GstElement* pipeline; const char* next_uri_not_decodable = "file:///broken_song.ogg"; bool next_uri_set; static void about_to_finish_cb(GstPlayBin* bin, gpointer obj) { GstTest *gst_test = reinterpret_cast<GstTest*>(obj); gst_test->next_uri_set = true; g_object_set(G_OBJECT(gst_test->pipeline), "uri", gst_test->next_uri_not_decodable, nullptr); } static gboolean bus_cb(GstBus* bus, GstMessage* msg, gpointer obj) { GstTest *gst_test = reinterpret_cast<GstTest*>(obj); switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_ERROR: { GError* error; gchar* debugs; gst_message_parse_error(msg, &error, &debugs); int domain = error->domain; g_error_free(error); free(debugs); GstState state, state_pending; gst_element_get_state(gst_test->pipeline, &state, &state_pending, 1 * GST_SECOND); if (state == GST_STATE_PLAYING && gst_test->next_uri_set && (domain == GST_RESOURCE_ERROR || domain == GST_STREAM_ERROR)) { // A track is still playing and the next URI is not playable. We ignore // the error here so the current track (which is playing fine) can play // until the end. } else { emit gst_test->Error(); } break; } case GST_MESSAGE_EOS: { // If there was an error for the next URI we will never get here. emit gst_test->Finished(); break; } default: break; } return TRUE; }
This should be solved properly with playbin3, delaying the error until the next track actually happens. If there are still problems, please file a new bug