diff mbox series

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

Message ID 20201009203851.10820-1-jamrial@gmail.com
State New
Headers show
Series Untitled series #2492
Related show

Commit Message

James Almer Oct. 9, 2020, 8:38 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 fftools/cmdutils.c | 32 ++++++++------------------------
 1 file changed, 8 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 88fdbeaf1e..ba25e5c884 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,21 +2315,11 @@  int show_sources(void *optctx, const char *opt, const char *arg)
         goto fail;
 
     do {
-        fmt = av_input_audio_device_next(fmt);
+        fmt = av_indev_iterate(&fmt_iter);
         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);
-        if (fmt) {
-            if (dev && !av_match_name(dev, fmt->name))
-                continue;
-            print_device_sources(fmt, opts);
+            print_device_sources((AVInputFormat *)fmt, opts);
         }
     } while (fmt);
   fail:
@@ -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 AVOutputFormat *fmt = NULL;
+    void *fmt_iter = NULL;
     char *dev = NULL;
     AVDictionary *opts = NULL;
     int ret = 0;
@@ -2352,19 +2344,11 @@  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;
-            print_device_sinks(fmt, opts);
+            print_device_sinks((AVOutputFormat *)fmt, opts);
         }
     } while (fmt);
   fail: