+ lock_guard<mutex> lock(_signals_mutex);
+
+ // Create the decoder
+ decoder_stack = shared_ptr<data::DecoderStack>(
+ new data::DecoderStack(*this, dec));
+
+ // Make a list of all the probes
+ std::vector<const srd_probe*> all_probes;
+ for(const GSList *i = dec->probes; i; i = i->next)
+ all_probes.push_back((const srd_probe*)i->data);
+ for(const GSList *i = dec->opt_probes; i; i = i->next)
+ all_probes.push_back((const srd_probe*)i->data);
+
+ // Auto select the initial probes
+ BOOST_FOREACH(const srd_probe *probe, all_probes)
+ BOOST_FOREACH(shared_ptr<view::Signal> s, _signals)
+ {
+ shared_ptr<view::LogicSignal> l =
+ dynamic_pointer_cast<view::LogicSignal>(s);
+ if (l && QString::fromUtf8(probe->name).
+ toLower().contains(
+ l->get_name().toLower()))
+ probes[probe] = l;
+ }
+
+ assert(decoder_stack);
+ assert(!decoder_stack->stack().empty());
+ assert(decoder_stack->stack().front());
+ decoder_stack->stack().front()->set_probes(probes);
+
+ // Create the decode signal
+ shared_ptr<view::DecodeTrace> d(
+ new view::DecodeTrace(*this, decoder_stack,
+ _decode_traces.size()));
+ _decode_traces.push_back(d);
+ }
+ catch(std::runtime_error e)
+ {
+ return false;
+ }
+
+ signals_changed();
+
+ // Do an initial decode
+ decoder_stack->begin_decode();
+
+ return true;
+}
+
+vector< shared_ptr<view::DecodeTrace> > SigSession::get_decode_signals() const
+{
+ lock_guard<mutex> lock(_signals_mutex);
+ return _decode_traces;
+}
+
+void SigSession::remove_decode_signal(view::DecodeTrace *signal)
+{
+ for (vector< shared_ptr<view::DecodeTrace> >::iterator i =
+ _decode_traces.begin();
+ i != _decode_traces.end();
+ i++)
+ if ((*i).get() == signal)
+ {
+ _decode_traces.erase(i);
+ signals_changed();
+ return;
+ }
+}
+#endif
+
+void SigSession::set_capture_state(capture_state state)
+{
+ lock_guard<mutex> lock(_sampling_mutex);
+ const bool changed = _capture_state != state;
+ _capture_state = state;
+ if(changed)
+ capture_state_changed(state);
+}
+
+void SigSession::set_default_device()
+{
+ shared_ptr<pv::device::DevInst> default_device;
+ const list< shared_ptr<device::Device> > &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<pv::device::Device> 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<device::DevInst> dev_inst)
+{
+ assert(dev_inst);
+ assert(_capture_state == Stopped);
+
+ unsigned int logic_probe_count = 0;
+
+ // Clear the decode traces
+ _decode_traces.clear();
+
+ // Detect what data types we will receive
+ if(dev_inst) {
+ assert(dev_inst->dev_inst());
+ for (const GSList *l = dev_inst->dev_inst()->probes;
+ l; l = l->next) {
+ const sr_probe *const probe = (const sr_probe *)l->data;
+ if (!probe->enabled)
+ continue;
+
+ switch(probe->type) {
+ case SR_PROBE_LOGIC:
+ logic_probe_count++;
+ break;
+ }
+ }