]> sigrok.org Git - libsigrokdecode.git/blobdiff - type_decoder.c
nit: break a long line in different ways, unobfuscate parameter grouping
[libsigrokdecode.git] / type_decoder.c
index 6c6eab6b22f584cbcbb0324431cd53e7a0e988fd..5a1e1a81c512625365d10ef98cb5b02e6df41e37 100644 (file)
@@ -482,9 +482,9 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args)
                                 start_sample,
                                 end_sample, output_type_name(pdo->output_type),
                                 output_id, pdo->proto_id, next_di->inst_id);
-                       if (!(py_res = PyObject_CallMethod(
-                               next_di->py_inst, "decode", "KKO", start_sample,
-                               end_sample, py_data))) {
+                       py_res = PyObject_CallMethod(next_di->py_inst, "decode",
+                               "KKO", start_sample, end_sample, py_data);
+                       if (!py_res) {
                                srd_exception_catch("Calling %s decode() failed",
                                                        next_di->inst_id);
                        }
@@ -1098,6 +1098,11 @@ static PyObject *Decoder_wait(PyObject *self, PyObject *args)
                 * when the sample data is exhausted.
                 */
                if (di->communicate_eof) {
+                       /* Advance self.samplenum to the (absolute) last sample number. */
+                       py_samplenum = PyLong_FromUnsignedLongLong(di->abs_cur_samplenum);
+                       PyObject_SetAttrString(di->py_inst, "samplenum", py_samplenum);
+                       Py_DECREF(py_samplenum);
+                       /* Raise an EOFError Python exception. */
                        srd_dbg("%s: %s: Raising EOF from wait().",
                                di->inst_id, __func__);
                        g_mutex_unlock(&di->data_mutex);