X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;ds=sidebyside;f=pv%2Fsigsession.cpp;h=5ab30ab1299e2e7bb81475053049eb46f189c3e1;hb=42a113fe1270485a0c06e22ce43860db8b48d2c3;hp=c5a7d494ecf8ed55237b4c440bd3f4497e72c398;hpb=884971565598bdd7641f64d9e76dba2cc9b16c01;p=pulseview.git diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index c5a7d49..5ab30ab 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -20,6 +20,7 @@ #include "sigsession.h" +#include "devicemanager.h" #include "data/analog.h" #include "data/analogsnapshot.h" #include "data/logic.h" @@ -39,7 +40,8 @@ namespace pv { // TODO: This should not be necessary SigSession* SigSession::_session = NULL; -SigSession::SigSession() : +SigSession::SigSession(DeviceManager &device_manager) : + _device_manager(device_manager), _sdi(NULL), _capture_state(Stopped) { @@ -59,15 +61,28 @@ SigSession::~SigSession() _session = NULL; } +struct sr_dev_inst* SigSession::get_device() const +{ + return _sdi; +} + void SigSession::set_device(struct sr_dev_inst *sdi) { if (_sdi) - sr_dev_close(_sdi); + _device_manager.release_device(_sdi); if (sdi) - sr_dev_open(sdi); + _device_manager.use_device(sdi, this); _sdi = sdi; } +void SigSession::release_device(struct sr_dev_inst *sdi) +{ + (void)sdi; + + assert(_capture_state == Stopped); + _sdi = NULL; +} + void SigSession::load_file(const string &name, function error_handler) { @@ -166,6 +181,10 @@ void SigSession::load_thread_proc(const string name, sr_session_destroy(); set_capture_state(Stopped); + + // Confirm that SR_DF_END was received + assert(!_cur_logic_snapshot); + assert(!_cur_analog_snapshot); } void SigSession::sample_thread_proc(struct sr_dev_inst *sdi, @@ -204,6 +223,10 @@ void SigSession::sample_thread_proc(struct sr_dev_inst *sdi, sr_session_destroy(); set_capture_state(Stopped); + + // Confirm that SR_DF_END was received + assert(!_cur_logic_snapshot); + assert(!_cur_analog_snapshot); } void SigSession::feed_in_header(const sr_dev_inst *sdi)