summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan BrĂ¼ns <stefan.bruens@rwth-aachen.de>2015-10-03 16:26:23 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2016-05-11 18:58:46 +0200
commit937e4c51d509c386536141e6cd2d8cd933dcfb4a (patch)
tree692fbef738b54b5dce166a2f36fbe1373e9725e6
parent366580f2617432561b0a93bc32e56f83895a7e48 (diff)
downloadlibsigrokdecode-937e4c51d509c386536141e6cd2d8cd933dcfb4a.tar.gz
libsigrokdecode-937e4c51d509c386536141e6cd2d8cd933dcfb4a.zip
Supply metadata to stacked decoders
Currently only toplevel decoders receive the samplerate, thus stacked decoders are not able to derive e.g. timestamps from the sample number. This fixes bug #664.
-rw-r--r--session.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/session.c b/session.c
index 7673fee..16c8c9e 100644
--- a/session.c
+++ b/session.c
@@ -128,19 +128,27 @@ static int srd_inst_send_meta(struct srd_decoder_inst *di, int key,
GVariant *data)
{
PyObject *py_ret;
+ GSList *l;
+ struct srd_decoder_inst *next_di;
+ int ret;
if (key != SRD_CONF_SAMPLERATE)
/* This is the only key we pass on to the decoder for now. */
return SRD_OK;
- if (!PyObject_HasAttrString(di->py_inst, "metadata"))
- /* This decoder doesn't want metadata, that's fine. */
- return SRD_OK;
+ if (PyObject_HasAttrString(di->py_inst, "metadata")) {
+ py_ret = PyObject_CallMethod(di->py_inst, "metadata", "lK",
+ (long)SRD_CONF_SAMPLERATE,
+ (unsigned long long)g_variant_get_uint64(data));
+ Py_XDECREF(py_ret);
+ }
- py_ret = PyObject_CallMethod(di->py_inst, "metadata", "lK",
- (long)SRD_CONF_SAMPLERATE,
- (unsigned long long)g_variant_get_uint64(data));
- Py_XDECREF(py_ret);
+ /* Push metadata to all the PDs stacked on top of this one. */
+ for (l = di->next_di; l; l = l->next) {
+ next_di = l->data;
+ if ((ret = srd_inst_send_meta(next_di, key, data)) != SRD_OK)
+ return ret;
+ }
return SRD_OK;
}