mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
return a negative error code instead of exiting on parse error
Original commit message from CVS: return a negative error code instead of exiting on parse error
This commit is contained in:
parent
f7589295b3
commit
a4e42f7b06
4 changed files with 47 additions and 16 deletions
|
@ -246,23 +246,23 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
|
|||
// we have the start of a name of the preceding element.
|
||||
// rename previous element to next arg.
|
||||
if (arg[1] != '\0') {
|
||||
fprintf(stderr,"error, unexpected junk after [\n");
|
||||
exit(-1);
|
||||
fprintf(stderr,"error, unexpected junk after [\n");
|
||||
return GST_PARSE_ERROR_SYNTAX;
|
||||
}
|
||||
i++;
|
||||
if (i < argc) {
|
||||
gst_element_set_name(previous, argv[i]);
|
||||
gst_element_set_name(previous, argv[i]);
|
||||
} else {
|
||||
fprintf(stderr,"error, expected element name, found end of arguments\n");
|
||||
exit(-1);
|
||||
fprintf(stderr,"error, expected element name, found end of arguments\n");
|
||||
return GST_PARSE_ERROR_SYNTAX;
|
||||
}
|
||||
i++;
|
||||
if (i >= argc) {
|
||||
fprintf(stderr,"error, expected ], found end of arguments\n");
|
||||
exit(-1);
|
||||
fprintf(stderr,"error, expected ], found end of arguments\n");
|
||||
return GST_PARSE_ERROR_SYNTAX;
|
||||
} else if (strcmp(argv[i], "]") != 0) {
|
||||
fprintf(stderr,"error, expected ], found '%s'\n", argv[i]);
|
||||
exit(-1);
|
||||
fprintf(stderr,"error, expected ], found '%s'\n", argv[i]);
|
||||
return GST_PARSE_ERROR_SYNTAX;
|
||||
}
|
||||
} else {
|
||||
DEBUG("have element or bin/thread\n");
|
||||
|
@ -273,7 +273,7 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
|
|||
element = gst_bin_new(g_strdup_printf("bin%d",priv->bincount++));
|
||||
if (!element) {
|
||||
fprintf(stderr,"Couldn't create a bin!\n");
|
||||
// exit(-1);
|
||||
return GST_PARSE_ERROR_CREATING_ELEMENT;
|
||||
}
|
||||
GST_DEBUG(0,"CREATED bin %s\n",GST_ELEMENT_NAME(element));
|
||||
} else if (arg[0] == '{') {
|
||||
|
@ -281,7 +281,7 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
|
|||
element = gst_thread_new(g_strdup_printf("thread%d",priv->threadcount++));
|
||||
if (!element) {
|
||||
fprintf(stderr,"Couldn't create a thread!\n");
|
||||
// exit(-1);
|
||||
return GST_PARSE_ERROR_CREATING_ELEMENT;
|
||||
}
|
||||
GST_DEBUG(0,"CREATED thread %s\n",GST_ELEMENT_NAME(element));
|
||||
} else {
|
||||
|
@ -290,7 +290,10 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
|
|||
continue;
|
||||
}
|
||||
|
||||
i += gst_parse_launch_cmdline(argc - i, argv + i + 1, GST_BIN (element), priv);
|
||||
j = gst_parse_launch_cmdline(argc - i, argv + i + 1, GST_BIN (element), priv);
|
||||
//check for parse error
|
||||
if (j < 0) return j;
|
||||
i += j;
|
||||
|
||||
} else {
|
||||
// we have an element
|
||||
|
@ -304,7 +307,7 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
|
|||
#else
|
||||
fprintf(stderr,"Couldn't create a '%s', no such element or need to load pluginn?\n",arg);
|
||||
#endif
|
||||
exit(-1);
|
||||
return GST_PARSE_ERROR_NOSUCH_ELEMENT;
|
||||
}
|
||||
GST_DEBUG(0,"CREATED element %s\n",GST_ELEMENT_NAME(element));
|
||||
}
|
||||
|
|
|
@ -31,6 +31,12 @@ extern "C" {
|
|||
|
||||
#ifndef GST_DISABLE_PARSE
|
||||
|
||||
typedef enum {
|
||||
GST_PARSE_ERROR_SYNTAX = -1,
|
||||
GST_PARSE_ERROR_CREATING_ELEMENT = -2,
|
||||
GST_PARSE_ERROR_NOSUCH_ELEMENT = -3,
|
||||
} GstParseErrors;
|
||||
|
||||
gint gst_parse_launch (const gchar *cmdline, GstBin *parent);
|
||||
|
||||
#else // GST_DISABLE_PARSE
|
||||
|
|
|
@ -516,7 +516,8 @@ parse_callback( GtkWidget *widget,
|
|||
GtkWidget *tree_item = (GtkWidget*)gtk_object_get_data(GTK_OBJECT(widget), "tree_item");
|
||||
gchar *last_pipe = (gchar*)gtk_object_get_data(GTK_OBJECT(widget), "last_pipe");
|
||||
gchar *try_pipe = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(pipe_combo)->entry));
|
||||
|
||||
gint parse_result;
|
||||
|
||||
if (pipeline){
|
||||
g_print("unreffing\n");
|
||||
gst_object_unref (GST_OBJECT (pipeline));
|
||||
|
@ -524,7 +525,25 @@ parse_callback( GtkWidget *widget,
|
|||
g_print ("trying pipeline: %s\n", try_pipe);
|
||||
|
||||
pipeline = gst_pipeline_new ("launch");
|
||||
gst_parse_launch (try_pipe, GST_BIN (pipeline));
|
||||
parse_result = gst_parse_launch (try_pipe, GST_BIN (pipeline));
|
||||
if (parse_result < 0){
|
||||
switch(parse_result){
|
||||
case GST_PARSE_ERROR_SYNTAX:
|
||||
gtk_label_set_text(GTK_LABEL(status), "error parsing syntax of pipeline");
|
||||
break;
|
||||
case GST_PARSE_ERROR_CREATING_ELEMENT:
|
||||
gtk_label_set_text(GTK_LABEL(status), "error creating a core element");
|
||||
break;
|
||||
case GST_PARSE_ERROR_NOSUCH_ELEMENT:
|
||||
gtk_label_set_text(GTK_LABEL(status), "error finding an element which was requested");
|
||||
break;
|
||||
default:
|
||||
gtk_label_set_text(GTK_LABEL(status), "unknown error parsing pipeline");
|
||||
break;
|
||||
}
|
||||
gst_object_unref (GST_OBJECT (pipeline));
|
||||
return;
|
||||
}
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(start_but), TRUE);
|
||||
|
||||
build_tree(tree_item, GST_BIN(pipeline));
|
||||
|
|
|
@ -152,7 +152,10 @@ main(int argc, char *argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
gst_parse_launch (cmdline, GST_BIN (pipeline));
|
||||
if (gst_parse_launch (cmdline, GST_BIN (pipeline)) < 0){
|
||||
fprintf(stderr,"ERROR: pipeline description could not be parsed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifndef GST_DISABLE_LOADSAVE
|
||||
if (save_pipeline) {
|
||||
|
|
Loading…
Reference in a new issue