X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fdevice%2Fdevice.cpp;h=40044f8cd9490d8cae5be998f8359881114696e8;hb=bb3030b34e44733036acdfe5b4d4ec0705146831;hp=4a3ec35f1869364c04f02da03f2577c36cdcf7f8;hpb=07dcf5615620315f4eda91a930b8540e64b625f2;p=pulseview.git diff --git a/pv/device/device.cpp b/pv/device/device.cpp index 4a3ec35..40044f8 100644 --- a/pv/device/device.cpp +++ b/pv/device/device.cpp @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include @@ -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(&SigSession::_sr_session); + + assert(_sdi); + sr_dev_open(_sdi); + if (sr_session_dev_add(SigSession::_sr_session, _sdi) != SR_OK) + throw QString(tr("Failed to use device.")); +} + +void Device::release() +{ + if (_owner) { + DevInst::release(); + sr_session_destroy(SigSession::_sr_session); + } + + sr_dev_close(_sdi); +} + std::string Device::format_device_title() const { ostringstream s; @@ -66,17 +89,5 @@ std::string Device::format_device_title() const return s.str(); } -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; - assert(p); - if (p->trigger && p->trigger[0] != '\0') - return true; - } - return false; -} - } // device } // pv