python/ext/py-{sink,source}.c: add close function
authorPaul Brossier <piem@piem.org>
Fri, 24 Jan 2014 01:22:28 +0000 (22:22 -0300)
committerPaul Brossier <piem@piem.org>
Fri, 24 Jan 2014 01:22:28 +0000 (22:22 -0300)
python/ext/py-sink.c
python/ext/py-source.c

index 59a2cc1..5636f4a 100644 (file)
@@ -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 */
 };
 
index 82cab06..c45ada8 100644 (file)
@@ -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 */
 };