mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 16:08:51 +00:00
gst-launch: print more errors to stderr and suppress more output in quiet mode
If --quiet is given, don't print anything but errors. Also, make sure errors are always printed to stderr and not to stdout. Fixes #621595.
This commit is contained in:
parent
8f5ec1f737
commit
1e3bd02618
1 changed files with 41 additions and 31 deletions
|
@ -89,8 +89,8 @@ xmllaunch_parse_cmdline (const gchar ** argv)
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
|
|
||||||
if (!(arg = argv[0])) {
|
if (!(arg = argv[0])) {
|
||||||
g_print (_
|
g_printerr ("%s",
|
||||||
("Usage: gst-xmllaunch <file.xml> [ element.property=value ... ]\n"));
|
_("Usage: gst-xmllaunch <file.xml> [ element.property=value ... ]\n"));
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,13 +160,14 @@ fault_handler_sighandler (int signum)
|
||||||
* deadlock */
|
* deadlock */
|
||||||
switch (signum) {
|
switch (signum) {
|
||||||
case SIGSEGV:
|
case SIGSEGV:
|
||||||
printf ("Caught SIGSEGV\n");
|
fprintf (stderr, "Caught SIGSEGV\n");
|
||||||
break;
|
break;
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
printf ("Caught SIGQUIT\n");
|
if (!quiet)
|
||||||
|
printf ("Caught SIGQUIT\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf ("signo: %d\n", signum);
|
fprintf (stderr, "signo: %d\n", signum);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,15 +185,16 @@ fault_handler_sigaction (int signum, siginfo_t * si, void *misc)
|
||||||
* deadlock */
|
* deadlock */
|
||||||
switch (si->si_signo) {
|
switch (si->si_signo) {
|
||||||
case SIGSEGV:
|
case SIGSEGV:
|
||||||
printf ("Caught SIGSEGV accessing address %p\n", si->si_addr);
|
fprintf (stderr, "Caught SIGSEGV accessing address %p\n", si->si_addr);
|
||||||
break;
|
break;
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
printf ("Caught SIGQUIT\n");
|
if (!quiet)
|
||||||
|
printf ("Caught SIGQUIT\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf ("signo: %d\n", si->si_signo);
|
fprintf (stderr, "signo: %d\n", si->si_signo);
|
||||||
printf ("errno: %d\n", si->si_errno);
|
fprintf (stderr, "errno: %d\n", si->si_errno);
|
||||||
printf ("code: %d\n", si->si_code);
|
fprintf (stderr, "code: %d\n", si->si_code);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +213,8 @@ fault_spin (void)
|
||||||
wait (NULL);
|
wait (NULL);
|
||||||
|
|
||||||
/* FIXME how do we know if we were run by libtool? */
|
/* FIXME how do we know if we were run by libtool? */
|
||||||
printf ("Spinning. Please run 'gdb gst-launch %d' to continue debugging, "
|
fprintf (stderr,
|
||||||
|
"Spinning. Please run 'gdb gst-launch %d' to continue debugging, "
|
||||||
"Ctrl-C to quit, or Ctrl-\\ to dump core.\n", (gint) getpid ());
|
"Ctrl-C to quit, or Ctrl-\\ to dump core.\n", (gint) getpid ());
|
||||||
while (spinning)
|
while (spinning)
|
||||||
g_usleep (1000000);
|
g_usleep (1000000);
|
||||||
|
@ -247,6 +250,24 @@ fault_setup (void)
|
||||||
}
|
}
|
||||||
#endif /* DISABLE_FAULT_HANDLER */
|
#endif /* DISABLE_FAULT_HANDLER */
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_error_message (GstMessage * msg)
|
||||||
|
{
|
||||||
|
GError *err = NULL;
|
||||||
|
gchar *name, *debug = NULL;
|
||||||
|
|
||||||
|
name = gst_object_get_path_string (msg->src);
|
||||||
|
gst_message_parse_error (msg, &err, &debug);
|
||||||
|
|
||||||
|
g_printerr (_("ERROR: from element %s: %s\n"), name, err->message);
|
||||||
|
if (debug != NULL)
|
||||||
|
g_printerr (_("Additional debug info:\n%s\n"), debug);
|
||||||
|
|
||||||
|
g_error_free (err);
|
||||||
|
g_free (debug);
|
||||||
|
g_free (name);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
|
print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
|
||||||
{
|
{
|
||||||
|
@ -281,9 +302,9 @@ print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
g_print ("%16s: %s\n", gst_tag_get_nick (tag), str);
|
PRINT ("%16s: %s\n", gst_tag_get_nick (tag), str);
|
||||||
} else {
|
} else {
|
||||||
g_print ("%16s: %s\n", "", str);
|
PRINT ("%16s: %s\n", "", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (str);
|
g_free (str);
|
||||||
|
@ -295,7 +316,7 @@ print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
|
||||||
static void
|
static void
|
||||||
sigint_handler_sighandler (int signum)
|
sigint_handler_sighandler (int signum)
|
||||||
{
|
{
|
||||||
g_print ("Caught interrupt -- ");
|
PRINT ("Caught interrupt -- ");
|
||||||
|
|
||||||
/* If we were waiting for an EOS, we still want to catch
|
/* If we were waiting for an EOS, we still want to catch
|
||||||
* the next signal to shutdown properly (and the following one
|
* the next signal to shutdown properly (and the following one
|
||||||
|
@ -319,7 +340,7 @@ check_intr (GstElement * pipeline)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
caught_intr = FALSE;
|
caught_intr = FALSE;
|
||||||
g_print ("handling interrupt.\n");
|
PRINT ("handling interrupt.\n");
|
||||||
|
|
||||||
/* post an application specific message */
|
/* post an application specific message */
|
||||||
gst_element_post_message (GST_ELEMENT (pipeline),
|
gst_element_post_message (GST_ELEMENT (pipeline),
|
||||||
|
@ -359,11 +380,11 @@ play_handler (int signum)
|
||||||
{
|
{
|
||||||
switch (signum) {
|
switch (signum) {
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
g_print ("Caught SIGUSR1 - Play request.\n");
|
PRINT ("Caught SIGUSR1 - Play request.\n");
|
||||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
break;
|
break;
|
||||||
case SIGUSR2:
|
case SIGUSR2:
|
||||||
g_print ("Caught SIGUSR2 - Stop request.\n");
|
PRINT ("Caught SIGUSR2 - Stop request.\n");
|
||||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -530,17 +551,12 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_MESSAGE_ERROR:{
|
case GST_MESSAGE_ERROR:{
|
||||||
GError *gerror;
|
|
||||||
gchar *debug;
|
|
||||||
|
|
||||||
/* dump graph on error */
|
/* dump graph on error */
|
||||||
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
|
||||||
GST_DEBUG_GRAPH_SHOW_ALL, "gst-launch.error");
|
GST_DEBUG_GRAPH_SHOW_ALL, "gst-launch.error");
|
||||||
|
|
||||||
gst_message_parse_error (message, &gerror, &debug);
|
print_error_message (message);
|
||||||
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
|
|
||||||
g_error_free (gerror);
|
|
||||||
g_free (debug);
|
|
||||||
/* we have an error */
|
/* we have an error */
|
||||||
res = ELR_ERROR;
|
res = ELR_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -859,14 +875,8 @@ main (int argc, char *argv[])
|
||||||
g_printerr (_("ERROR: pipeline doesn't want to play.\n"));
|
g_printerr (_("ERROR: pipeline doesn't want to play.\n"));
|
||||||
bus = gst_element_get_bus (pipeline);
|
bus = gst_element_get_bus (pipeline);
|
||||||
if ((err_msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0))) {
|
if ((err_msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0))) {
|
||||||
GError *gerror;
|
print_error_message (err_msg);
|
||||||
gchar *debug;
|
|
||||||
|
|
||||||
gst_message_parse_error (err_msg, &gerror, &debug);
|
|
||||||
gst_object_default_error (GST_MESSAGE_SRC (err_msg), gerror, debug);
|
|
||||||
gst_message_unref (err_msg);
|
gst_message_unref (err_msg);
|
||||||
g_error_free (gerror);
|
|
||||||
g_free (debug);
|
|
||||||
}
|
}
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
res = -1;
|
res = -1;
|
||||||
|
|
Loading…
Reference in a new issue