From: Wim Taymans Date: Fri, 18 May 2012 07:52:09 +0000 (+0200) Subject: launch: improve EOS on shutdown handling X-Git-Tag: RELEASE-0.11.92~87 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6e878031144ace9255998d9b70be47081c9e4915;p=platform%2Fupstream%2Fgstreamer.git launch: improve EOS on shutdown handling When the -e option is selected, also wait for EOS when the pipeline produced an error. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=630997 --- diff --git a/tools/gst-launch.c b/tools/gst-launch.c index d0aa879..27f9b58 100644 --- a/tools/gst-launch.c +++ b/tools/gst-launch.c @@ -1099,18 +1099,37 @@ main (int argc, char *argv[]) tfthen = gst_util_get_timestamp (); caught_error = event_loop (pipeline, TRUE, GST_STATE_PLAYING); - if (eos_on_shutdown && caught_error == ELR_INTERRUPT) { - PRINT (_("EOS on shutdown enabled -- Forcing EOS on the pipeline\n")); + if (eos_on_shutdown && caught_error != ELR_NO_ERROR) { + gboolean ignore_errors; + waiting_eos = TRUE; - gst_element_send_event (pipeline, gst_event_new_eos ()); + if (caught_error == ELR_INTERRUPT) { + PRINT (_("EOS on shutdown enabled -- Forcing EOS on the pipeline\n")); + gst_element_send_event (pipeline, gst_event_new_eos ()); + ignore_errors = FALSE; + } else { + PRINT (_("EOS on shutdown enabled -- waiting for EOS after Error\n")); + ignore_errors = TRUE; + } PRINT (_("Waiting for EOS...\n")); - caught_error = event_loop (pipeline, TRUE, GST_STATE_PLAYING); - if (caught_error == ELR_NO_ERROR) { - /* we got EOS */ - PRINT (_("EOS received - stopping pipeline...\n")); - } else if (caught_error == ELR_ERROR) { - PRINT (_("An error happened while waiting for EOS\n")); + while (TRUE) { + caught_error = event_loop (pipeline, TRUE, GST_STATE_PLAYING); + + if (caught_error == ELR_NO_ERROR) { + /* we got EOS */ + PRINT (_("EOS received - stopping pipeline...\n")); + break; + } else if (caught_error == ELR_INTERRUPT) { + PRINT (_ + ("Interrupt while waiting for EOS - stopping pipeline...\n")); + break; + } else if (caught_error == ELR_ERROR) { + if (!ignore_errors) { + PRINT (_("An error happened while waiting for EOS\n")); + break; + } + } } } tfnow = gst_util_get_timestamp ();