[alsa-cvslog] alsa-python: Official ALSA python binding branch, master now at v1.0.22-1-gcf1395d
Brought to you by:
perex
From: <nor...@al...> - 2010-05-27 08:20:16
|
Hello, This is an automated email from the git hooks/update script, it was generated because a ref change was pushed to the repository. Updating branch, master, via cf1395da1fe8734ae4a33bca970547a176a1e2fd (commit) from 86cde07b10a07290981145181f78eeb269ed5730 (commit) - Log ----------------------------------------------------------------- commit cf1395da1fe8734ae4a33bca970547a176a1e2fd Author: Hector Martin <he...@ma...> AuthorDate: Wed Apr 21 05:54:49 2010 +0200 Commit: Takashi Iwai <ti...@su...> CommitDate: Thu May 27 10:19:27 2010 +0200 Add register_poll for alsaseq Signed-off-by: Hector Martin <he...@ma...> Signed-off-by: Takashi Iwai <ti...@su...> ----------------------------------------------------------------------- Diffstat: pyalsa/alsaseq.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) Patch -------------- (max 1500 lines) diff --git a/pyalsa/alsaseq.c b/pyalsa/alsaseq.c index de131a4..bbf6b2e 100644 --- a/pyalsa/alsaseq.c +++ b/pyalsa/alsaseq.c @@ -3236,6 +3236,53 @@ Sequencer_stop_queue(SequencerObject *self, Py_RETURN_NONE; } +PyDoc_STRVAR(Sequencer_registerpoll__doc__, +"register_poll(pollObj, input=False, output=False) -- Register poll file descriptors."); + +static PyObject * +Sequencer_registerpoll(SequencerObject *self, PyObject *args, PyObject *kwds) +{ + PyObject *pollObj, *reg, *t; + struct pollfd *pfd; + int i, count; + int input = 0; + int output = 0; + int mode = POLLIN|POLLOUT; + + static char * kwlist[] = { "pollObj", "input", "output", NULL }; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|ii", kwlist, &pollObj, &input, &output)) + return NULL; + + if (input && !output) + mode = POLLIN; + else if (!input && output) + mode = POLLOUT; + + count = snd_seq_poll_descriptors_count(self->handle, mode); + if (count <= 0) + Py_RETURN_NONE; + pfd = alloca(sizeof(struct pollfd) * count); + count = snd_seq_poll_descriptors(self->handle, pfd, count, mode); + if (count <= 0) + Py_RETURN_NONE; + + reg = PyObject_GetAttr(pollObj, PyString_InternFromString("register")); + + for (i = 0; i < count; i++) { + t = PyTuple_New(2); + if (t) { + PyTuple_SET_ITEM(t, 0, PyInt_FromLong(pfd[i].fd)); + PyTuple_SET_ITEM(t, 1, PyInt_FromLong(pfd[i].events)); + Py_XDECREF(PyObject_CallObject(reg, t)); + Py_DECREF(t); + } + } + + Py_XDECREF(reg); + + Py_RETURN_NONE; +} @@ -3309,6 +3356,10 @@ static PyMethodDef Sequencer_methods[] = { (PyCFunction) Sequencer_stop_queue, METH_VARARGS | METH_KEYWORDS, Sequencer_stop_queue__doc__}, + {"register_poll", + (PyCFunction) Sequencer_registerpoll, + METH_VARARGS | METH_KEYWORDS, + Sequencer_registerpoll__doc__}, {NULL} }; ------- End of patch hooks/update --- Git Source Code Management System hooks/update refs/heads/master \ 86cde07b10a07290981145181f78eeb269ed5730 \ cf1395da1fe8734ae4a33bca970547a176a1e2fd |