Removed a redundant call to SigSession::set_device
[pulseview.git] / pv / sigsession.cpp
index 4469a3eef367071c44a545d3c3a1a8ae746742cc..9af7df74e7a5f967023a20a62c4f6e68ed3d8c16 100644 (file)
@@ -73,13 +73,14 @@ 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;
@@ -92,20 +93,25 @@ shared_ptr<device::DevInst> SigSession::get_device() const
 
 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<device::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<device::DevInst>();
@@ -473,20 +479,6 @@ void SigSession::update_signals(shared_ptr<device::DevInst> dev_inst)
        signals_changed();
 }
 
-bool SigSession::is_trigger_enabled() const
-{
-       assert(_dev_inst);
-       assert(_dev_inst->dev_inst());
-       for (const GSList *l = _dev_inst->dev_inst()->probes; l; l = l->next) {
-               const sr_probe *const p = (const sr_probe *)l->data;
-               assert(p);
-               if (p->trigger && p->trigger[0] != '\0')
-                       return true;
-       }
-
-       return false;
-}
-
 shared_ptr<view::Signal> SigSession::signal_from_probe(
        const sr_probe *probe) const
 {
@@ -590,7 +582,8 @@ void SigSession::sample_thread_proc(shared_ptr<device::DevInst> dev_inst,
                return;
        }
 
-       set_capture_state(is_trigger_enabled() ? AwaitingTrigger : Running);
+       set_capture_state(dev_inst->is_trigger_enabled() ?
+               AwaitingTrigger : Running);
 
        sr_session_run();
        sr_session_destroy();