diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /FastDecode.cpp | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'FastDecode.cpp')
| -rw-r--r-- | FastDecode.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
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 <cstring> +#include <functional> +#include <algorithm> +#include <memory> +#include <vector> +#include <QMutexLocker> +#include <QtConcurrent/QtConcurrentRun> + +extern "C" void fast_decode_ (short[], int[], double *, char[], char[], char[], + fortran_charlen_t, fortran_charlen_t, + fortran_charlen_t); + +QFuture<FastDecodeResult> 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<char, 12> ownCall, dxCall; + std::copy_n (myCall, ownCall.size (), ownCall.begin ()); + std::copy_n (hisCall, dxCall.size (), dxCall.begin ()); + auto captured = std::make_shared<std::vector<short>> (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; + }); +} |
