From patchwork Fri Feb 28 07:57:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Henningsson X-Patchwork-Id: 3739371 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 282E3BF13A for ; Fri, 28 Feb 2014 08:08:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 501CD20260 for ; Fri, 28 Feb 2014 08:08:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 26B6220259 for ; Fri, 28 Feb 2014 08:08:19 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 395DC2659C8; Fri, 28 Feb 2014 09:08:18 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 5754A2650D3; Fri, 28 Feb 2014 09:03:55 +0100 (CET) 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 4BD192650AE; Fri, 28 Feb 2014 09:03:53 +0100 (CET) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by alsa0.perex.cz (Postfix) with ESMTP id F1884265481 for ; Fri, 28 Feb 2014 08:57:08 +0100 (CET) Received: from hd9483857.selulk5.dyn.perspektivbredband.net ([217.72.56.87] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1WJIJg-0000bT-Ld; Fri, 28 Feb 2014 07:57:08 +0000 From: David Henningsson To: tiwai@suse.de, alsa-devel@alsa-project.org Date: Fri, 28 Feb 2014 08:57:05 +0100 Message-Id: <1393574227-25732-2-git-send-email-david.henningsson@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1393574227-25732-1-git-send-email-david.henningsson@canonical.com> References: <1393574227-25732-1-git-send-email-david.henningsson@canonical.com> Cc: David Henningsson Subject: [alsa-devel] [PATCH v2 1/3] route: Allow chmap syntax for slave channels in ttable 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 Instead of writing e g "0" and "1", one can now write "FL" and "FR" instead. E g: ttable.0.FL 1 ttable.1.FR 1 ttable.2.LFE 1 Signed-off-by: David Henningsson --- src/pcm/pcm_route.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 2beedf6..56318d4 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -789,6 +789,24 @@ static void snd_pcm_route_dump(snd_pcm_t *pcm, snd_output_t *out) snd_pcm_dump(route->plug.gen.slave, out); } +static int strtochannel(const char *id, long *channel) +{ + int err; + int ch; + err = safe_strtol(id, channel); + if (err >= 0) + return err; + + ch = (int) snd_pcm_chmap_from_string(id); + if (ch == -1) + return -EINVAL; + + /* For now, assume standard channel mapping */ + *channel = ch - SND_CHMAP_FL; + return 0; +} + + static const snd_pcm_ops_t snd_pcm_route_ops = { .close = snd_pcm_route_close, .info = snd_pcm_generic_info, @@ -983,7 +1001,7 @@ int snd_pcm_route_determine_ttable(snd_config_t *tt, const char *id; if (snd_config_get_id(jnode, &id) < 0) continue; - err = safe_strtol(id, &schannel); + err = strtochannel(id, &schannel); if (err < 0) { SNDERR("Invalid slave channel: %s", id); return -EINVAL; @@ -1046,7 +1064,7 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt const char *id; if (snd_config_get_id(jnode, &id) < 0) continue; - err = safe_strtol(id, &schannel); + err = strtochannel(id, &schannel); if (err < 0 || schannel < 0 || (unsigned int) schannel > tt_ssize || (schannels > 0 && schannel >= schannels)) {