X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fstoresession.cpp;h=6ecde13aff92a5594eb3a0f931687e5fa7170d9d;hp=058b46a99ee8d1d5b6434cd33e6da93c91d080fd;hb=f3d66e52ed6b454ea7a0662d5e6367e230116a2b;hpb=2acdb232d6bb452cfdfaea3ef5218fb4da592329 diff --git a/pv/storesession.cpp b/pv/storesession.cpp index 058b46a9..6ecde13a 100644 --- a/pv/storesession.cpp +++ b/pv/storesession.cpp @@ -22,9 +22,9 @@ #include "storesession.hpp" -#include +#include #include -#include +#include #include #include @@ -53,7 +53,7 @@ namespace pv { const size_t StoreSession::BlockSize = 1024 * 1024; StoreSession::StoreSession(const std::string &file_name, - const SigSession &session) : + const Session &session) : file_name_(file_name), session_(session), interrupt_(false), @@ -106,17 +106,17 @@ bool StoreSession::start() return false; } - // Get the snapshot - const deque< shared_ptr > &snapshots = - data->get_snapshots(); + // Get the segment + const deque< shared_ptr > &segments = + data->logic_segments(); - if (snapshots.empty()) { - error_ = tr("No snapshots to save."); + if (segments.empty()) { + error_ = tr("No segments to save."); return false; } - const shared_ptr snapshot(snapshots.front()); - assert(snapshot); + const shared_ptr segment(segments.front()); + assert(segment); // Begin storing try { @@ -127,15 +127,15 @@ bool StoreSession::start() {{"filename", Glib::Variant::create(file_name_)}}); auto meta = context->create_meta_packet( - {{ConfigKey::SAMPLERATE, - Glib::Variant::create(data->samplerate())}}); + {{ConfigKey::SAMPLERATE, Glib::Variant::create( + segment->samplerate())}}); output_->receive(meta); } catch (Error error) { error_ = tr("Error while saving."); return false; } - thread_ = std::thread(&StoreSession::store_proc, this, snapshot); + thread_ = std::thread(&StoreSession::store_proc, this, segment); return true; } @@ -150,9 +150,9 @@ void StoreSession::cancel() interrupt_ = true; } -void StoreSession::store_proc(shared_ptr snapshot) +void StoreSession::store_proc(shared_ptr segment) { - assert(snapshot); + assert(segment); uint64_t start_sample = 0, sample_count; unsigned progress_scale = 0; @@ -161,10 +161,10 @@ void StoreSession::store_proc(shared_ptr snapshot) uint8_t *const data = new uint8_t[BlockSize]; assert(data); - const int unit_size = snapshot->unit_size(); + const int unit_size = segment->unit_size(); assert(unit_size != 0); - sample_count = snapshot->get_sample_count(); + sample_count = segment->get_sample_count(); // Qt needs the progress values to fit inside an int. If they would // not, scale the current and max values down until they do. @@ -181,7 +181,7 @@ void StoreSession::store_proc(shared_ptr snapshot) const uint64_t end_sample = min( start_sample + samples_per_block, sample_count); - snapshot->get_samples(data, start_sample, end_sample); + segment->get_samples(data, start_sample, end_sample); size_t length = end_sample - start_sample; @@ -198,6 +198,9 @@ void StoreSession::store_proc(shared_ptr snapshot) units_stored_ = start_sample >> progress_scale; } + // Zeroing the progress variables indicates completion + units_stored_ = unit_count_ = 0; + progress_updated(); output_.reset();