summaryrefslogtreecommitdiff
path: root/widgets/JttyN1mmOutput.hpp
diff options
context:
space:
mode:
authorhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
committerhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
commitc25cbdf6fb6d946175f4335fab77bfea601b56db (patch)
tree6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /widgets/JttyN1mmOutput.hpp
parent71f5689252c9f13e70e1c24856904475b2307809 (diff)
parent0685fcada9f95fe90f70b387cd7d757da8209624 (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 'widgets/JttyN1mmOutput.hpp')
-rw-r--r--widgets/JttyN1mmOutput.hpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/widgets/JttyN1mmOutput.hpp b/widgets/JttyN1mmOutput.hpp
new file mode 100644
index 00000000..ad92fc23
--- /dev/null
+++ b/widgets/JttyN1mmOutput.hpp
@@ -0,0 +1,57 @@
+// -*- Mode: C++ -*-
+#ifndef JTTY_N1MM_OUTPUT_HPP
+#define JTTY_N1MM_OUTPUT_HPP
+
+#include <QSet>
+#include <QtGlobal>
+
+namespace Jtty
+{
+ class N1mmOutput
+ {
+ public:
+ void submit (qint64 requestId)
+ {
+ requests_.insert (requestId);
+ completionPending_ = true;
+ }
+
+ bool accept (qint64 requestId)
+ {
+ if (!requests_.contains (requestId)) return false;
+ acceptedAudio_ = true;
+ return true;
+ }
+ bool resolve (qint64 requestId) { return requests_.remove (requestId) != 0; }
+ bool pending () const { return completionPending_; }
+ bool finishRequested () const { return finishRequested_; }
+ bool startRequested () const { return startRequested_; }
+ void start () { finishRequested_ = false; startRequested_ = true; }
+ void started () { startRequested_ = false; }
+ void finish ()
+ {
+ if (completionPending_) finishRequested_ = true;
+ if (requests_.isEmpty ()) startRequested_ = false;
+ }
+ void abort () { *this = N1mmOutput {}; }
+
+ bool takeCompletion (bool audioActive, bool drained = false)
+ {
+ // Rejections can precede more TXTEXT in the same transaction. OFF
+ // closes an empty transaction; accepted audio completes only at drain.
+ if (!completionPending_ || !requests_.isEmpty () || audioActive
+ || (!finishRequested_ && !(drained && acceptedAudio_))) return false;
+ abort ();
+ return true;
+ }
+
+ private:
+ QSet<qint64> requests_;
+ bool completionPending_ {false};
+ bool finishRequested_ {false};
+ bool startRequested_ {false};
+ bool acceptedAudio_ {false};
+ };
+}
+
+#endif