From 059831534c7e884f0a607ed86b582fd00d821731 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Sat, 26 Sep 2026 23:24:03 +0200 Subject: New upstream version 3.2.0~rc1+dfsg --- FastDecode.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 FastDecode.cpp (limited to 'FastDecode.cpp') diff --git a/FastDecode.cpp b/FastDecode.cpp new file mode 100644 index 00000000..ad60f6e6 --- /dev/null +++ b/FastDecode.cpp @@ -0,0 +1,42 @@ +#include "FastDecode.hpp" +#include "wsjtx_config.h" +#include "DecDataMutex.hpp" + +#include +#include +#include +#include +#include +#include +#include + +extern "C" void fast_decode_ (short[], int[], double *, char[], char[], char[], + fortran_charlen_t, fortran_charlen_t, + fortran_charlen_t); + +QFuture startFastDecode (short const samples[], int const arguments[], + double period, char const myCall[], + char const hisCall[]) +{ + FastDecodeResult result; + std::copy_n (arguments, result.arguments.size (), result.arguments.begin ()); + std::array ownCall, dxCall; + std::copy_n (myCall, ownCall.size (), ownCall.begin ()); + std::copy_n (hisCall, dxCall.size (), dxCall.begin ()); + auto captured = std::make_shared> (360000, 0); + { + QMutexLocker lock {&dec_data_mutex ()}; + std::copy_n (samples, std::max (0, std::min (360000, arguments[1])), + captured->begin ()); + } + return QtConcurrent::run ([=] () mutable { + // fast_decode retains Fortran SAVE state between invocations. Independent + // sample ownership alone does not make concurrent decoder entry safe. + static QMutex decoderMutex; + QMutexLocker lock {&decoderMutex}; + fast_decode_ (captured->data (), result.arguments.data (), &period, + result.messages.data (), ownCall.data (), dxCall.data (), + fortran_charlen_t (8000), fortran_charlen_t (12), fortran_charlen_t (12)); + return result; + }); +} -- cgit v1.2.3