From 32cfb920625182c03eb4a4564ffdfa9d2b08f15c Mon Sep 17 00:00:00 2001 From: Bert Vermeulen Date: Thu, 12 Sep 2013 23:54:43 +0200 Subject: Move all decoder instances and callbacks into a session struct The struct srd_session also holds configuration parameters formerly passed to srd_session_start(). The new call srd_session_new() takes a pointer where a newly allocated pointer to struct srd_session will be stored. This pointer must be passed as the first argument to all functions that require it. The SRD_CONF_NUM_PROBES, SRD_CONF_UNITSIZE and SRD_CONF_SAMPLERATE keys must be configured with srd_config_set() before srd_session_start() is called. A new call srd_session_destroy() is also available. This cleans up all resources the session holds. This is also called from srd_exit() for all sessions. --- libsigrokdecode-internal.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'libsigrokdecode-internal.h') diff --git a/libsigrokdecode-internal.h b/libsigrokdecode-internal.h index 600b9fd..2951fa3 100644 --- a/libsigrokdecode-internal.h +++ b/libsigrokdecode-internal.h @@ -24,18 +24,32 @@ #include "libsigrokdecode.h" +struct srd_session { + int session_id; + uint64_t num_probes; + uint64_t unitsize; + uint64_t samplerate; + + /* List of decoder instances. */ + GSList *di_list; + + /* List of frontend callbacks to receive decoder output. */ + GSList *callbacks; +}; + /*--- controller.c ----------------------------------------------------------*/ SRD_PRIV int srd_decoder_searchpath_add(const char *path); -SRD_PRIV struct srd_decoder_inst *srd_inst_find_by_obj(const GSList *stack, - const PyObject *obj); +SRD_PRIV struct srd_decoder_inst *srd_inst_find_by_obj( const GSList *stack, + const PyObject *obj); SRD_PRIV int srd_inst_start(struct srd_decoder_inst *di, PyObject *args); SRD_PRIV int srd_inst_decode(uint64_t start_samplenum, const struct srd_decoder_inst *dec, const uint8_t *inbuf, uint64_t inbuflen); SRD_PRIV void srd_inst_free(struct srd_decoder_inst *di); -SRD_PRIV void srd_inst_free_all(GSList *stack); -SRD_PRIV struct srd_pd_callback *srd_pd_output_callback_find(int output_type); +SRD_PRIV void srd_inst_free_all(struct srd_session *sess, GSList *stack); +SRD_PRIV struct srd_pd_callback *srd_pd_output_callback_find(struct srd_session *sess, + int output_type); SRD_PRIV int srd_inst_pd_output_add(struct srd_decoder_inst *di, int output_type, const char *output_id); -- cgit v1.2.3-70-g09d2