projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
View: Fix view item positioning
[pulseview.git]
/
pv
/
session.cpp
diff --git
a/pv/session.cpp
b/pv/session.cpp
index 2e98c8f73f40c08a70f451c60716824a1b348bbb..c464942893c271a16c637a4df1c5aac982d9cd9c 100644
(file)
--- a/
pv/session.cpp
+++ b/
pv/session.cpp
@@
-105,7
+105,8
@@
Session::Session(DeviceManager &device_manager, QString name) :
default_name_(name),
name_(name),
capture_state_(Stopped),
default_name_(name),
name_(name),
capture_state_(Stopped),
- cur_samplerate_(0)
+ cur_samplerate_(0),
+ data_saved_(true)
{
}
{
}
@@
-172,6
+173,11
@@
shared_ptr<pv::toolbars::MainBar> Session::main_bar() const
return main_bar_;
}
return main_bar_;
}
+bool Session::data_saved() const
+{
+ return data_saved_;
+}
+
void Session::save_settings(QSettings &settings) const
{
map<string, string> dev_info;
void Session::save_settings(QSettings &settings) const
{
map<string, string> dev_info;
@@
-851,10
+857,31
@@
void Session::sample_thread_proc(function<void (const QString)> error_handler)
assert(0);
}
assert(0);
}
+ // Optimize memory usage
+ free_unused_memory();
+
+ // We now have unsaved data unless we just "captured" from a file
+ shared_ptr<devices::File> file_device =
+ dynamic_pointer_cast<devices::File>(device_);
+
+ if (!file_device)
+ data_saved_ = false;
+
if (out_of_memory_)
error_handler(tr("Out of memory, acquisition stopped."));
}
if (out_of_memory_)
error_handler(tr("Out of memory, acquisition stopped."));
}
+void Session::free_unused_memory()
+{
+ for (shared_ptr<data::SignalData> data : all_signal_data_) {
+ const vector< shared_ptr<data::Segment> > segments = data->segments();
+
+ for (shared_ptr<data::Segment> segment : segments) {
+ segment->free_unused_memory();
+ }
+ }
+}
+
void Session::feed_in_header()
{
cur_samplerate_ = device_->read_config<uint64_t>(ConfigKey::SAMPLERATE);
void Session::feed_in_header()
{
cur_samplerate_ = device_->read_config<uint64_t>(ConfigKey::SAMPLERATE);
@@
-914,8
+941,6
@@
void Session::feed_in_logic(shared_ptr<Logic> logic)
{
lock_guard<recursive_mutex> lock(data_mutex_);
{
lock_guard<recursive_mutex> lock(data_mutex_);
- const size_t sample_count = logic->data_length() / logic->unit_size();
-
if (!logic_data_) {
// The only reason logic_data_ would not have been created is
// if it was not possible to determine the signals when the
if (!logic_data_) {
// The only reason logic_data_ would not have been created is
// if it was not possible to determine the signals when the
@@
-929,8
+954,7
@@
void Session::feed_in_logic(shared_ptr<Logic> logic)
// Create a new data segment
cur_logic_segment_ = shared_ptr<data::LogicSegment>(
// Create a new data segment
cur_logic_segment_ = shared_ptr<data::LogicSegment>(
- new data::LogicSegment(
- logic, cur_samplerate_, sample_count));
+ new data::LogicSegment(*logic_data_, logic, cur_samplerate_));
logic_data_->push_segment(cur_logic_segment_);
// @todo Putting this here means that only listeners querying
logic_data_->push_segment(cur_logic_segment_);
// @todo Putting this here means that only listeners querying
@@
-973,12
+997,6
@@
void Session::feed_in_analog(shared_ptr<Analog> analog)
// in the sweep containing this segment.
sweep_beginning = true;
// in the sweep containing this segment.
sweep_beginning = true;
- // Create a segment, keep it in the maps of channels
- segment = shared_ptr<data::AnalogSegment>(
- new data::AnalogSegment(
- cur_samplerate_, sample_count));
- cur_analog_segments_[channel] = segment;
-
// Find the analog data associated with the channel
shared_ptr<data::SignalBase> base = signalbase_from_channel(channel);
assert(base);
// Find the analog data associated with the channel
shared_ptr<data::SignalBase> base = signalbase_from_channel(channel);
assert(base);
@@
-986,6
+1004,11
@@
void Session::feed_in_analog(shared_ptr<Analog> analog)
shared_ptr<data::Analog> data(base->analog_data());
assert(data);
shared_ptr<data::Analog> data(base->analog_data());
assert(data);
+ // Create a segment, keep it in the maps of channels
+ segment = shared_ptr<data::AnalogSegment>(
+ new data::AnalogSegment(*data, cur_samplerate_));
+ cur_analog_segments_[channel] = segment;
+
// Push the segment into the analog data.
data->push_segment(segment);
}
// Push the segment into the analog data.
data->push_segment(segment);
}
@@
-1008,6
+1031,8
@@
void Session::feed_in_analog(shared_ptr<Analog> analog)
void Session::data_feed_in(shared_ptr<sigrok::Device> device,
shared_ptr<Packet> packet)
{
void Session::data_feed_in(shared_ptr<sigrok::Device> device,
shared_ptr<Packet> packet)
{
+ static bool frame_began=false;
+
(void)device;
assert(device);
(void)device;
assert(device);
@@
-1029,6
+1054,7
@@
void Session::data_feed_in(shared_ptr<sigrok::Device> device,
case SR_DF_FRAME_BEGIN:
feed_in_frame_begin();
case SR_DF_FRAME_BEGIN:
feed_in_frame_begin();
+ frame_began = true;
break;
case SR_DF_LOGIC:
break;
case SR_DF_LOGIC:
@@
-1049,6
+1075,7
@@
void Session::data_feed_in(shared_ptr<sigrok::Device> device,
}
break;
}
break;
+ case SR_DF_FRAME_END:
case SR_DF_END:
{
{
case SR_DF_END:
{
{
@@
-1056,7
+1083,10
@@
void Session::data_feed_in(shared_ptr<sigrok::Device> device,
cur_logic_segment_.reset();
cur_analog_segments_.clear();
}
cur_logic_segment_.reset();
cur_analog_segments_.clear();
}
- frame_ended();
+ if (frame_began) {
+ frame_began = false;
+ frame_ended();
+ }
break;
}
default:
break;
}
default:
@@
-1064,4
+1094,9
@@
void Session::data_feed_in(shared_ptr<sigrok::Device> device,
}
}
}
}
+void Session::on_data_saved()
+{
+ data_saved_ = true;
+}
+
} // namespace pv
} // namespace pv