diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
| commit | 059831534c7e884f0a607ed86b582fd00d821731 (patch) | |
| tree | 76bcb67a78f8aa2654fd34c2ad801a62136b0170 /widgets/JttyN1mmOutput.hpp | |
| parent | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff) | |
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to 'widgets/JttyN1mmOutput.hpp')
| -rw-r--r-- | widgets/JttyN1mmOutput.hpp | 57 |
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 |
