]> sigrok.org Git - libsigrokdecode.git/commitdiff
srd: Every callback should have a 'void *' parameter.
authorUwe Hermann <redacted>
Sat, 11 Feb 2012 21:38:17 +0000 (22:38 +0100)
committerUwe Hermann <redacted>
Sat, 11 Feb 2012 21:41:33 +0000 (22:41 +0100)
This is required in various situations and for various lib users,
especially so GUIs which might want to pass specific info via this
mechanism.

controller.c
sigrokdecode.h

index d4637f3e040a2f5d1fe856afee5426079a665df4..6e6e4356c21365c6eea1c7eae8fb8335537b999e 100644 (file)
@@ -692,7 +692,8 @@ SRD_API int srd_session_feed(uint64_t start_samplenum, uint8_t * inbuf,
        return SRD_OK;
 }
 
-SRD_API int srd_register_callback(int output_type, srd_pd_output_callback_t cb)
+SRD_API int srd_register_callback(int output_type,
+                                 srd_pd_output_callback_t cb, void *data)
 {
        struct srd_pd_callback *pd_cb;
 
@@ -705,6 +706,7 @@ SRD_API int srd_register_callback(int output_type, srd_pd_output_callback_t cb)
 
        pd_cb->output_type = output_type;
        pd_cb->callback = cb;
+       pd_cb->data = data;
        callbacks = g_slist_append(callbacks, pd_cb);
 
        return SRD_OK;
index 4768b4c7a7e445730f0fa83dad4fd308846e4345..18ab5135efd4390198cab0789b3b73c2493eabdc 100644 (file)
@@ -173,9 +173,13 @@ struct srd_proto_data {
        void *data;
 };
 
+typedef void (*srd_pd_output_callback_t)(struct srd_proto_data *pdata,
+                                        void *data);
+
 struct srd_pd_callback {
        int output_type;
-       void (*callback)(struct srd_proto_data *);
+       srd_pd_output_callback_t callback;
+       void *data;
 };
 
 /* custom python types */
@@ -220,8 +224,8 @@ SRD_API int srd_session_start(int num_probes, int unitsize,
 SRD_API int srd_session_feed(uint64_t start_samplenum, uint8_t *inbuf,
                             uint64_t inbuflen);
 SRD_API struct srd_decoder_inst *get_di_by_decobject(void *decobject);
-typedef void (*srd_pd_output_callback_t)(struct srd_proto_data *pdata);
-SRD_API int srd_register_callback(int output_type, srd_pd_output_callback_t cb);
+SRD_API int srd_register_callback(int output_type,
+                                 srd_pd_output_callback_t cb, void *data);
 SRD_API void *srd_find_callback(int output_type);
 
 /*--- decoder.c -------------------------------------------------------------*/