X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=session.c;h=e1bb4f9880d36a8f64f8603827a7df8585d088bc;hb=6aa03e3aeb9054122e52016c3344927d5c0f02de;hp=7673feefbc2de8667aed7c8b080cc4e18dd0a71c;hpb=367843620d039ad183bc4d7c33d91c316d717621;p=libsigrokdecode.git diff --git a/session.c b/session.c index 7673fee..e1bb4f9 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; } @@ -216,12 +224,12 @@ SRD_API int srd_session_metadata_set(struct srd_session *sess, int key, * has been configured, it is the minimum number of bytes needed to store * the default channels. * - * @param sess The session to use. + * @param sess The session to use. Must not be NULL. * @param start_samplenum The sample number of the first sample in this chunk. * @param end_samplenum The sample number of the last sample in this chunk. - * @param inbuf Pointer to sample data. - * @param inbuflen Length in bytes of the buffer. - * @param unitsize The number of bytes per sample. + * @param inbuf Pointer to sample data. Must not be NULL. + * @param inbuflen Length in bytes of the buffer. Must be > 0. + * @param unitsize The number of bytes per sample. Must be > 0. * * @return SRD_OK upon success, a (negative) error code otherwise. *