]> sigrok.org Git - pulseview.git/blobdiff - pv/device/device.cpp
Replaced boost::shared_ptr with std::shared_ptr
[pulseview.git] / pv / device / device.cpp
index 4a3ec35f1869364c04f02da03f2577c36cdcf7f8..4a30e5fcd75c3bb12df003096888c6c16dd116aa 100644 (file)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <cassert>
 #include <sstream>
 
 #include <libsigrok/libsigrok.h>
@@ -41,6 +42,28 @@ sr_dev_inst* Device::dev_inst() const
        return _sdi;
 }
 
+void Device::use(SigSession *owner) throw(QString)
+{
+       DevInst::use(owner);
+
+       sr_session_new();
+
+       assert(_sdi);
+       sr_dev_open(_sdi);
+       if (sr_session_dev_add(_sdi) != SR_OK)
+               throw QString(tr("Failed to use device."));
+}
+
+void Device::release()
+{
+       if (_owner) {
+               DevInst::release();
+               sr_session_destroy();
+       }
+
+       sr_dev_close(_sdi);
+}
+
 std::string Device::format_device_title() const
 {
        ostringstream s;
@@ -69,8 +92,8 @@ std::string Device::format_device_title() const
 bool Device::is_trigger_enabled() const
 {
        assert(_sdi);
-       for (const GSList *l = _sdi->probes; l; l = l->next) {
-               const sr_probe *const p = (const sr_probe *)l->data;
+       for (const GSList *l = _sdi->channels; l; l = l->next) {
+               const sr_channel *const p = (const sr_channel *)l->data;
                assert(p);
                if (p->trigger && p->trigger[0] != '\0')
                        return true;