From patchwork Fri Apr 1 17:33:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Goode X-Patchwork-Id: 8730721 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5B536C0553 for ; Sat, 2 Apr 2016 06:54:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 824132038A for ; Sat, 2 Apr 2016 06:54:47 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 54DCD20384 for ; Sat, 2 Apr 2016 06:54:46 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1AD46266AF8; Sat, 2 Apr 2016 08:54:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 37C6E265146; Sat, 2 Apr 2016 08:53:23 +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 2F59E26512A; Fri, 1 Apr 2016 19:34:38 +0200 (CEST) Received: from mail-yw0-f178.google.com (mail-yw0-f178.google.com [209.85.161.178]) by alsa0.perex.cz (Postfix) with ESMTP id 1409B261A0A for ; Fri, 1 Apr 2016 19:34:31 +0200 (CEST) Received: by mail-yw0-f178.google.com with SMTP id h65so176018000ywe.0 for ; Fri, 01 Apr 2016 10:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=tvh7opCxUiYbbCfPYoVcrh1f8WBdnT/06jVRQtmovkI=; b=VQiWVGYsw9V7BwqxrDwBSsQj0Ewy8/2txdk2Q2D7SAJoiGRMaH6z1TiuUGWltcol8P nbwJ+0BZzW27m/fgkz15AE6Imeqqccg2NhJRMlRvhC8iETm4xIxW2Jhaqm020XrdM9/F /J+SfgMwaDNY+JnmFHQtomdMHW6qQ2bC6RhLrltPUk8PLaHMZjFnb+HOyF39HNwi75aP YAXYfxs3bryIYDxxRHc+1rdklbPw6iyOCwGBIVP1unKp0EfxbJ06TYgWaaRI+9UG1U+b xBDKXUrb/ba2eTPuKJpdDKAZr6Ktp+knEvP0S0blE2+Z8wA2rGSEAZrZ0eLTNEp3xawC BmmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tvh7opCxUiYbbCfPYoVcrh1f8WBdnT/06jVRQtmovkI=; b=Q4xpD1WDmwthaNaz4Vj+q8j+GxHas0Cz+JkN2742Vg6URlwpXAvSgqWSo4aI4pGaYt F3N76dSfnMq3RjdhQ3zRlIy6otJLFlnklvtxCGKMugL1YgMCCKYFqygr6/+ApPqum04v +7jCCtouxdkg8rncp4TANSL+PagkNCUTE2L+65/1swrcAD8q0+PAP4VmlI87el5j7qpy kkf5mpQ1l16WveFw6hgo4CwCofiCp51IW8CbSucOQnip+SLQICu8q/aMMGJGkYhsbgqU W0KqRzR3lQcZKg89GMpzUUXt9dT9544pw753T1dKJho96+eAgfKkZ7V71bgfIeggBg4X H/wQ== X-Gm-Message-State: AD7BkJJNqoAg5Po1IWrDOXWzXIdiFJy1961poXP8FqPrIcfDv0xdBi7GzYCgfiUSBSvUlMnv X-Received: by 10.129.131.139 with SMTP id t133mr5303466ywf.328.1459532069878; Fri, 01 Apr 2016 10:34:29 -0700 (PDT) Received: from wpg-ubiq154.hot.corp.google.com ([172.24.166.195]) by smtp.gmail.com with ESMTPSA id i202sm7977645ywc.13.2016.04.01.10.34.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Apr 2016 10:34:29 -0700 (PDT) From: Adam Goode To: patch@alsa-project.org Date: Fri, 1 Apr 2016 13:33:50 -0400 Message-Id: <1459532030-6387-1-git-send-email-agoode@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 X-Mailman-Approved-At: Sat, 02 Apr 2016 08:53:20 +0200 Cc: Adam Goode , alsa-devel@alsa-project.org, martin.koegler@chello.at Subject: [alsa-devel] [PATCH - alsa-lib 1/1] Change card/pid get functions to return -ENOSYS if the kernel is too old 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP When trying to get the pid or card of a client, the get functions will return -1 if there is no pid or card for a client. Clients have zero or one of these, so -1 is correct for these cases. But we also need to detect the case where the kernel cannot tell us if there is a card or pid, so that userspace can fallback to probing this information in the old way. Signed-off-by: Adam Goode diff --git a/src/seq/seq.c b/src/seq/seq.c index 4405e68..7de1e81 100644 --- a/src/seq/seq.c +++ b/src/seq/seq.c @@ -1522,9 +1522,10 @@ int snd_seq_client_info_get_error_bounce(const snd_seq_client_info_t *info) } /** - * \brief Get the sound card number. + * \brief Get the sound card number if the kernel supports this. * \param info client_info container - * \return card number or -1 if value is not available. + * \return card number, -1 if there is no card for this client, + * or \c -ENOSYS if the kernel does not have support for this operation * * Only available for SND_SEQ_KERNEL_CLIENT clients. */ @@ -1535,9 +1536,10 @@ int snd_seq_client_info_get_card(const snd_seq_client_info_t *info) } /** - * \brief Get the owning PID. + * \brief Get the owning PID if the kernel supports this. * \param info client_info container - * \return pid or -1 if value is not available. + * \return pid, -1 if there is no PID for this client, + * or \c -ENOSYS if the kernel does not have support for this operation * * Only available for SND_SEQ_USER_CLIENT clients. */ diff --git a/src/seq/seq_hw.c b/src/seq/seq_hw.c index 578ef12..a1d1e4a 100644 --- a/src/seq/seq_hw.c +++ b/src/seq/seq_hw.c @@ -102,8 +102,8 @@ static int snd_seq_hw_get_client_info(snd_seq_t *seq, snd_seq_client_info_t * in return -errno; } if (hw->version < SNDRV_PROTOCOL_VERSION(1, 0, 2)) { - info->card = -1; - info->pid = -1; + info->card = -ENOSYS; + info->pid = -ENOSYS; } return 0; } @@ -374,8 +374,8 @@ static int snd_seq_hw_query_next_client(snd_seq_t *seq, snd_seq_client_info_t *i return -errno; } if (hw->version < SNDRV_PROTOCOL_VERSION(1, 0, 2)) { - info->card = -1; - info->pid = -1; + info->card = -ENOSYS; + info->pid = -ENOSYS; } return 0; }