*
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
-int srd_instance_decode(uint64_t timeoffset, uint64_t duration,
+int srd_instance_decode(uint64_t start_samplenum,
struct srd_decoder_instance *di, uint8_t *inbuf, uint64_t inbuflen)
{
PyObject *py_instance, *py_res;
srd_logic *logic;
+ uint64_t end_samplenum;
/* Return an error upon unusable input. */
if (di == NULL)
logic = PyObject_New(srd_logic, &srd_logic_type);
Py_INCREF(logic);
logic->di = di;
+ logic->start_samplenum = start_samplenum;
logic->itercnt = 0;
logic->inbuf = inbuf;
logic->inbuflen = inbuflen;
logic->sample = PyList_New(2);
Py_INCREF(logic->sample);
+ end_samplenum = start_samplenum + inbuflen / di->unitsize;
if (!(py_res = PyObject_CallMethod(py_instance, "decode",
- "KKO", timeoffset, duration, logic))) {
+ "KKO", logic->start_samplenum, end_samplenum, logic))) {
if (PyErr_Occurred())
PyErr_Print(); /* Returns void. */
}
/* Feed logic samples to decoder session. */
-int srd_session_feed(uint64_t timeoffset, uint64_t duration, uint8_t *inbuf,
- uint64_t inbuflen)
+int srd_session_feed(uint64_t start_samplenum, uint8_t *inbuf, uint64_t inbuflen)
{
GSList *d;
int ret;
for (d = di_list; d; d = d->next) {
- if ((ret = srd_instance_decode(timeoffset, duration, d->data, inbuf,
+ if ((ret = srd_instance_decode(start_samplenum, d->data, inbuf,
inbuflen)) != SRD_OK)
return ret;
}
typedef struct {
PyObject_HEAD
struct srd_decoder_instance *di;
+ uint64_t start_samplenum;
unsigned int itercnt;
uint8_t *inbuf;
uint64_t inbuflen;
const char *probename, int num);
struct srd_decoder_instance *srd_instance_find(char *instance_id);
int srd_instance_start(struct srd_decoder_instance *di, PyObject *args);
-int srd_instance_decode(uint64_t timeoffset, uint64_t duration,
+int srd_instance_decode(uint64_t start_samplenum,
struct srd_decoder_instance *dec, uint8_t *inbuf, uint64_t inbuflen);
int srd_session_start(int num_probes, int unitsize, uint64_t samplerate);
-int srd_session_feed(uint64_t timeoffset, uint64_t duration, uint8_t *inbuf,
- uint64_t inbuflen);
-int pd_add(struct srd_decoder_instance *di, int output_type,
- char *output_id);
+int srd_session_feed(uint64_t start_samplenum, uint8_t *inbuf, uint64_t inbuflen);
+int pd_add(struct srd_decoder_instance *di, int output_type, char *output_id);
struct srd_decoder_instance *get_di_by_decobject(void *decobject);
int srd_register_callback(int output_type, void *cb);
void *srd_find_callback(int output_type);
static PyMethodDef Decoder_methods[] = {
{"put", Decoder_put, METH_VARARGS,
- "Accepts a dictionary with the following keys: time, duration, data"},
+ "Accepts a dictionary with the following keys: startsample, endsample, data"},
{"add", Decoder_add, METH_VARARGS, "Create a new output stream"},
{NULL, NULL, 0, NULL}
};
sample >>= 1;
}
- /* TODO: samplenum should be in the inbuf feed, instead of time/duration.
- * fake it for now...
- */
/* Prepare the next samplenum/sample list in this iteration. */
- py_samplenum = PyLong_FromUnsignedLongLong(logic->itercnt++);
+ py_samplenum = PyLong_FromUnsignedLongLong(logic->start_samplenum + logic->itercnt);
PyList_SetItem(logic->sample, 0, py_samplenum);
py_samples = PyBytes_FromStringAndSize((const char *)probe_samples,
logic->di->num_probes);
PyList_SetItem(logic->sample, 1, py_samples);
Py_INCREF(logic->sample);
+ logic->itercnt++;
return logic->sample;
}