diff options
| author | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:35 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:35 +0200 |
| commit | ffc62c792c9a5196cb4ce7a353287dfe20db6524 (patch) | |
| tree | 1269efa852935b183daae4bb33a58d1b4d2ffb53 /Modulator/JttyPcmFifo.cpp | |
| parent | 059831534c7e884f0a607ed86b582fd00d821731 (diff) | |
New upstream version 3.3.0~beta1+dfsgupstream/3.3.0_beta1+dfsg
Diffstat (limited to 'Modulator/JttyPcmFifo.cpp')
| -rw-r--r-- | Modulator/JttyPcmFifo.cpp | 9 |
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; } |
