X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=instance.c;h=e80afd751469b7fb6d81acac51cdff3591131019;hb=f98f41714fc5c7516f614e0d453f6226533d981d;hp=a1de9574520d7511211520938c81d73b33dc0df3;hpb=e27d3e67cb69d54936399cd97a4c40c9842549a7;p=libsigrokdecode.git diff --git a/instance.c b/instance.c index a1de957..e80afd7 100644 --- a/instance.c +++ b/instance.c @@ -948,28 +948,28 @@ static gpointer di_thread(gpointer data) * sample numbers within the chunk specified by 'inbuf' and 'inbuflen'. * * Correct example (4096 samples total, 4 chunks @ 1024 samples each): - * srd_inst_decode(di, 0, 1023, inbuf, 1024, 1); - * srd_inst_decode(di, 1024, 2047, inbuf, 1024, 1); - * srd_inst_decode(di, 2048, 3071, inbuf, 1024, 1); - * srd_inst_decode(di, 3072, 4095, inbuf, 1024, 1); + * srd_inst_decode(di, 0, 1024, inbuf, 1024, 1); + * srd_inst_decode(di, 1024, 2048, inbuf, 1024, 1); + * srd_inst_decode(di, 2048, 3072, inbuf, 1024, 1); + * srd_inst_decode(di, 3072, 4096, inbuf, 1024, 1); * * The chunk size ('inbuflen') can be arbitrary and can differ between calls. * * Correct example (4096 samples total, 7 chunks @ various samples each): - * srd_inst_decode(di, 0, 1023, inbuf, 1024, 1); - * srd_inst_decode(di, 1024, 1123, inbuf, 100, 1); - * srd_inst_decode(di, 1124, 1423, inbuf, 300, 1); - * srd_inst_decode(di, 1424, 1642, inbuf, 219, 1); - * srd_inst_decode(di, 1643, 2047, inbuf, 405, 1); - * srd_inst_decode(di, 2048, 3071, inbuf, 1024, 1); - * srd_inst_decode(di, 3072, 4095, inbuf, 1024, 1); + * srd_inst_decode(di, 0, 1024, inbuf, 1024, 1); + * srd_inst_decode(di, 1024, 1124, inbuf, 100, 1); + * srd_inst_decode(di, 1124, 1424, inbuf, 300, 1); + * srd_inst_decode(di, 1424, 1643, inbuf, 219, 1); + * srd_inst_decode(di, 1643, 2048, inbuf, 405, 1); + * srd_inst_decode(di, 2048, 3072, inbuf, 1024, 1); + * srd_inst_decode(di, 3072, 4096, inbuf, 1024, 1); * * INCORRECT example (4096 samples total, 4 chunks @ 1024 samples each, but * the start- and end-samplenumbers are not absolute): - * srd_inst_decode(di, 0, 1023, inbuf, 1024, 1); - * srd_inst_decode(di, 0, 1023, inbuf, 1024, 1); - * srd_inst_decode(di, 0, 1023, inbuf, 1024, 1); - * srd_inst_decode(di, 0, 1023, inbuf, 1024, 1); + * srd_inst_decode(di, 0, 1024, inbuf, 1024, 1); + * srd_inst_decode(di, 0, 1024, inbuf, 1024, 1); + * srd_inst_decode(di, 0, 1024, inbuf, 1024, 1); + * srd_inst_decode(di, 0, 1024, inbuf, 1024, 1); * * @param di The decoder instance to call. Must not be NULL. * @param abs_start_samplenum The absolute starting sample number for the @@ -1010,6 +1010,14 @@ SRD_PRIV int srd_inst_decode(struct srd_decoder_inst *di, return SRD_ERR_ARG; } + if (abs_start_samplenum != di->abs_cur_samplenum || + abs_end_samplenum < abs_start_samplenum) { + srd_dbg("Incorrect sample numbers: start=%" PRIu64 ", cur=%" + PRIu64 ", end=%" PRIu64 ".", abs_start_samplenum, + di->abs_cur_samplenum, abs_end_samplenum); + return SRD_ERR_ARG; + } + di->data_unitsize = unitsize; srd_dbg("Decoding: abs start sample %" PRIu64 ", abs end sample %" @@ -1042,6 +1050,7 @@ SRD_PRIV int srd_inst_decode(struct srd_decoder_inst *di, di->inst_id); return SRD_ERR_PYTHON; } + di->abs_cur_samplenum = abs_end_samplenum; Py_DecRef(py_res); } else { /* If this is the first call, start the worker thread. */