]> sigrok.org Git - pulseview.git/blobdiff - pv/data/decoder.cpp
Print an error message, rather than asserting if the srd_inst_new fails
[pulseview.git] / pv / data / decoder.cpp
index 2848d16ca4dffd166697b2517193acaec7030592..2cfb3a99a9b289f49103718a7169301d66ceb198 100644 (file)
@@ -41,9 +41,11 @@ const int64_t Decoder::DecodeChunkLength = 4096;
 
 Decoder::Decoder(const srd_decoder *const dec,
        std::map<const srd_probe*,
-               boost::shared_ptr<pv::view::Signal> > probes) :
+               boost::shared_ptr<pv::view::Signal> > probes,
+       GHashTable *options) :
        _decoder(dec),
        _probes(probes),
+       _options(options),
        _decoder_inst(NULL)
 {
        init_decoder();
@@ -54,6 +56,8 @@ Decoder::~Decoder()
 {
        _decode_thread.interrupt();
        _decode_thread.join();
+
+       g_hash_table_destroy(_options);
 }
 
 const srd_decoder* Decoder::get_decoder() const
@@ -111,8 +115,11 @@ void Decoder::init_decoder()
                }
        }
 
-       _decoder_inst = srd_inst_new(_decoder->id, NULL);
-       assert(_decoder_inst);
+       _decoder_inst = srd_inst_new(_decoder->id, _options);
+       if(!_decoder_inst) {
+               qDebug() << "Failed to initialise decoder";
+               return;
+       }
 
        _decoder_inst->data_samplerate = _samplerate;
 
@@ -185,6 +192,8 @@ void Decoder::annotation_callback(srd_proto_data *pdata, void *decoder)
        shared_ptr<Annotation> a(new Annotation(pdata));
        lock_guard<mutex> lock(d->_annotations_mutex);
        d->_annotations.push_back(a);
+
+       d->new_decode_data();
 }
 
 } // namespace data