X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fstoresession.cpp;h=f8ab2e69bc78c1a2ed985e86d176c662b56084d3;hp=9a481dd86696ba60ae5e4b61c03bd9719156b1c8;hb=bf0edd2b0cbb5f4bd5d69b0f00bcea7d037e2287;hpb=c51ae0b4200f11bfcb352677cfd07b62ac12230c diff --git a/pv/storesession.cpp b/pv/storesession.cpp index 9a481dd..f8ab2e6 100644 --- a/pv/storesession.cpp +++ b/pv/storesession.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -109,7 +110,7 @@ bool StoreSession::start() shared_ptr any_segment; shared_ptr lsegment; - vector< shared_ptr > achannel_list; + vector< shared_ptr > achannel_list; vector< shared_ptr > asegment_list; for (shared_ptr signal : sigs) { @@ -160,16 +161,20 @@ bool StoreSession::start() } // Check whether the user wants to export a certain sample range + uint64_t end_sample; + if (sample_range_.first == sample_range_.second) { start_sample_ = 0; sample_count_ = any_segment->get_sample_count(); } else { if (sample_range_.first > sample_range_.second) { start_sample_ = sample_range_.second; - sample_count_ = sample_range_.first - sample_range_.second; + end_sample = min(sample_range_.first, any_segment->get_sample_count()); + sample_count_ = end_sample - start_sample_; } else { start_sample_ = sample_range_.first; - sample_count_ = sample_range_.second - sample_range_.first; + end_sample = min(sample_range_.second, any_segment->get_sample_count()); + sample_count_ = end_sample - start_sample_; } } @@ -210,7 +215,7 @@ void StoreSession::cancel() interrupt_ = true; } -void StoreSession::store_proc(vector< shared_ptr > achannel_list, +void StoreSession::store_proc(vector< shared_ptr > achannel_list, vector< shared_ptr > asegment_list, shared_ptr lsegment) { @@ -255,7 +260,7 @@ void StoreSession::store_proc(vector< shared_ptr > achannel_lis const auto context = session_.device_manager().context(); for (unsigned int i = 0; i < achannel_list.size(); i++) { - shared_ptr achannel = achannel_list.at(i); + shared_ptr achannel = (achannel_list.at(i))->channel(); shared_ptr asegment = asegment_list.at(i); const float *adata =