[FFmpeg-devel] [PATCH 3/3] cmdutils: use the new device iteration API to list devices

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Fri Oct 9 23:30:19 EEST 2020


James Almer:
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
>  fftools/cmdutils.c | 28 ++++++----------------------
>  1 file changed, 6 insertions(+), 22 deletions(-)
> 
> diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
> index 88fdbeaf1e..83989b8190 100644
> --- a/fftools/cmdutils.c
> +++ b/fftools/cmdutils.c
> @@ -2302,7 +2302,8 @@ static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionar
>  
>  int show_sources(void *optctx, const char *opt, const char *arg)
>  {
> -    AVInputFormat *fmt = NULL;
> +    const AVInputFormat *fmt = NULL;
> +    void *fmt_iter = NULL;
>      char *dev = NULL;
>      AVDictionary *opts = NULL;
>      int ret = 0;
> @@ -2314,17 +2315,7 @@ int show_sources(void *optctx, const char *opt, const char *arg)
>          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 && !av_match_name(dev, fmt->name))
> -                continue;
> -            print_device_sources(fmt, opts);
> -        }
> -    } while (fmt);
> -    do {
> -        fmt = av_input_video_device_next(fmt);
> +        fmt = av_indev_iterate(&fmt_iter);
>          if (fmt) {
>              if (dev && !av_match_name(dev, fmt->name))
>                  continue;
> @@ -2340,7 +2331,8 @@ int show_sources(void *optctx, const char *opt, const char *arg)
>  
>  int show_sinks(void *optctx, const char *opt, const char *arg)
>  {
> -    AVOutputFormat *fmt = NULL;
> +    const AVInputFormat *fmt = NULL;

AVOutputFormat

> +    void *fmt_iter = NULL;
>      char *dev = NULL;
>      AVDictionary *opts = NULL;
>      int ret = 0;
> @@ -2352,15 +2344,7 @@ int show_sinks(void *optctx, const char *opt, const char *arg)
>          goto fail;
>  
>      do {
> -        fmt = av_output_audio_device_next(fmt);
> -        if (fmt) {
> -            if (dev && !av_match_name(dev, fmt->name))
> -                continue;
> -            print_device_sinks(fmt, opts);
> -        }
> -    } while (fmt);
> -    do {
> -        fmt = av_output_video_device_next(fmt);
> +        fmt = av_outdev_iterate(&fmt_iter);
>          if (fmt) {
>              if (dev && !av_match_name(dev, fmt->name))
>                  continue;
> 



More information about the ffmpeg-devel mailing list