Skip to content

Commit 27a86ce

Browse files
committed
type_decoder: update .samplenum before ending .wait() with EOFError
When the protocol decoder's input data is exhausted, then the .wait() method will raise the EOFError exception. Python decoders can catch this exception and handle the condition. For proper annotation emission it is essential that the self.samplenum value corresponds to the last position in the input stream. Update it before returning from the .wait() call.
1 parent 1105c42 commit 27a86ce

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

type_decoder.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,11 @@ static PyObject *Decoder_wait(PyObject *self, PyObject *args)
10981098
* when the sample data is exhausted.
10991099
*/
11001100
if (di->communicate_eof) {
1101+
/* Advance self.samplenum to the (absolute) last sample number. */
1102+
py_samplenum = PyLong_FromUnsignedLongLong(di->abs_cur_samplenum);
1103+
PyObject_SetAttrString(di->py_inst, "samplenum", py_samplenum);
1104+
Py_DECREF(py_samplenum);
1105+
/* Raise an EOFError Python exception. */
11011106
srd_dbg("%s: %s: Raising EOF from wait().",
11021107
di->inst_id, __func__);
11031108
g_mutex_unlock(&di->data_mutex);

0 commit comments

Comments
 (0)