#include <boost/thread/thread.hpp>
+#include <stdexcept>
+
#include <QDebug>
#include "decoder.h"
_session(NULL),
_decoder_inst(NULL)
{
- init_decoder();
+ if (!init_decoder())
+ throw runtime_error("Failed to initialise decoder.");
+
begin_decode();
}
{
}
-void Decoder::init_decoder()
+bool Decoder::init_decoder()
{
if (!_probes.empty())
{
_decoder_inst = srd_inst_new(_session, _decoder->id, _options);
if(!_decoder_inst) {
qDebug() << "Failed to initialise decoder";
- return;
+ return false;
}
_decoder_inst->data_samplerate = _samplerate;
}
srd_inst_probe_set_all(_decoder_inst, probes);
+
+ return true;
}
void Decoder::decode_proc(shared_ptr<data::Logic> data)
private:
void begin_decode();
- void init_decoder();
+ bool init_decoder();
void decode_proc(boost::shared_ptr<data::Logic> data);
#include <assert.h>
+#include <stdexcept>
+
#include <sys/stat.h>
#include <QDebug>
return _logic_data;
}
-void SigSession::add_decoder(srd_decoder *const dec,
+bool SigSession::add_decoder(srd_decoder *const dec,
std::map<const srd_probe*,
boost::shared_ptr<view::Signal> > probes,
GHashTable *options)
{
+ try
{
lock_guard<mutex> lock(_signals_mutex);
_decode_traces.size()));
_decode_traces.push_back(d);
}
+ catch(std::runtime_error e)
+ {
+ return false;
+ }
+
signals_changed();
+
+ return true;
}
vector< shared_ptr<view::DecodeSignal> > SigSession::get_decode_signals() const
boost::shared_ptr<data::Logic> get_data();
- void add_decoder(srd_decoder *const dec,
+ bool add_decoder(srd_decoder *const dec,
std::map<const srd_probe*,
boost::shared_ptr<view::Signal> > probes,
GHashTable *options);