From 7b56229d3b025e3c417d762607c8599034481a39 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Thu, 23 Jan 2014 22:22:28 -0300 Subject: [PATCH] python/ext/py-{sink,source}.c: add close function --- python/ext/py-sink.c | 9 +++++++++ python/ext/py-source.c | 13 ++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/python/ext/py-sink.c b/python/ext/py-sink.c index 59a2cc18..5636f4a8 100644 --- a/python/ext/py-sink.c +++ b/python/ext/py-sink.c @@ -89,8 +89,17 @@ AUBIO_MEMBERS_START(sink) {"samplerate", T_INT, offsetof (Py_sink, samplerate), READONLY, ""}, AUBIO_MEMBERS_STOP(sink) +static PyObject * +Pyaubio_sink_close (Py_sink *self, PyObject *unused) +{ + del_aubio_sink (self->o); + self->o = NULL; + Py_RETURN_NONE; +} static PyMethodDef Py_sink_methods[] = { + {"close", (PyCFunction) Pyaubio_sink_close, + METH_NOARGS, ""}, {NULL} /* sentinel */ }; diff --git a/python/ext/py-source.c b/python/ext/py-source.c index 82cab06d..c45ada83 100644 --- a/python/ext/py-source.c +++ b/python/ext/py-source.c @@ -1,6 +1,3 @@ -// WARNING: this file is generated, DO NOT EDIT - -// WARNING: if you haven't read the first line yet, please do so #include "aubiowraphell.h" typedef struct @@ -126,11 +123,21 @@ Pyaubio_source_get_channels (Py_source *self, PyObject *unused) return (PyObject *)PyInt_FromLong (tmp); } +static PyObject * +Pyaubio_source_close (Py_source *self, PyObject *unused) +{ + del_aubio_source (self->o); + self->o = NULL; + Py_RETURN_NONE; +} + static PyMethodDef Py_source_methods[] = { {"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate, METH_NOARGS, ""}, {"get_channels", (PyCFunction) Pyaubio_source_get_channels, METH_NOARGS, ""}, + {"close", (PyCFunction) Pyaubio_source_close, + METH_NOARGS, ""}, {NULL} /* sentinel */ }; -- 2.11.0