summaryrefslogtreecommitdiff
path: root/Audio/TxAudioQueue.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 /Audio/TxAudioQueue.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 'Audio/TxAudioQueue.cpp')
-rw-r--r--Audio/TxAudioQueue.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/Audio/TxAudioQueue.cpp b/Audio/TxAudioQueue.cpp
index 9217d199..0bbaa2bd 100644
--- a/Audio/TxAudioQueue.cpp
+++ b/Audio/TxAudioQueue.cpp
@@ -63,13 +63,19 @@ TxAudioQueueEnqueueResult TxAudioQueue::enqueue (
TxAudioQueueEnqueueResult TxAudioQueue::enqueue (
qint16 const * samples, qint64 count, TxAudioQueueEpoch epoch)
{
- bool accepted {false};
+ TxAudioQueueEnqueueFailure failure {TxAudioQueueEnqueueFailure::StaleEpoch};
TxAudioQueueEpoch current_epoch;
if (impl_->tryEpoch (current_epoch) && epoch == current_epoch)
{
- accepted = impl_->fifo.enqueue (samples, count, epoch.value ());
+ failure = impl_->fifo.enqueue (samples, count, epoch.value ())
+ ? TxAudioQueueEnqueueFailure::None
+ : TxAudioQueueEnqueueFailure::Capacity;
}
- return TxAudioQueueEnqueueResult {accepted, progress ()};
+ return TxAudioQueueEnqueueResult {
+ failure == TxAudioQueueEnqueueFailure::None,
+ failure,
+ progress ()
+ };
}
void TxAudioQueue::clear (TxAudioQueueEpoch epoch)
@@ -108,14 +114,20 @@ TxAudioQueueDrainState TxAudioQueue::takeDrainReady () noexcept
TxAudioQueueProgress TxAudioQueue::progress () const noexcept
{
- TxAudioQueueEpoch epoch;
- impl_->tryEpoch (epoch);
- return TxAudioQueueProgress {
- epoch,
+ auto const before = impl_->epoch_sequence.load (std::memory_order_acquire);
+ if (before & 1) return {};
+
+ TxAudioQueueProgress result {
+ TxAudioQueueEpoch {impl_->epoch.load (std::memory_order_relaxed)},
impl_->fifo.queuedReal (),
impl_->fifo.servedReal (),
impl_->fifo.totalReal ()
};
+ std::atomic_thread_fence (std::memory_order_acquire);
+ auto const after = impl_->epoch_sequence.load (std::memory_order_relaxed);
+ if (!TxAudioQueueDetail::tryMakeEpochSnapshot (
+ before, result.epoch.value (), after, result.epoch)) return {};
+ return result;
}
qint64 TxAudioQueue::capacity () const noexcept