]> sigrok.org Git - pulseview.git/commitdiff
DecodeSignal: Improve robustness
authorSoeren Apel <redacted>
Sat, 1 Jul 2017 21:37:55 +0000 (23:37 +0200)
committerUwe Hermann <redacted>
Wed, 5 Jul 2017 22:37:08 +0000 (00:37 +0200)
pv/data/decodesignal.cpp

index 1d9f3c8ffb0dababec91fd579de2eef4b17e22e7..5acf9eec634380533a2cb1c0bfeceb767cec6f7b 100644 (file)
@@ -749,12 +749,24 @@ void DecodeSignal::query_input_metadata()
        // TODO Currently we assume all channels have the same sample rate
        // and start time
        bool samplerate_valid = false;
        // TODO Currently we assume all channels have the same sample rate
        // and start time
        bool samplerate_valid = false;
+       data::DecodeChannel *any_channel;
+       shared_ptr<Logic> logic_data;
 
 
-       auto any_channel = find_if(channels_.begin(), channels_.end(),
-               [](data::DecodeChannel ch) { return ch.assigned_signal; });
+       do {
+               any_channel = &(*find_if(channels_.begin(), channels_.end(),
+                       [](data::DecodeChannel ch) { return ch.assigned_signal; }));
+
+               logic_data = any_channel->assigned_signal->logic_data();
+
+               if (!logic_data) {
+                       // Wait until input data is available or an interrupt was requested
+                       unique_lock<mutex> input_wait_lock(input_mutex_);
+                       decode_input_cond_.wait(input_wait_lock);
+               }
+       } while (!logic_data && !decode_interrupt_);
 
 
-       shared_ptr<Logic> logic_data =
-               any_channel->assigned_signal->logic_data();
+       if (decode_interrupt_)
+               return;
 
        do {
                if (!logic_data->logic_segments().empty()) {
 
        do {
                if (!logic_data->logic_segments().empty()) {