History

python/ext/py-source.c: add seek, thanks @davebrent for the heads up

Paul Brossier committed 12 years ago

Commit 11b49d71 parent 24931d52 files · +46 −6Browse files

Showing the changes to python/ext/py-source.c (1 of 2 files). Show all

Unified · Split

python/ext/py-source.c+26−0
@@ -69,6 +69,11 @@ static char Py_source_close_doc[] = "" · 68 unmodified lines
6969 "\n"
7070 "Close this source now.";
7171
72+static char Py_source_seek_doc[] = ""
73+"x.seek(position)\n"
74+"\n"
75+"Seek to resampled frame position.";
76+
7277 static PyObject *
7378 Py_source_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
7479 {
@@ -238,6 +243,25 @@ Pyaubio_source_close (Py_source *self, PyObject *unused) · 163 unmodified lines
238243 Py_RETURN_NONE;
239244 }
240245
246+static PyObject *
247+Pyaubio_source_seek (Py_source *self, PyObject *args)
248+{
249+ uint_t err = 0;
250+
251+ uint_t position;
252+ if (!PyArg_ParseTuple (args, "I", &position)) {
253+ return NULL;
254+ }
255+
256+ err = aubio_source_seek(self->o, position);
257+ if (err != 0) {
258+ PyErr_SetString (PyExc_ValueError,
259+ "error when seeking in source");
260+ return NULL;
261+ }
262+ Py_RETURN_NONE;
263+}
264+
241265 static PyMethodDef Py_source_methods[] = {
242266 {"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate,
243267 METH_NOARGS, Py_source_get_samplerate_doc},
@@ -249,6 +273,8 @@ static PyMethodDef Py_source_methods[] = { · 5 unmodified lines
249273 METH_NOARGS, Py_source_do_multi_doc},
250274 {"close", (PyCFunction) Pyaubio_source_close,
251275 METH_NOARGS, Py_source_close_doc},
276+ {"seek", (PyCFunction) Pyaubio_source_seek,
277+ METH_VARARGS, Py_source_seek_doc},
252278 {NULL} /* sentinel */
253279 };
254280

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t