X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fdecodesignal.cpp;h=e70947b2c4989a11ddaf0cdaee38b3af946afa07;hp=8483d91d0ce4a2b41de67a07605d2a757d761137;hb=ba5b52e12e2d95c5ac9155cb697e002df5df1de6;hpb=5620539c5113781af252576f9b7af5420e875ba7 diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 8483d91d..e70947b2 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -902,6 +902,13 @@ void DecodeSignal::decode_data( const int64_t chunk_end = min(i + chunk_sample_count, abs_start_samplenum + sample_count); + // Report this chunk as already decoded so that annotations don't + // appear in an area that we claim to not having been been decoded yet + { + lock_guard lock(output_mutex_); + segments_.at(current_segment_id_).samples_decoded = chunk_end; + } + int64_t data_size = (chunk_end - i) * unit_size; uint8_t* chunk = new uint8_t[data_size]; input_segment->get_samples(i, chunk_end, chunk); @@ -915,11 +922,6 @@ void DecodeSignal::decode_data( delete[] chunk; - { - lock_guard lock(output_mutex_); - segments_.at(current_segment_id_).samples_decoded = chunk_end; - } - // Notify the frontend that we processed some data and // possibly have new annotations as well new_annotations(); @@ -1004,8 +1006,6 @@ void DecodeSignal::decode_proc() void DecodeSignal::start_srd_session() { - uint64_t samplerate; - // If there were stack changes, the session has been destroyed by now, so if // it hasn't been destroyed, we can just reset and re-use it if (srd_session_) { @@ -1016,13 +1016,20 @@ void DecodeSignal::start_srd_session() // and) construction of another decoder stack. // TODO Reduce redundancy, use a common code path for - // the meta/cb/start sequence? + // the meta/start sequence? terminate_srd_session(); - srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE, - g_variant_new_uint64(segments_.at(current_segment_id_).samplerate)); - srd_pd_output_callback_add(srd_session_, SRD_OUTPUT_ANN, - DecodeSignal::annotation_callback, this); + + // Metadata is cleared also, so re-set it + uint64_t samplerate = 0; + if (segments_.size() > 0) + samplerate = segments_.at(current_segment_id_).samplerate; + if (samplerate) + srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE, + g_variant_new_uint64(samplerate)); + for (const shared_ptr &dec : stack_) + dec->apply_all_options(); srd_session_start(srd_session_); + return; } @@ -1049,10 +1056,9 @@ void DecodeSignal::start_srd_session() } // Start the session - samplerate = segments_.at(current_segment_id_).samplerate; - if (samplerate) + if (segments_.size() > 0) srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE, - g_variant_new_uint64(samplerate)); + g_variant_new_uint64(segments_.at(current_segment_id_).samplerate)); srd_pd_output_callback_add(srd_session_, SRD_OUTPUT_ANN, DecodeSignal::annotation_callback, this); @@ -1070,8 +1076,19 @@ void DecodeSignal::terminate_srd_session() // have completed their operation, and reduces response time for // those stacks which still are processing data while the // application no longer wants them to. - if (srd_session_) + if (srd_session_) { srd_session_terminate_reset(srd_session_); + + // Metadata is cleared also, so re-set it + uint64_t samplerate = 0; + if (segments_.size() > 0) + samplerate = segments_.at(current_segment_id_).samplerate; + if (samplerate) + srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE, + g_variant_new_uint64(samplerate)); + for (const shared_ptr &dec : stack_) + dec->apply_all_options(); + } } void DecodeSignal::stop_srd_session()