From 7fe09b9a20858e45603fbf8c4c214e8dae413ac2 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Mon, 15 May 2023 16:45:08 +0100 Subject: [PATCH] Set minimum FIFO size to avoid buffer overflow --- plugins/channelrx/demodnavtex/navtexdemodbaseband.cpp | 3 ++- plugins/channelrx/demodrtty/rttydemodbaseband.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/channelrx/demodnavtex/navtexdemodbaseband.cpp b/plugins/channelrx/demodnavtex/navtexdemodbaseband.cpp index 464942421..19bc98476 100644 --- a/plugins/channelrx/demodnavtex/navtexdemodbaseband.cpp +++ b/plugins/channelrx/demodnavtex/navtexdemodbaseband.cpp @@ -145,7 +145,8 @@ bool NavtexDemodBaseband::handleMessage(const Message& cmd) DSPSignalNotification& notif = (DSPSignalNotification&) cmd; qDebug() << "NavtexDemodBaseband::handleMessage: DSPSignalNotification: basebandSampleRate: " << notif.getSampleRate(); setBasebandSampleRate(notif.getSampleRate()); - m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getSampleRate())); + // We can run with very slow sample rate (E.g. 4k), but we don't want FIFO getting too small + m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(std::max(notif.getSampleRate(), 48000))); return true; } diff --git a/plugins/channelrx/demodrtty/rttydemodbaseband.cpp b/plugins/channelrx/demodrtty/rttydemodbaseband.cpp index e54076203..3cd28f59b 100644 --- a/plugins/channelrx/demodrtty/rttydemodbaseband.cpp +++ b/plugins/channelrx/demodrtty/rttydemodbaseband.cpp @@ -145,7 +145,8 @@ bool RttyDemodBaseband::handleMessage(const Message& cmd) DSPSignalNotification& notif = (DSPSignalNotification&) cmd; qDebug() << "RttyDemodBaseband::handleMessage: DSPSignalNotification: basebandSampleRate: " << notif.getSampleRate(); setBasebandSampleRate(notif.getSampleRate()); - m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getSampleRate())); + // We can run with very slow sample rate (E.g. 4k), but we don't want FIFO getting too small + m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(std::max(notif.getSampleRate(), 48000))); return true; }