From 411d03ac6b8ee1a8c06f952b9378c90516a715b7 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 20 Apr 2018 12:29:24 +0200 Subject: ThreadsafeQueue: add wakeup event instead of custom termination markers This avoids the issue that the ~SDR termination marker doesn't reach the consumer because it's still prebuffering --- src/output/SDR.cpp | 10 +++++----- src/output/Soapy.h | 1 - src/output/USRPTime.h | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src/output') diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp index b47433d..7c1b585 100644 --- a/src/output/SDR.cpp +++ b/src/output/SDR.cpp @@ -84,9 +84,7 @@ SDR::~SDR() { m_running.store(false); - FrameData end_marker; - end_marker.buf.clear(); - m_queue.push(end_marker); + m_queue.trigger_wakeup(); if (m_device_thread.joinable()) { m_device_thread.join(); @@ -181,7 +179,7 @@ void SDR::process_thread_entry() m_queue.wait_and_pop(frame, pop_prebuffering); etiLog.log(trace, "SDR,pop"); - if (m_running.load() == false or frame.buf.empty()) { + if (m_running.load() == false) { break; } @@ -203,8 +201,10 @@ void SDR::process_thread_entry() } } } + catch (const ThreadsafeQueueWakeup& e) { } catch (const runtime_error& e) { - etiLog.level(error) << "SDR output thread caught runtime error: " << e.what(); + etiLog.level(error) << "SDR output thread caught runtime error: " << + e.what(); } m_running.store(false); diff --git a/src/output/Soapy.h b/src/output/Soapy.h index 5c20156..3045420 100644 --- a/src/output/Soapy.h +++ b/src/output/Soapy.h @@ -48,7 +48,6 @@ DESCRIPTION: #include "ModPlugin.h" #include "EtiReader.h" #include "RemoteControl.h" -#include "ThreadsafeQueue.h" namespace Output { diff --git a/src/output/USRPTime.h b/src/output/USRPTime.h index 70e55ae..51ca800 100644 --- a/src/output/USRPTime.h +++ b/src/output/USRPTime.h @@ -48,7 +48,6 @@ DESCRIPTION: #include "output/SDR.h" #include "TimestampDecoder.h" #include "RemoteControl.h" -#include "ThreadsafeQueue.h" #include #include -- cgit v1.2.3