History

Change the signature of create_filter() to make it return an error code.

Originally committed as revision 25691 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini committed 16 years ago

Commit c58572f1 parent 8ce803d1 file · +19 −19Browse files

Showing the changes to libavfilter/graphparser.c (1 of 1 file). Show all

Unified · Split

libavfilter/graphparser.c+19−19
@@ -86,21 +86,20 @@ static char *parse_link_name(const char **buf, AVClass *log_ctx) · 85 unmodified lines
8686 * filtergraph in *ctx.
8787 *
8888 * @param ctx the filtergraph context
89+ * @param put here a filter context in case of successful creation and configuration, NULL otherwise.
8990 * @param index an index which is supposed to be unique for each filter instance added to the filtergraph
9091 * @param filt_name the name of the filter to create
9192 * @param args the arguments provided to the filter during its initialization
9293 * @param log_ctx the log context to use
93− * @return a filter context in case of successful creation and configuration, NULL otherwise.
94+ * @return 0 in case of success, a negative AVERROR code otherwise
9495 */
95−static AVFilterContext *create_filter(AVFilterGraph *ctx, int index,
96− const char *filt_name, const char *args,
97− AVClass *log_ctx)
96+static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index,
97+ const char *filt_name, const char *args, AVClass *log_ctx)
9898 {
99− AVFilterContext *filt_ctx;
100−
10199 AVFilter *filt;
102100 char inst_name[30];
103101 char tmp_args[256];
102+ int ret;
104103
105104 snprintf(inst_name, sizeof(inst_name), "Filter %d %s", index, filt_name);
106105
@@ -109,19 +108,19 @@ static AVFilterContext *create_filter(AVFilterGraph *ctx, int index, · 2 unmodified lines
109108 if (!filt) {
110109 av_log(log_ctx, AV_LOG_ERROR,
111110 "No such filter: '%s'\n", filt_name);
112− return NULL;
111+ return AVERROR(EINVAL);
113112 }
114113
115− avfilter_open(&filt_ctx, filt, inst_name);
116− if (!filt_ctx) {
114+ ret = avfilter_open(filt_ctx, filt, inst_name);
115+ if (!*filt_ctx) {
117116 av_log(log_ctx, AV_LOG_ERROR,
118117 "Error creating filter '%s'\n", filt_name);
119− return NULL;
118+ return ret;
120119 }
121120
122− if (avfilter_graph_add_filter(ctx, filt_ctx) < 0) {
123− avfilter_destroy(filt_ctx);
124− return NULL;
121+ if ((ret = avfilter_graph_add_filter(ctx, *filt_ctx)) < 0) {
122+ avfilter_destroy(*filt_ctx);
123+ return ret;
125124 }
126125
127126 if (!strcmp(filt_name, "scale") && !strstr(args, "flags")) {
@@ -130,13 +129,13 @@ static AVFilterContext *create_filter(AVFilterGraph *ctx, int index, · 2 unmodified lines
130129 args = tmp_args;
131130 }
132131
133− if (avfilter_init_filter(filt_ctx, args, NULL)) {
132+ if ((ret = avfilter_init_filter(*filt_ctx, args, NULL)) < 0) {
134133 av_log(log_ctx, AV_LOG_ERROR,
135134 "Error initializing filter '%s' with args '%s'\n", filt_name, args);
136− return NULL;
135+ return ret;
137136 }
138137
139− return filt_ctx;
138+ return 0;
140139 }
141140
142141 /**
@@ -147,17 +146,18 @@ static AVFilterContext *parse_filter(const char **buf, AVFilterGraph *graph, · 4 unmodified lines
147146 {
148147 char *opts = NULL;
149148 char *name = av_get_token(buf, "=,;[\n");
150− AVFilterContext *ret;
149+ AVFilterContext *filt_ctx;
150+ int ret;
151151
152152 if (**buf == '=') {
153153 (*buf)++;
154154 opts = av_get_token(buf, "[],;\n");
155155 }
156156
157− ret = create_filter(graph, index, name, opts, log_ctx);
157+ ret = create_filter(&filt_ctx, graph, index, name, opts, log_ctx);
158158 av_free(name);
159159 av_free(opts);
160− return ret;
160+ return filt_ctx;
161161 }
162162
163163 static void free_inout(AVFilterInOut *head)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t