]> sigrok.org Git - pulseview.git/blobdiff - pv/sigsession.cpp
Moved DeviceManager::use_device and release_device into DevInst
[pulseview.git] / pv / sigsession.cpp
index b5387877dda0a73a513f7cb5f066e030f3b17539..90fb2798abb7f5aa63e766c9973b0cc61c71fc5d 100644 (file)
@@ -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,42 +73,48 @@ SigSession::SigSession(DeviceManager &device_manager) :
 
 SigSession::~SigSession()
 {
+       using pv::device::Device;
+
        stop_capture();
 
        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<DevInst> SigSession::get_device() const
+shared_ptr<device::DevInst> SigSession::get_device() const
 {
        return _dev_inst;
 }
 
-void SigSession::set_device(shared_ptr<DevInst> dev_inst)
+void SigSession::set_device(shared_ptr<device::DevInst> 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<DevInst> 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<DevInst>();
+       _dev_inst = shared_ptr<device::DevInst>();
 }
 
 void SigSession::load_file(const string &name,
@@ -126,8 +132,8 @@ void SigSession::load_file(const string &name,
                        return;
                }
 
-               shared_ptr<DevInst> dev_inst(
-                       new DevInst((sr_dev_inst*)devlist->data));
+               shared_ptr<device::DevInst> dev_inst(
+                       new device::Device((sr_dev_inst*)devlist->data));
                g_slist_free(devlist);
 
                _decode_traces.clear();
@@ -146,7 +152,8 @@ void SigSession::load_file(const string &name,
                        return;
 
                _decode_traces.clear();
-               update_signals(shared_ptr<DevInst>(new DevInst(in->sdi)));
+               update_signals(shared_ptr<device::DevInst>(
+                       new device::Device(in->sdi)));
                read_sample_rate(in->sdi);
 
                _sampling_thread = boost::thread(
@@ -386,7 +393,7 @@ sr_input* SigSession::load_input_file_format(const string &filename,
        return in;
 }
 
-void SigSession::update_signals(shared_ptr<DevInst> dev_inst)
+void SigSession::update_signals(shared_ptr<device::DevInst> dev_inst)
 {
        assert(dev_inst);
        assert(_capture_state == Stopped);
@@ -568,7 +575,7 @@ void SigSession::load_input_thread_proc(const string name,
        delete in;
 }
 
-void SigSession::sample_thread_proc(shared_ptr<DevInst> dev_inst,
+void SigSession::sample_thread_proc(shared_ptr<device::DevInst> dev_inst,
        function<void (const QString)> error_handler)
 {
        assert(dev_inst);