[alsa-devel] [PATCH] alsa-python: alsaseq: added binding for delete_port
Maurizio Berti
maurizio.berti at gmail.com
Sun Aug 7 22:28:49 CEST 2016
Hello,
I was going to send this patch via git, but I've troubles setting it up
against gmail, then I hope I'm not doing something wrong by posting this
directly here.
I found out that pyalsa doesn't provide delete_port, then I added it;
please, note, I'm not a programmer, I just do this for fun and I actually
have no experience in C programming: I just understand (most of) it by
reading the code, so I just used some knowledge and logic to add this
binding. So far, it looks fine to me and works without any problem.
Signed-off-by: MaurizioB <maurizio.berti at gmail.com>
diff --git a/pyalsa/alsaseq.c b/pyalsa/alsaseq.c
index ce332ed..2ad4d55 100644
--- a/pyalsa/alsaseq.c
+++ b/pyalsa/alsaseq.c
@@ -2343,6 +2343,44 @@ Sequencer_create_simple_port(SequencerObject *self,
return PyInt_FromLong(port);
}
+
+/** alsaseq.Sequencer delete_port() method: __doc__ */
+PyDoc_STRVAR(Sequencer_delete_port__doc__,
+ "delete_port(port_id) -> int"
+ "\n"
+ "Delete an existing port.\n"
+ "\n"
+ "Parameters:\n"
+ " port_id -- id of the port\n"
+ "Raises:\n"
+ " SequencerError: if ALSA can't delete the port"
+);
+
+
+/** alsaseq.Sequencer delete_port() method */
+static PyObject *
+Sequencer_delete_port(SequencerObject *self,
+ PyObject *args,
+ PyObject *kwds) {
+ int port_id = 0;
+ int ret;
+ char *kwlist[] = { "port_id", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist,
+ &port_id)) {
+ return NULL;
+ }
+
+ ret = snd_seq_delete_port(self->handle, port_id);
+ if (ret < 0) {
+ RAISESND(ret, "Failed to delete port");
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+
/** alsaseq.Sequencer connection_list() method: __doc__ */
PyDoc_STRVAR(Sequencer_connection_list__doc__,
"connection_list() -> list\n"
@@ -3248,6 +3286,10 @@ static PyMethodDef Sequencer_methods[] = {
(PyCFunction) Sequencer_create_simple_port,
METH_VARARGS | METH_KEYWORDS,
Sequencer_create_simple_port__doc__ },
+ {"delete_port",
+ (PyCFunction) Sequencer_delete_port,
+ METH_VARARGS | METH_KEYWORDS,
+ Sequencer_delete_port__doc__ },
{"connection_list",
(PyCFunction) Sequencer_connection_list,
METH_VARARGS,
--
2.4.10
--
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net
More information about the Alsa-devel
mailing list