[FFmpeg-devel] [PATCH 2/2] opts: add list device sources/sinks options
Michael Niedermayer
michaelni at gmx.at
Wed Oct 22 02:02:01 CEST 2014
On Sat, Oct 18, 2014 at 08:25:30PM +0200, Lukasz Marek wrote:
> Allows to list sources/sinks of the devices that implement
> that functionality.
>
> Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
> ---
> cmdutils.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++++
> cmdutils.h | 12 ++++
> cmdutils_common_opts.h | 6 ++
> 3 files changed, 209 insertions(+)
[...]
> +int show_sources(void *optctx, const char *opt, const char *arg)
> +{
> +#if CONFIG_AVDEVICE
> + AVInputFormat *fmt = NULL;
> + char *dev = NULL;
> + AVDictionary *opts = NULL;
> + int ret = 0;
> + int error_level = av_log_get_level();
> +
> + av_log_set_level(AV_LOG_ERROR);
> +
> + if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
> + goto fail;
> +
> + do {
> + fmt = av_input_audio_device_next(fmt);
> + if (fmt) {
> + if (!strcmp(fmt->name, "lavfi"))
> + continue; //it's pointless to probe lavfi
> + if (dev && strcmp(fmt->name, dev))
> + continue;
> + print_device_sources(fmt, opts);
> + }
> + } while (fmt);
> + do {
> + fmt = av_input_video_device_next(fmt);
> + if (fmt) {
> + if (dev && strcmp(fmt->name, dev))
> + continue;
> + print_device_sources(fmt, opts);
> + }
> + } while (fmt);
> + fail:
> + av_dict_free(&opts);
> + av_free(dev);
> + av_log_set_level(error_level);
> + return ret;
> +#else
> + printf("Configured without libavdevice\n");
> + return AVERROR(ENOSYS);
> +#endif
it seems the only use of this function is under #if CONFIG_AVDEVICE
so the fallback shouldnt be needed
same for the other function
also mising documentation and example in docs
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141022/8a398a7a/attachment.asc>
More information about the ffmpeg-devel
mailing list