X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fdecoderstack.cpp;h=f82d3ecc1ef82f32dbfbee4f460d5af588a2fd1c;hp=8284c7937c7a7ee6a68f334a587bee7374e97fcb;hb=f46e495ef1db0a4e522462ac18260f2151fa2b89;hpb=c1b2865ea8b10c4b41360b2fd1974a8bebaa0dea diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index 8284c793..f82d3ecc 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -58,6 +58,7 @@ namespace data { const double DecoderStack::DecodeMargin = 1.0; const double DecoderStack::DecodeThreshold = 0.2; const int64_t DecoderStack::DecodeChunkLength = 4096; +const unsigned int DecoderStack::DecodeNotifyPeriod = 65536; mutex DecoderStack::_global_decode_mutex; @@ -105,7 +106,7 @@ void DecoderStack::remove(int index) assert(index < (int)_stack.size()); // Find the decoder in the stack - list< shared_ptr >::iterator iter = _stack.begin(); + auto iter = _stack.begin(); for(int i = 0; i < index; i++, iter++) assert(iter != _stack.end()); @@ -158,8 +159,7 @@ void DecoderStack::get_annotation_subset( { lock_guard lock(_output_mutex); - std::map::const_iterator iter = - _rows.find(row); + const auto iter = _rows.find(row); if (iter != _rows.end()) (*iter).second.get_annotation_subset(dest, start_sample, end_sample); @@ -193,6 +193,14 @@ void DecoderStack::begin_decode() clear(); + // Check that all decoders have the required channels + BOOST_FOREACH(const shared_ptr &dec, _stack) + if (!dec->have_required_probes()) { + _error_message = tr("One or more required channels " + "have not been specified"); + return; + } + // Add classes BOOST_FOREACH (const shared_ptr &dec, _stack) { @@ -224,12 +232,12 @@ void DecoderStack::begin_decode() } } - // We get the logic data of the first probe in the list. + // We get the logic data of the first channel in the list. // This works because we are currently assuming all // LogicSignals have the same data/snapshot BOOST_FOREACH (const shared_ptr &dec, _stack) - if (dec && !dec->probes().empty() && - ((logic_signal = (*dec->probes().begin()).second)) && + if (dec && !dec->channels().empty() && + ((logic_signal = (*dec->channels().begin()).second)) && ((data = logic_signal->logic_data()))) break; @@ -256,8 +264,7 @@ uint64_t DecoderStack::get_max_sample_count() const { uint64_t max_sample_count = 0; - for (map::const_iterator i = _rows.begin(); - i != _rows.end(); i++) + for (auto i = _rows.cbegin(); i != _rows.end(); i++) max_sample_count = max(max_sample_count, (*i).second.get_max_sample()); @@ -306,6 +313,9 @@ void DecoderStack::decode_data( lock_guard lock(_output_mutex); _samples_decoded = chunk_end; } + + if (i % DecodeNotifyPeriod == 0) + new_decode_data(); } new_decode_data(); @@ -317,14 +327,8 @@ void DecoderStack::decode_proc() srd_session *session; srd_decoder_inst *prev_di = NULL; - assert(data); assert(_snapshot); - // Check that all decoders have the required probes - BOOST_FOREACH(const shared_ptr &dec, _stack) - if (!dec->have_required_probes()) - return; - // Create the session srd_session_new(&session); assert(session); @@ -390,11 +394,10 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder) const srd_decoder *const decc = pdata->pdo->di->decoder; assert(decc); - map::iterator row_iter = d->_rows.end(); + auto row_iter = d->_rows.end(); // Try looking up the sub-row of this class - const map, Row>::const_iterator r = - d->_class_rows.find(make_pair(decc, a.format())); + const auto r = d->_class_rows.find(make_pair(decc, a.format())); if (r != d->_class_rows.end()) row_iter = d->_rows.find((*r).second); else @@ -424,7 +427,8 @@ void DecoderStack::on_data_received() { { unique_lock lock(_input_mutex); - _sample_count = _snapshot->get_sample_count(); + if (_snapshot) + _sample_count = _snapshot->get_sample_count(); } _input_cond.notify_one(); } @@ -433,7 +437,8 @@ void DecoderStack::on_frame_ended() { { unique_lock lock(_input_mutex); - _frame_complete = true; + if (_snapshot) + _frame_complete = true; } _input_cond.notify_one(); }