X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fsigsession.cpp;h=90fb2798abb7f5aa63e766c9973b0cc61c71fc5d;hb=996b7c9da9b5cb56413e829217e1e7d7d7d520da;hp=809509bb78768fc9a054b1a7db8d6b64c2d57f4d;hpb=19adbc2c342b190161ec1223377a3619974b91f7;p=pulseview.git diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 809509b..90fb279 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -25,7 +25,7 @@ #include "sigsession.h" #include "devicemanager.h" -#include "devinst.h" +#include "device/device.h" #include "data/analog.h" #include "data/analogsnapshot.h" @@ -73,41 +73,48 @@ SigSession::SigSession(DeviceManager &device_manager) : SigSession::~SigSession() { + using pv::device::Device; + stop_capture(); - _sampling_thread.join(); + if (_sampling_thread.joinable()) + _sampling_thread.join(); - if (_dev_inst) - _device_manager.release_device(_dev_inst); + _dev_inst->release(); // TODO: This should not be necessary _session = NULL; } -shared_ptr SigSession::get_device() const +shared_ptr SigSession::get_device() const { return _dev_inst; } -void SigSession::set_device(shared_ptr dev_inst) +void SigSession::set_device(shared_ptr dev_inst) { + using pv::device::Device; + // Ensure we are not capturing before setting the device stop_capture(); if (_dev_inst) - _device_manager.release_device(_dev_inst); + _dev_inst->release(); + if (dev_inst) - _device_manager.use_device(dev_inst, this); + dev_inst->use(this); + _dev_inst = dev_inst; update_signals(dev_inst); } -void SigSession::release_device(shared_ptr dev_inst) +void SigSession::release_device(device::DevInst *dev_inst) { (void)dev_inst; + assert(_dev_inst.get() == dev_inst); assert(_capture_state == Stopped); - _dev_inst = shared_ptr(); + _dev_inst = shared_ptr(); } void SigSession::load_file(const string &name, @@ -125,8 +132,8 @@ void SigSession::load_file(const string &name, return; } - shared_ptr dev_inst( - new DevInst((sr_dev_inst*)devlist->data)); + shared_ptr dev_inst( + new device::Device((sr_dev_inst*)devlist->data)); g_slist_free(devlist); _decode_traces.clear(); @@ -145,7 +152,8 @@ void SigSession::load_file(const string &name, return; _decode_traces.clear(); - update_signals(shared_ptr(new DevInst(in->sdi))); + update_signals(shared_ptr( + new device::Device(in->sdi))); read_sample_rate(in->sdi); _sampling_thread = boost::thread( @@ -200,7 +208,8 @@ void SigSession::stop_capture() sr_session_stop(); // Check that sampling stopped - _sampling_thread.join(); + if (_sampling_thread.joinable()) + _sampling_thread.join(); } set< shared_ptr > SigSession::get_data() const @@ -384,7 +393,7 @@ sr_input* SigSession::load_input_file_format(const string &filename, return in; } -void SigSession::update_signals(shared_ptr dev_inst) +void SigSession::update_signals(shared_ptr dev_inst) { assert(dev_inst); assert(_capture_state == Stopped); @@ -442,8 +451,8 @@ void SigSession::update_signals(shared_ptr dev_inst) switch(probe->type) { case SR_PROBE_LOGIC: signal = shared_ptr( - new view::LogicSignal(*this, probe, - _logic_data)); + new view::LogicSignal(dev_inst, + probe, _logic_data)); break; case SR_PROBE_ANALOG: @@ -451,8 +460,8 @@ void SigSession::update_signals(shared_ptr dev_inst) shared_ptr data( new data::Analog()); signal = shared_ptr( - new view::AnalogSignal(*this, probe, - data)); + new view::AnalogSignal(dev_inst, + probe, data)); break; } @@ -566,7 +575,7 @@ void SigSession::load_input_thread_proc(const string name, delete in; } -void SigSession::sample_thread_proc(shared_ptr dev_inst, +void SigSession::sample_thread_proc(shared_ptr dev_inst, function error_handler) { assert(dev_inst); @@ -645,7 +654,7 @@ void SigSession::feed_in_logic(const sr_datafeed_logic &logic) // Create a new data snapshot _cur_logic_snapshot = shared_ptr( - new data::LogicSnapshot(logic)); + new data::LogicSnapshot(logic, _dev_inst->get_sample_limit())); _logic_data->push_snapshot(_cur_logic_snapshot); } else @@ -687,7 +696,7 @@ void SigSession::feed_in_analog(const sr_datafeed_analog &analog) // Create a snapshot, keep it in the maps of probes snapshot = shared_ptr( - new data::AnalogSnapshot()); + new data::AnalogSnapshot(_dev_inst->get_sample_limit())); _cur_analog_snapshots[probe] = snapshot; // Find the annalog data associated with the probe