diff mbox series

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

Message ID 20201009201811.10710-3-jamrial@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,1/3] avdevice/alldevices: stop using deprecated linked list API | expand

Checks

Context Check Description
andriy/make success Make finished
andriy/make_fate success Make fate finished
andriy/PPC64_make warning Make failed

Commit Message

James Almer Oct. 9, 2020, 8:18 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 fftools/cmdutils.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

Comments

Andreas Rheinhardt Oct. 9, 2020, 8:30 p.m. UTC | #1
James Almer:
> Signed-off-by: James Almer <jamrial@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;
>
diff mbox series

Patch

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;
+    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;