-
- // No more input data and session is stopped, let the decode thread
- // process any pending data, terminate and release the global SRD mutex
- // in order to let other decoders run
- decode_input_cond_.notify_one();
-}
-
-void DecodeSignal::query_input_metadata()
-{
- // Update the samplerate and start time because we cannot start
- // the libsrd session without the current samplerate
-
- // 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;
-
- 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_);
-
- if (decode_interrupt_)
- return;
-
- do {
- if (!logic_data->logic_segments().empty()) {
- shared_ptr<LogicSegment> first_segment =
- any_channel->assigned_signal->logic_data()->logic_segments().front();
- start_time_ = first_segment->start_time();
- samplerate_ = first_segment->samplerate();
- if (samplerate_ > 0)
- samplerate_valid = true;
- }
-
- if (!samplerate_valid) {
- // 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 (!samplerate_valid && !decode_interrupt_);