* [PATCH] alsa-python: add register_poll to alsaseq
@ 2010-05-12 1:51 Hector Martin
2010-05-27 8:20 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: Hector Martin @ 2010-05-12 1:51 UTC (permalink / raw)
To: alsa-devel; +Cc: Clemens Ladisch
[-- Attachment #1: Type: text/plain, Size: 290 bytes --]
Attached patch adds register_poll to the sequencer bindings to support
nonblocking sequencer access with the select module.
I sent this last month but it looks like it was overlooked. Resending.
--
Hector Martin (hector@marcansoft.com)
Public Key: http://www.marcansoft.com/marcan.asc
[-- Attachment #2: 0001-Add-register_poll-for-alsaseq.patch --]
[-- Type: text/plain, Size: 2359 bytes --]
>From f801ff2f940b24c3ee3f27271ec4b249a2c67fb8 Mon Sep 17 00:00:00 2001
From: Hector Martin <hector@marcansoft.com>
Date: Wed, 21 Apr 2010 05:54:49 +0200
Subject: [PATCH] Add register_poll for alsaseq
Signed-off-by: Hector Martin <hector@marcansoft.com>
---
pyalsa/alsaseq.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
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}
};
--
1.6.4.4
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] alsa-python: add register_poll to alsaseq
2010-05-12 1:51 [PATCH] alsa-python: add register_poll to alsaseq Hector Martin
@ 2010-05-27 8:20 ` Takashi Iwai
0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2010-05-27 8:20 UTC (permalink / raw)
To: Hector Martin; +Cc: alsa-devel, Clemens Ladisch
At Wed, 12 May 2010 03:51:34 +0200,
Hector Martin wrote:
>
> Attached patch adds register_poll to the sequencer bindings to support
> nonblocking sequencer access with the select module.
>
> I sent this last month but it looks like it was overlooked. Resending.
Thanks, applied now.
Takashi
>
> --
> Hector Martin (hector@marcansoft.com)
> Public Key: http://www.marcansoft.com/marcan.asc
>
>
> [2 0001-Add-register_poll-for-alsaseq.patch <text/plain (7bit)>]
> >From f801ff2f940b24c3ee3f27271ec4b249a2c67fb8 Mon Sep 17 00:00:00 2001
> From: Hector Martin <hector@marcansoft.com>
> Date: Wed, 21 Apr 2010 05:54:49 +0200
> Subject: [PATCH] Add register_poll for alsaseq
>
> Signed-off-by: Hector Martin <hector@marcansoft.com>
> ---
> pyalsa/alsaseq.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 51 insertions(+), 0 deletions(-)
>
> 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}
> };
>
> --
> 1.6.4.4
>
> [3 <text/plain; us-ascii (7bit)>]
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] alsa-python: add register_poll to alsaseq
@ 2010-04-21 4:00 Hector Martin
2010-04-21 6:52 ` Clemens Ladisch
0 siblings, 1 reply; 5+ messages in thread
From: Hector Martin @ 2010-04-21 4:00 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 217 bytes --]
Attached patch adds register_poll to the sequencer bindings to support
nonblocking sequencer access with the select module.
--
Hector Martin (hector@marcansoft.com)
Public Key: http://www.marcansoft.com/marcan.asc
[-- Attachment #2: 0001-Add-register_poll-for-alsaseq.patch --]
[-- Type: text/plain, Size: 2355 bytes --]
>From db1a07ad9e9076f258d1ff871955eedc7d34ae9c Mon Sep 17 00:00:00 2001
From: Hector Martin <hector@marcansoft.com>
Date: Wed, 21 Apr 2010 05:54:49 +0200
Subject: [PATCH] Add register_poll for alsaseq
---
pyalsa/alsaseq.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/pyalsa/alsaseq.c b/pyalsa/alsaseq.c
index de131a4..fbab6da 100644
--- a/pyalsa/alsaseq.c
+++ b/pyalsa/alsaseq.c
@@ -3236,6 +3236,55 @@ 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 = malloc(sizeof(struct pollfd) * count);
+ if (pfd == NULL)
+ Py_RETURN_NONE;
+ 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 +3358,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}
};
--
1.6.4.4
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] alsa-python: add register_poll to alsaseq
2010-04-21 4:00 Hector Martin
@ 2010-04-21 6:52 ` Clemens Ladisch
2010-04-21 14:05 ` Hector Martin
0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2010-04-21 6:52 UTC (permalink / raw)
To: Hector Martin; +Cc: alsa-devel
Hector Martin wrote:
> Attached patch adds register_poll to the sequencer bindings to support
> nonblocking sequencer access with the select module.
>
> From db1a07ad9e9076f258d1ff871955eedc7d34ae9c Mon Sep 17 00:00:00 2001
> From: Hector Martin <hector@marcansoft.com>
> Date: Wed, 21 Apr 2010 05:54:49 +0200
> Subject: [PATCH] Add register_poll for alsaseq
>
> ---
> pyalsa/alsaseq.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 53 insertions(+), 0 deletions(-)
Please provide a Signed-off-by tag; we use this also for non-kernel code.
> + pfd = malloc(sizeof(struct pollfd) * count);
This isn't freed; better use alloca().
Regards,
Clemens
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] alsa-python: add register_poll to alsaseq
2010-04-21 6:52 ` Clemens Ladisch
@ 2010-04-21 14:05 ` Hector Martin
0 siblings, 0 replies; 5+ messages in thread
From: Hector Martin @ 2010-04-21 14:05 UTC (permalink / raw)
To: Clemens Ladisch; +Cc: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 404 bytes --]
On 04/21/2010 08:52 AM, Clemens Ladisch wrote:
> Please provide a Signed-off-by tag; we use this also for non-kernel code.
Done.
> This isn't freed; better use alloca().
Whoops. I see this got fixed on hcontrol with 866af7359. I based my
patch on 1.0.21's hcontrol so I missed that fix.
New patch attached.
--
Hector Martin (hector@marcansoft.com)
Public Key: http://www.marcansoft.com/marcan.asc
[-- Attachment #2: 0001-Add-register_poll-for-alsaseq.patch --]
[-- Type: text/plain, Size: 2359 bytes --]
>From f801ff2f940b24c3ee3f27271ec4b249a2c67fb8 Mon Sep 17 00:00:00 2001
From: Hector Martin <hector@marcansoft.com>
Date: Wed, 21 Apr 2010 05:54:49 +0200
Subject: [PATCH] Add register_poll for alsaseq
Signed-off-by: Hector Martin <hector@marcansoft.com>
---
pyalsa/alsaseq.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
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}
};
--
1.6.4.4
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-05-27 8:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-12 1:51 [PATCH] alsa-python: add register_poll to alsaseq Hector Martin
2010-05-27 8:20 ` Takashi Iwai
-- strict thread matches above, loose matches on Subject: below --
2010-04-21 4:00 Hector Martin
2010-04-21 6:52 ` Clemens Ladisch
2010-04-21 14:05 ` Hector Martin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.