X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fdecoderstack.cpp;h=c3bf26d25699c12135707b40512414c9ee0ef4f3;hp=2344804fd1f17d2e2490f83fa6d8df9128084f12;hb=8bd26d8b9c831b509ee3241ea4dac6f50c023622;hpb=1c5fb7593d34daeca31148eb48de4ff7a0c6aa05 diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index 2344804f..c3bf26d2 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; @@ -193,6 +194,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 +233,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; @@ -249,8 +258,7 @@ void DecoderStack::begin_decode() if (_samplerate == 0.0) _samplerate = 1.0; - _decode_thread = boost::thread(&DecoderStack::decode_proc, this, - data); + _decode_thread = boost::thread(&DecoderStack::decode_proc, this); } uint64_t DecoderStack::get_max_sample_count() const @@ -307,25 +315,22 @@ void DecoderStack::decode_data( lock_guard lock(_output_mutex); _samples_decoded = chunk_end; } + + if (i % DecodeNotifyPeriod == 0) + new_decode_data(); } new_decode_data(); } -void DecoderStack::decode_proc(shared_ptr data) +void DecoderStack::decode_proc() { optional sample_count; 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); @@ -425,7 +430,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(); } @@ -434,7 +440,8 @@ void DecoderStack::on_frame_ended() { { unique_lock lock(_input_mutex); - _frame_complete = true; + if (_snapshot) + _frame_complete = true; } _input_cond.notify_one(); }