summaryrefslogtreecommitdiff
path: root/Modulator/JttyPcmFifo.cpp
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2026-10-20 22:35:06 +0100
committerDave Hibberd <hibby@debian.org>2026-10-20 22:35:06 +0100
commit82ebb1ed1af30cee4dfbb1c628431d32885a00e0 (patch)
tree1a1f782d3e576b758be0bc61171574a7cd8f2376 /Modulator/JttyPcmFifo.cpp
parent061658210acb6425517733ea012dda803a7f72a1 (diff)
parent61d684922b0f1c8455cc60eb3d123df058c9e1f5 (diff)
Merge tag 'debian/3.3.0_beta2+dfsg-1' into hibbian/trixie-backports
tagging wsjtx 3.3.0~beta2+dfsg-1
Diffstat (limited to 'Modulator/JttyPcmFifo.cpp')
-rw-r--r--Modulator/JttyPcmFifo.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/Modulator/JttyPcmFifo.cpp b/Modulator/JttyPcmFifo.cpp
index fd6d82d7..f78cbede 100644
--- a/Modulator/JttyPcmFifo.cpp
+++ b/Modulator/JttyPcmFifo.cpp
@@ -61,8 +61,8 @@ bool JttyPcmFifo::enqueue (qint16 const * samples, qint64 count, qint64 epoch)
{
if (!samples || count <= 0) return true;
- qint64 const used = m_used.load (std::memory_order_acquire);
- if (!jttyPcmEnqueueFits (m_capacity, used, count)) return false;
+ if (!jttyPcmEnqueueFits (
+ m_capacity, m_used.load (std::memory_order_acquire), count)) return false;
qint64 const tail = copyIntoRing (m_buffer, m_capacity,
m_tail.load (std::memory_order_relaxed),
@@ -170,9 +170,12 @@ JttyPcmFifo::DrainState JttyPcmFifo::takeDrainReady () noexcept
qint64 JttyPcmFifo::queuedReal () const noexcept
{
- qint64 const used = m_used.load (std::memory_order_acquire);
+ // Read the reset baseline and served count before occupancy: a consumer
+ // applying a reset stores the decremented occupancy before publishing the
+ // new served count, so this order never over-reports the logical queue.
qint64 const resetTotal = m_resetTotalBaseline.load (std::memory_order_acquire);
qint64 const served = m_servedReal.load (std::memory_order_acquire);
+ qint64 const used = m_used.load (std::memory_order_acquire);
qint64 const abortedQueued = resetTotal > served ? resetTotal - served : 0;
return used > abortedQueued ? used - abortedQueued : 0;
}