From 2b3dda54bb8e390e6a5d378c0e88f2bafacf0870 Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Tue, 2 Jan 2018 11:07:36 +0100 Subject: [PATCH 1/1] SignalBase: Don't terminate conversion when there's no data Instead of terminating, we wait instead. We do this because SignalBase::on_samples_added() somehow doesn't reliably see that there's no conversion thread active anymore. conversion_thread_.joinable() returns true when the thread was already terminated for whatever reason, resulting in on_samples_added() trying to notify a non-existant thread. --- pv/data/signalbase.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pv/data/signalbase.cpp b/pv/data/signalbase.cpp index 26e01d05..018e4a27 100644 --- a/pv/data/signalbase.cpp +++ b/pv/data/signalbase.cpp @@ -542,13 +542,19 @@ void SignalBase::conversion_thread_proc() if (conversion_is_a2l()) { analog_data = dynamic_pointer_cast(data_); - if (analog_data->analog_segments().size() == 0) - return; + if (analog_data->analog_segments().size() == 0) { + unique_lock input_lock(conversion_input_mutex_); + conversion_input_cond_.wait(input_lock); + } } else // Currently, we only handle A2L conversions return; + // If we had to wait for input data, we may have been notified to terminate + if (conversion_interrupt_) + return; + uint32_t segment_id = 0; AnalogSegment *asegment = analog_data->analog_segments().front().get(); -- 2.30.2