diff options
Diffstat (limited to 'controller.c')
-rw-r--r-- | controller.c | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/controller.c b/controller.c index c265ae7..5d19e7a 100644 --- a/controller.c +++ b/controller.c @@ -330,9 +330,9 @@ static gint compare_probe_id(const struct srd_probe *a, const char *probe_id) * it overwrites any probes that were already defined (if any). * * @param di Decoder instance. - * @param new_probes A GHashTable of probes to set. Key is probe name, value is - * the probe number. Samples passed to this instance will be - * arranged in this order. + * @param probes A GHashTable of probes to set. Key is probe name, value is + * the probe number. Samples passed to this instance will be + * arranged in this order. * * @return SRD_OK upon success, a (negative) error code otherwise. */ @@ -344,7 +344,6 @@ SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di, struct srd_probe *p; int *new_probemap, new_probenum; char *probe_id, *probenum_str; - int i, num_required_probes; srd_dbg("set probes called for instance %s with list of %d probes", di->inst_id, g_hash_table_size(new_probes)); @@ -367,13 +366,6 @@ SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di, return SRD_ERR_MALLOC; } - /* - * For now, map all indexes to probe -1 (can be overridden later). - * This -1 is interpreted as an unspecified probe later. - */ - for (i = 0; i < di->dec_num_probes; i++) - new_probemap[i] = -1; - for (l = g_hash_table_get_keys(new_probes); l; l = l->next) { probe_id = l->data; probenum_str = g_hash_table_lookup(new_probes, probe_id); @@ -398,17 +390,9 @@ SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di, } p = sl->data; new_probemap[p->order] = new_probenum; - srd_dbg("Setting probe mapping: %s (index %d) = probe %d.", - p->id, p->order, new_probenum); - } - - srd_dbg("Final probe map:"); - num_required_probes = g_slist_length(di->decoder->probes); - for (i = 0; i < di->dec_num_probes; i++) { - srd_dbg(" - index %d = probe %d (%s)", i, new_probemap[i], - (i < num_required_probes) ? "required" : "optional"); + srd_dbg("setting probe mapping for %d = probe %d", p->order, + new_probenum); } - g_free(di->dec_probemap); di->dec_probemap = new_probemap; @@ -418,9 +402,9 @@ SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di, /** * Create a new protocol decoder instance. * - * @param decoder_id Decoder 'id' field. + * @param id Decoder 'id' field. * @param options GHashtable of options which override the defaults set in - * the decoder class. May be NULL. + * the decoder class. * * @return Pointer to a newly allocated struct srd_decoder_inst, or * NULL in case of failure. @@ -445,13 +429,10 @@ SRD_API struct srd_decoder_inst *srd_inst_new(const char *decoder_id, return NULL; } + inst_id = g_hash_table_lookup(options, "id"); di->decoder = dec; - if (options) { - inst_id = g_hash_table_lookup(options, "id"); - di->inst_id = g_strdup(inst_id ? inst_id : decoder_id); - g_hash_table_remove(options, "id"); - } else - di->inst_id = g_strdup(decoder_id); + di->inst_id = g_strdup(inst_id ? inst_id : decoder_id); + g_hash_table_remove(options, "id"); /* * Prepare a default probe map, where samples come in the @@ -480,7 +461,7 @@ SRD_API struct srd_decoder_inst *srd_inst_new(const char *decoder_id, return NULL; } - if (options && srd_inst_option_set(di, options) != SRD_OK) { + if (srd_inst_option_set(di, options) != SRD_OK) { g_free(di->dec_probemap); g_free(di); return NULL; @@ -736,8 +717,6 @@ SRD_API int srd_session_start(int num_probes, int unitsize, uint64_t samplerate) struct srd_decoder_inst *di; int ret; - ret = SRD_OK; - srd_dbg("Calling start() on all instances with %d probes, " "unitsize %d samplerate %d.", num_probes, unitsize, samplerate); @@ -756,7 +735,7 @@ SRD_API int srd_session_start(int num_probes, int unitsize, uint64_t samplerate) di->data_num_probes = num_probes; di->data_unitsize = unitsize; di->data_samplerate = samplerate; - if ((ret = srd_inst_start(di, args)) != SRD_OK) + if ((ret = srd_inst_start(di, args) != SRD_OK)) break; } @@ -770,7 +749,7 @@ SRD_API int srd_session_start(int num_probes, int unitsize, uint64_t samplerate) * * @param start_samplenum The sample number of the first sample in this chunk. * @param inbuf Pointer to sample data. - * @param inbuflen Length in bytes of the buffer. + * @param inbuf Length in bytes of the buffer. * * @return SRD_OK upon success, a (negative) error code otherwise. */ |