- g_slist_free(di_list);
- di_list = NULL;
- }
-}
-
-SRD_API int srd_session_start(int num_probes, int unitsize, uint64_t samplerate)
-{
- PyObject *args;
- GSList *d;
- struct srd_decoder_inst *di;
- int ret;
-
- srd_dbg("Calling start() on all instances with %d probes, "
- "unitsize %d samplerate %d.", num_probes, unitsize, samplerate);
-
- /* Currently only one item of metadata is passed along to decoders,
- * samplerate. This can be extended as needed.
- */
- if (!(args = Py_BuildValue("{s:l}", "samplerate", (long)samplerate))) {
- srd_err("Unable to build Python object for metadata.");
- return SRD_ERR_PYTHON;
- }
-
- /* Run the start() method on all decoders receiving frontend data. */
- for (d = di_list; d; d = d->next) {
- di = d->data;
- di->data_num_probes = num_probes;
- di->data_unitsize = unitsize;
- di->data_samplerate = samplerate;
- if ((ret = srd_inst_start(di, args) != SRD_OK))
- break;
- }
-
- Py_DecRef(args);
-
- return ret;
-}
-
-/* Feed logic samples to decoder session. */
-SRD_API int srd_session_feed(uint64_t start_samplenum, uint8_t * inbuf,
- uint64_t inbuflen)
-{
- GSList *d;
- int ret;
-
- srd_dbg("Calling decode() on all instances with starting sample "
- "number %" PRIu64 ", %" PRIu64 " bytes at 0x%p",
- start_samplenum, inbuflen, inbuf);
-
- for (d = di_list; d; d = d->next) {
- if ((ret = srd_inst_decode(start_samplenum, d->data, inbuf,
- inbuflen)) != SRD_OK)
- return ret;
- }
-
- return SRD_OK;
-}
-
-SRD_API int srd_register_callback(int output_type, srd_pd_output_callback_t cb)
-{
- struct srd_pd_callback *pd_cb;
-
- srd_dbg("Registering new callback for output type %d.", output_type);
-
- if (!(pd_cb = g_try_malloc(sizeof(struct srd_pd_callback)))) {
- srd_err("Failed to g_malloc() struct srd_pd_callback.");
- return SRD_ERR_MALLOC;
- }
-
- pd_cb->output_type = output_type;
- pd_cb->callback = cb;
- callbacks = g_slist_append(callbacks, pd_cb);
-
- return SRD_OK;
-}
-
-SRD_API void *srd_find_callback(int output_type)
-{
- GSList *l;
- struct srd_pd_callback *pd_cb;
- void *(cb);
-
- cb = NULL;
- for (l = callbacks; l; l = l->next) {
- pd_cb = l->data;
- if (pd_cb->output_type == output_type) {
- cb = pd_cb->callback;
- break;
- }