[FFmpeg-devel] [PATCH 2/6] avradio/sdr: Factor bug workaround detection code out.

Michael Niedermayer michael at niedermayer.cc
Mon Jul 24 21:35:31 EEST 2023


Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavradio/sdr.h        | 5 +++++
 libavradio/sdrdemux.c   | 8 ++++++++
 libavradio/sdrinradio.c | 5 +----
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index de0a479d26..7d7bfd6806 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -290,6 +290,11 @@ extern const AVOption ff_sdr_options[];
 
 extern ModulationDescriptor ff_sdr_modulation_descs[];
 
+/**
+ * Detect hw bug specific workarounds.
+ */
+void ff_sdr_autodetect_workarounds(SDRContext *sdr);
+
 /**
  * Set the center frequency of the hardware
  * this will check the argument and call set_frequency_callback()
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index bb33c69668..b0b63827eb 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -99,6 +99,14 @@ static void apply_deemphasis(SDRContext *sdr, AVComplexFloat *data, int len, int
     }
 }
 
+void ff_sdr_autodetect_workarounds(SDRContext *sdr)
+{
+    if (sdr->rtlsdr_fixes < 0)
+        sdr->rtlsdr_fixes = !strcmp(sdr->driver_name, "rtlsdr");
+    if (sdr->sdrplay_fixes < 0)
+        sdr->sdrplay_fixes = !strcmp(sdr->driver_name, "sdrplay");
+}
+
 static void free_station(Station *station)
 {
     if (station->stream)
diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c
index 5c14250f8c..2865b6a9a6 100644
--- a/libavradio/sdrinradio.c
+++ b/libavradio/sdrinradio.c
@@ -212,10 +212,7 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
     if (!sdr->driver_name)
         return AVERROR(EINVAL); //No driver specified and none found
 
-    if (sdr->rtlsdr_fixes < 0)
-        sdr->rtlsdr_fixes = !strcmp(sdr->driver_name, "rtlsdr");
-    if (sdr->sdrplay_fixes < 0)
-        sdr->sdrplay_fixes = !strcmp(sdr->driver_name, "sdrplay");
+    ff_sdr_autodetect_workarounds(sdr);
 
     SoapySDRKwargs_set(&args, "driver", sdr->driver_name);
     sdr->soapy = soapy = SoapySDRDevice_make(&args);
-- 
2.31.1



More information about the ffmpeg-devel mailing list