From patchwork Sun Aug 7 20:28:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maurizio Berti X-Patchwork-Id: 9266569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D0A460754 for ; Sun, 7 Aug 2016 20:29:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 139DF26785 for ; Sun, 7 Aug 2016 20:29:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6BBB26B4A; Sun, 7 Aug 2016 20:29:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E4E926785 for ; Sun, 7 Aug 2016 20:29:44 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2EFBF265E24; Sun, 7 Aug 2016 22:29:43 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id CEA64265D3D; Sun, 7 Aug 2016 22:29:37 +0200 (CEST) X-Original-To: Alsa-devel@alsa-project.org Delivered-To: Alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id CD126265D42; Sun, 7 Aug 2016 22:29:36 +0200 (CEST) Received: from mail-yw0-f194.google.com (mail-yw0-f194.google.com [209.85.161.194]) by alsa0.perex.cz (Postfix) with ESMTP id BC568265919 for ; Sun, 7 Aug 2016 22:29:30 +0200 (CEST) Received: by mail-yw0-f194.google.com with SMTP id z8so23942155ywa.0 for ; Sun, 07 Aug 2016 13:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=5e1ip96MhbKjHGz2WE/o/k/+Q7neLrmz7kPJiP3U+54=; b=fl8DeGNjCouxFr3aET9I2L8VjeDwro2zTNQHbhfJSSTX4YPGDXTsYgarOpjQlsTGhs NsnXqomvySqbbljTYs/+nfqHFI7tJiYvuyBVbHeSvB0KuSZgtQ7e4lbFM6RQron8fydn 84K7/PYir8zlJWecIs5c8YOn0Kd0QziP2CPuQqUNfc53W0J87m2Q5ueLCh/8UlKbdh5f bBWToN8dBSFVw20gq8G/5NCa+FfLLoNqNHmxBx9eWK2I9wiPieQaDKqeZ+GWfolexViN FS8VcT4EZ19JmEic0kqBNq758mrVpzkemqbJd6c8wbHEuX7OtIsyjx+vyBcSjxaWdLIy e+dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=5e1ip96MhbKjHGz2WE/o/k/+Q7neLrmz7kPJiP3U+54=; b=VWdM5vzHn6ix/GE69IQnEncAlC6TlFAgNvw/805Ehcdky8r2dQVsRnNjKfsddUoyAM 79kl15DxIrQkqHPhAS5Aqv3HBlm5lAU5zrI5x1TQxop9t41G6Zzh36glOvvXvq/fBlXK aDopaBCXY3ztJFzFgMjdFkXUdt0YzLWVgjk+ELkBo6MrloRprlEaucHTzlrqYsDj+RXG Kd2ObixW/wFl+mNa2KjQ8DgW5VuOol0V3yIzkh9E+iUV5cVgSpFN4INWCFYAHlHTqFAj PFGZ/no2rWJVOLYP3k8m0FGnrdQLTwghqJywmlg63Etc0qMKeszu5iyZLDmDBx/T3c1Q /gYA== X-Gm-Message-State: AEkoousr1CdgvtFmN7HYrpmi3QWoztPcbMTP85lf/qKDIDJti1AL6QudoFpGAD+433Ir3biEAELaV3AwfvQXgQ== X-Received: by 10.129.61.13 with SMTP id k13mr64725983ywa.56.1470601769347; Sun, 07 Aug 2016 13:29:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.57.73 with HTTP; Sun, 7 Aug 2016 13:28:49 -0700 (PDT) From: Maurizio Berti Date: Sun, 7 Aug 2016 22:28:49 +0200 Message-ID: To: Alsa-devel@alsa-project.org X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Subject: [alsa-devel] [PATCH] alsa-python: alsaseq: added binding for delete_port X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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,