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.
if (conversion_is_a2l()) {
analog_data = dynamic_pointer_cast<Analog>(data_);
- if (analog_data->analog_segments().size() == 0)
- return;
+ if (analog_data->analog_segments().size() == 0) {
+ unique_lock<mutex> 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();