diff mbox series

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

Message ID 20230724183535.2677937-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/6] avradio/sdrinradio: Check tuner before applying rtlsdr frequency correction | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch
yinshiyou/configure_loongarch64 warning Failed to apply patch

Commit Message

Michael Niedermayer July 24, 2023, 6:35 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavradio/sdr.h        | 5 +++++
 libavradio/sdrdemux.c   | 8 ++++++++
 libavradio/sdrinradio.c | 5 +----
 3 files changed, 14 insertions(+), 4 deletions(-)
diff mbox series

Patch

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