X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsigsession.cpp;h=b93ecc85952ecc4053169782bd666bdd06cd968f;hp=5cc999829f7bd1748aeb07b2732eed883f5d438c;hb=a28c30252fd32d3185c62062dfad74ae659ae383;hpb=ae2d1bc5b5aba9fcdd7fef42ef1bc9069267d6f7 diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 5cc99982..b93ecc85 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() @@ -212,7 +215,7 @@ bool SigSession::add_decoder(srd_decoder *const dec) // Create the decoder decoder_stack = shared_ptr( - new data::DecoderStack(dec)); + new data::DecoderStack(*this, dec)); // Make a list of all the probes std::vector all_probes; @@ -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); @@ -468,6 +493,12 @@ void SigSession::feed_in_meta(const sr_dev_inst *sdi, signals_changed(); } +void SigSession::feed_in_frame_begin() +{ + if (_cur_logic_snapshot || !_cur_analog_snapshots.empty()) + frame_began(); +} + void SigSession::feed_in_logic(const sr_datafeed_logic &logic) { lock_guard lock(_data_mutex); @@ -487,6 +518,12 @@ void SigSession::feed_in_logic(const sr_datafeed_logic &logic) _cur_logic_snapshot = shared_ptr( new data::LogicSnapshot(logic, _dev_inst->get_sample_limit())); _logic_data->push_snapshot(_cur_logic_snapshot); + + // @todo Putting this here means that only listeners querying + // for logic will be notified. Currently the only user of + // frame_began is DecoderStack, but in future we need to signal + // this after both analog and logic sweeps have begun. + frame_began(); } else { @@ -494,7 +531,7 @@ void SigSession::feed_in_logic(const sr_datafeed_logic &logic) _cur_logic_snapshot->append_payload(logic); } - data_updated(); + data_received(); } void SigSession::feed_in_analog(const sr_datafeed_analog &analog) @@ -555,7 +592,7 @@ void SigSession::feed_in_analog(const sr_datafeed_analog &analog) set_capture_state(Running); } - data_updated(); + data_received(); } void SigSession::data_feed_in(const struct sr_dev_inst *sdi, @@ -575,6 +612,10 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi, *(const sr_datafeed_meta*)packet->payload); break; + case SR_DF_FRAME_BEGIN: + feed_in_frame_begin(); + break; + case SR_DF_LOGIC: assert(packet->payload); feed_in_logic(*(const sr_datafeed_logic*)packet->payload); @@ -592,7 +633,7 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi, _cur_logic_snapshot.reset(); _cur_analog_snapshots.clear(); } - data_updated(); + frame_ended(); break; } }