From ffc62c792c9a5196cb4ce7a353287dfe20db6524 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Fri, 9 Oct 2026 14:12:35 +0200 Subject: New upstream version 3.3.0~beta1+dfsg --- Modulator/JttyPcmFifo.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Modulator/JttyPcmFifo.cpp') 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; } -- cgit v1.2.3