On Wed, Nov 06, 2013 at 08:04:58PM +0100, Diego Biurrun wrote:
> --- /dev/null
> +++ b/libavfilter/api-example.c
> @@ -0,0 +1,324 @@
> +static int init_filter_graph(AVFormatContext *ic, AVStream *audio_st)
> +{
> +    // create new graph
> +    filter_graph = avfilter_graph_alloc();
> +    if (!filter_graph) {
> +        av_log(NULL, AV_LOG_ERROR,
> +               "Unable to create filter graph: out of memory\n");
> +        return -1;
> +    }
> +
> +    err = avfilter_graph_create_filter(&abuffer_ctx, abuffer,
> +                                       NULL, strbuf, NULL, filter_graph);
> +    if (err < 0) {
> +        av_log(NULL, AV_LOG_ERROR, "error initializing abuffer filter\n");
> +        return err;
> +    }
> +    err = avfilter_graph_create_filter(&volume_ctx, volume, NULL,
> +                                       strbuf, NULL, filter_graph);
> +    if (err < 0) {
> +        av_log(NULL, AV_LOG_ERROR, "error initializing volume filter\n");
> +        return err;
> +    }
> +    err = avfilter_graph_create_filter(&aformat_ctx, aformat,
> +                                       NULL, strbuf, NULL, filter_graph);
> +    if (err < 0) {
> +        av_log(NULL, AV_LOG_ERROR, "unable to create aformat filter\n");
> +        return err;
> +    }
> +    err = avfilter_graph_create_filter(&abuffersink_ctx, abuffersink,
> +                                       NULL, NULL, NULL, filter_graph);
> +    if (err < 0) {
> +        av_log(NULL, AV_LOG_ERROR, "unable to create aformat filter\n");
> +        return err;
> +    }
> +
> +    if (err >= 0)
> +        err = avfilter_link(abuffer_ctx, 0, volume_ctx, 0);
> +    if (err >= 0)
> +        err = avfilter_link(volume_ctx, 0, aformat_ctx, 0);
> +    if (err >= 0)
> +        err = avfilter_link(aformat_ctx, 0, abuffersink_ctx, 0);
> +    if (err < 0) {
> +        av_log(NULL, AV_LOG_ERROR, "error connecting filters\n");
> +        return err;
> +    }
> +    err = avfilter_graph_config(filter_graph, NULL);
> +    if (err < 0) {
> +        av_log(NULL, AV_LOG_ERROR, "error configuring the filter graph\n");
> +        return err;
> +    }
> +    return 0;
> +}

Do we care about properly cleaning up the memory allocation on errors
in this example program?

Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to