diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:28 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:28 +0200 |
| commit | 69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch) | |
| tree | ebc98370a697a9bbd6b973a14fa5113c475c6db7 /FastDecode.cpp | |
| parent | 3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff) | |
| parent | 059831534c7e884f0a607ed86b582fd00d821731 (diff) | |
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg'
with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
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; + }); +} |
