X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fsigsession.cpp;h=cbb3192d6d2cffe92b24e97f15037b31d81e8ede;hb=d873f4d685e16c708a15fcde12fbbec66650511c;hp=5cc999829f7bd1748aeb07b2732eed883f5d438c;hpb=ae2d1bc5b5aba9fcdd7fef42ef1bc9069267d6f7;p=pulseview.git diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 5cc9998..cbb3192 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -54,6 +54,7 @@ using boost::function; using boost::lock_guard; using boost::mutex; using boost::shared_ptr; +using std::list; using std::map; using std::set; using std::string; @@ -70,6 +71,8 @@ SigSession::SigSession(DeviceManager &device_manager) : { // TODO: This should not be necessary _session = this; + + set_default_device(); } SigSession::~SigSession() @@ -287,6 +290,28 @@ void SigSession::set_capture_state(capture_state state) capture_state_changed(state); } +void SigSession::set_default_device() +{ + shared_ptr default_device; + const list< shared_ptr > &devices = + _device_manager.devices(); + + if (!devices.empty()) { + // Fall back to the first device in the list. + default_device = devices.front(); + + // Try and find the demo device and select that by default + BOOST_FOREACH (shared_ptr dev, devices) + if (strcmp(dev->dev_inst()->driver->name, + "demo") == 0) { + default_device = dev; + break; + } + } + + set_device(default_device); +} + void SigSession::update_signals(shared_ptr dev_inst) { assert(dev_inst);