From: Joel Holdsworth Date: Sun, 13 Oct 2013 13:56:19 +0000 (+0100) Subject: Modified Decoder to support srd_sessions X-Git-Tag: pulseview-0.2.0~252 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=9d20a7415bfe41d8985fb026ef0ba164de08c313;p=pulseview.git Modified Decoder to support srd_sessions --- diff --git a/pv/data/decoder.cpp b/pv/data/decoder.cpp index 2cfb3a99..5907f649 100644 --- a/pv/data/decoder.cpp +++ b/pv/data/decoder.cpp @@ -46,6 +46,7 @@ Decoder::Decoder(const srd_decoder *const dec, _decoder(dec), _probes(probes), _options(options), + _session(NULL), _decoder_inst(NULL) { init_decoder(); @@ -115,7 +116,10 @@ void Decoder::init_decoder() } } - _decoder_inst = srd_inst_new(_decoder->id, _options); + srd_session_new(&_session); + assert(_session); + + _decoder_inst = srd_inst_new(_session, _decoder->id, _options); if(!_decoder_inst) { qDebug() << "Failed to initialise decoder"; return; @@ -162,9 +166,16 @@ void Decoder::decode_proc(shared_ptr data) if (samplerate == 0.0) samplerate = 1.0; - srd_session_start(_probes.size(), snapshot->unit_size(), samplerate); + srd_session_config_set(_session, SRD_CONF_NUM_PROBES, + g_variant_new_uint64(_probes.size())); + srd_session_config_set(_session, SRD_CONF_UNITSIZE, + g_variant_new_uint64(snapshot->unit_size())); + srd_session_config_set(_session, SRD_CONF_SAMPLERATE, + g_variant_new_uint64((uint64_t)samplerate)); + + srd_session_start(_session); - srd_pd_output_callback_add(SRD_OUTPUT_ANN, + srd_pd_output_callback_add(_session, SRD_OUTPUT_ANN, Decoder::annotation_callback, this); for (int64_t i = 0; @@ -175,7 +186,8 @@ void Decoder::decode_proc(shared_ptr data) i + DecodeChunkLength, sample_count); snapshot->get_samples(chunk, i, chunk_end); - if (srd_session_send(i, chunk, chunk_end - i) != SRD_OK) + if (srd_session_send(_session, i, chunk, chunk_end - i) != + SRD_OK) break; } } diff --git a/pv/data/decoder.h b/pv/data/decoder.h index c881403b..5a4b4a99 100644 --- a/pv/data/decoder.h +++ b/pv/data/decoder.h @@ -33,6 +33,7 @@ struct srd_decoder; struct srd_decoder_inst; struct srd_probe; +struct srd_session; namespace pv { @@ -92,6 +93,7 @@ private: _probes; GHashTable *_options; + srd_session *_session; srd_decoder_inst *_decoder_inst; mutable boost::mutex _annotations_mutex;