From da33df368f44de48952da3dd6e03189d21da0c9b Mon Sep 17 00:00:00 2001 From: Franco Venturi Date: Mon, 18 Oct 2021 20:02:42 -0400 Subject: [PATCH] have the stop() method notify the callback threads so they can terminate after sdrplay_api_Uninit() --- lib/rsp_impl.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/rsp_impl.cc b/lib/rsp_impl.cc index c27bdc0..2561ab8 100644 --- a/lib/rsp_impl.cc +++ b/lib/rsp_impl.cc @@ -541,6 +541,13 @@ bool rsp_impl::stop() } } run_status = RunStatus::idle; + + // notify the callback threads so they can terminate + ring_buffers[0].tail = ring_buffers[0].head; + ring_buffers[1].tail = ring_buffers[1].head; + ring_buffers[0].overflow.notify_one(); + ring_buffers[1].overflow.notify_one(); + return true; } @@ -711,6 +718,10 @@ void rsp_impl::stream_callback(short *xi, short *xq, return ring_buffer.tail + ring_buffer_overflow >= ring_buffer.head; }); + if (run_status != RunStatus::streaming) { + return; + } + unsigned long new_head = ring_buffer.head + numSamples; size_t start = static_cast(ring_buffer.head & RingBufferMask); size_t end = static_cast(new_head & RingBufferMask);