[FFmpeg-devel] [RFC] libavfilter query_format() related functions error handling

Clément Bœsch u at pkh.me
Sat Mar 14 15:11:28 CET 2015


On Sat, Mar 14, 2015 at 01:33:12PM +0100, Nicolas George wrote:
> Le quartidi 24 ventôse, an CCXXIII, Michael Niedermayer a écrit :
> >     ff_set_common_channel_layouts(ctx, ff_all_channel_layouts());
> >     ff_set_common_formats(ctx, ff_make_format_list(sample_fmts));
> >     ff_set_common_samplerates(ctx, ff_all_samplerates());
> > 

What do you do about the 2nd argument being NULL by allocation error here?

Should the ctx passed there too?

> >     return ctx->ff_errno;
> 
> I wanted to suggest something along this line too. Since the functions are
> private and can be changed, I suspect the error code would be better carried
> around in a value passed as argument.
> 

That would also make the calls to query_formats() between filters more
easily thread safe.

So...

    int ret = 0;
    ff_set_common_channel_layouts(ctx, ff_all_channel_layouts(&ret), &ret);
    ff_set_common_formats(ctx, ff_make_format_list(sample_fmts, &ret), &ret);
    ff_set_common_samplerates(ctx, ff_all_samplerates(&ret), &ret);
    return ret;

?

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150314/42e21edc/attachment.asc>


More information about the ffmpeg-devel mailing list