Use frontend-registered callback with correct parameters
authorBert Vermeulen <bert@biot.com>
Sun, 1 Sep 2013 16:20:36 +0000 (18:20 +0200)
committerBert Vermeulen <bert@biot.com>
Sun, 1 Sep 2013 16:20:36 +0000 (18:20 +0200)
controller.c
libsigrokdecode-internal.h
type_decoder.c

index 7987ea172b8d2270d9fc221246b57e84ab71f0fc..9267ded40e653a14423c9446b23f8994e5366542 100644 (file)
@@ -965,22 +965,21 @@ SRD_API int srd_pd_output_callback_add(int output_type,
 }
 
 /** @private */
-SRD_PRIV void *srd_pd_output_callback_find(int output_type)
+SRD_PRIV struct srd_pd_callback *srd_pd_output_callback_find(int output_type)
 {
        GSList *l;
-       struct srd_pd_callback *pd_cb;
-       void *(cb);
+       struct srd_pd_callback *tmp, *pd_cb;
 
-       cb = NULL;
+       pd_cb = NULL;
        for (l = callbacks; l; l = l->next) {
-               pd_cb = l->data;
-               if (pd_cb->output_type == output_type) {
-                       cb = pd_cb->cb;
+               tmp = l->data;
+               if (tmp->output_type == output_type) {
+                       pd_cb = tmp;
                        break;
                }
        }
 
-       return cb;
+       return pd_cb;
 }
 
 /* This is the backend function to Python sigrokdecode.add() call. */
index 10b7fa7a01b8af629ac1243950cfe027d50d4dea..600b9fd1e186f76b31212b28802add2a50c0313e 100644 (file)
@@ -35,7 +35,7 @@ SRD_PRIV int srd_inst_decode(uint64_t start_samplenum,
                             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 void *srd_pd_output_callback_find(int output_type);
+SRD_PRIV struct srd_pd_callback *srd_pd_output_callback_find(int output_type);
 SRD_PRIV int srd_inst_pd_output_add(struct srd_decoder_inst *di,
                                    int output_type, const char *output_id);
 
index 16675bcb9f0a136560d15c1cb70ddba91a5e3daf..3f4bae9d774742f791f3ec6d27b81041408ac59d 100644 (file)
@@ -95,7 +95,7 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args)
        struct srd_proto_data *pdata;
        uint64_t start_sample, end_sample;
        int output_id;
-       void (*cb)();
+       struct srd_pd_callback *cb;
 
        if (!(di = srd_inst_find_by_obj(NULL, self))) {
                /* Shouldn't happen. */
@@ -142,7 +142,7 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args)
                                /* An error was already logged. */
                                break;
                        }
-                       cb(pdata);
+                       cb->cb(pdata, cb->cb_data);
                }
                break;
        case SRD_OUTPUT_PROTO: