fix return value of PCM.write() on success (#137)

the `else` branch of the return value handling cascade got lost in
commit 438e52e, leading to us returning None on success.

rather than restoring the old code exactly, delay the construction
of the final return code object. this is more consistent with
alsapcm_read() and overall nicer.
This commit is contained in:
Oswald Buddenhagen
2024-02-02 13:22:17 +01:00
committed by Lars Immisch
parent 061c297f4b
commit 691c1d9b23

View File

@@ -1436,7 +1436,6 @@ static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args)
{
int datalen;
char *data;
PyObject *rc = NULL;
#if PY_MAJOR_VERSION < 3
if (!PyArg_ParseTuple(args,"s#:write", &data, &datalen))
@@ -1493,7 +1492,7 @@ static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args)
}
if (res == -EAGAIN) {
rc = PyLong_FromLong(0);
res = 0;
}
else if (res < 0)
{
@@ -1511,7 +1510,7 @@ static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args)
PyBuffer_Release(&buf);
#endif
return rc;
return PyLong_FromLong(res);
}
static PyObject *