summaryrefslogtreecommitdiff
path: root/libsigrokdecode.h.in
diff options
context:
space:
mode:
authorBert Vermeulen <bert@biot.com>2013-09-12 23:54:43 +0200
committerBert Vermeulen <bert@biot.com>2013-10-14 10:43:16 +0200
commit32cfb920625182c03eb4a4564ffdfa9d2b08f15c (patch)
tree925fd9152e284d4afcfb473247667149c2aaf1e6 /libsigrokdecode.h.in
parent1f2e00d140ac41a3a61888f67fc6f96c4369bea3 (diff)
downloadlibsigrokdecode-32cfb920625182c03eb4a4564ffdfa9d2b08f15c.tar.gz
libsigrokdecode-32cfb920625182c03eb4a4564ffdfa9d2b08f15c.zip
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.
Diffstat (limited to 'libsigrokdecode.h.in')
-rw-r--r--libsigrokdecode.h.in34
1 files changed, 24 insertions, 10 deletions
diff --git a/libsigrokdecode.h.in b/libsigrokdecode.h.in
index 97ffa1d..c61a0e4 100644
--- a/libsigrokdecode.h.in
+++ b/libsigrokdecode.h.in
@@ -30,6 +30,8 @@
extern "C" {
#endif
+struct srd_session;
+
/**
* @file
*
@@ -164,6 +166,12 @@ enum {
#define SRD_MAX_NUM_PROBES 64
+enum {
+ SRD_CONF_NUM_PROBES = 10000,
+ SRD_CONF_UNITSIZE,
+ SRD_CONF_SAMPLERATE,
+};
+
struct srd_decoder {
/** The decoder ID. Must be non-NULL and unique for all decoders. */
char *id;
@@ -228,6 +236,7 @@ struct srd_decoder_option {
struct srd_decoder_inst {
struct srd_decoder *decoder;
+ struct srd_session *sess;
PyObject *py_inst;
char *inst_id;
GSList *pd_output;
@@ -287,16 +296,21 @@ SRD_API int srd_inst_option_set(struct srd_decoder_inst *di,
GHashTable *options);
SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di,
GHashTable *probes);
-SRD_API struct srd_decoder_inst *srd_inst_new(const char *id,
- GHashTable *options);
-SRD_API int srd_inst_stack(struct srd_decoder_inst *di_from,
- struct srd_decoder_inst *di_to);
-SRD_API struct srd_decoder_inst *srd_inst_find_by_id(const char *inst_id);
-SRD_API int srd_session_start(int num_probes, int unitsize, uint64_t samplerate);
-SRD_API int srd_session_send(uint64_t start_samplenum, const uint8_t *inbuf,
- uint64_t inbuflen);
-SRD_API int srd_pd_output_callback_add(int output_type,
- srd_pd_output_callback_t cb, void *cb_data);
+SRD_API struct srd_decoder_inst *srd_inst_new(struct srd_session *sess,
+ const char *id, GHashTable *options);
+SRD_API int srd_inst_stack(struct srd_session *sess,
+ struct srd_decoder_inst *di_from, struct srd_decoder_inst *di_to);
+SRD_API struct srd_decoder_inst *srd_inst_find_by_id(struct srd_session *sess,
+ const char *inst_id);
+SRD_API int srd_session_new(struct srd_session **sess);
+SRD_API int srd_session_start(struct srd_session *sess);
+SRD_API int srd_session_config_set(struct srd_session *sess, int key,
+ GVariant *data);
+SRD_API int srd_session_send(struct srd_session *sess,
+ uint64_t start_samplenum, const uint8_t *inbuf, uint64_t inbuflen);
+SRD_API int srd_session_destroy(struct srd_session *sess);
+SRD_API int srd_pd_output_callback_add(struct srd_session *sess,
+ int output_type, srd_pd_output_callback_t cb, void *cb_data);
/*--- decoder.c -------------------------------------------------------------*/