From patchwork Fri Feb 21 15:24:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Henningsson X-Patchwork-Id: 3697961 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 38C1F9F1EE for ; Fri, 21 Feb 2014 15:25:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 60F89201B6 for ; Fri, 21 Feb 2014 15:25:06 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7705320145 for ; Fri, 21 Feb 2014 15:25:04 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 93C9226593E; Fri, 21 Feb 2014 16:25:03 +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 3F0DB265908; Fri, 21 Feb 2014 16:24:35 +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 E157F26590A; Fri, 21 Feb 2014 16:24:32 +0100 (CET) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by alsa0.perex.cz (Postfix) with ESMTP id B5D682658F4 for ; Fri, 21 Feb 2014 16:24:25 +0100 (CET) Received: from hd9483857.selulk5.dyn.perspektivbredband.net ([217.72.56.87] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1WGrxh-0006aq-Dm; Fri, 21 Feb 2014 15:24:25 +0000 From: David Henningsson To: tiwai@suse.de, alsa-devel@alsa-project.org Date: Fri, 21 Feb 2014 16:24:20 +0100 Message-Id: <1392996262-27970-2-git-send-email-david.henningsson@canonical.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1392996262-27970-1-git-send-email-david.henningsson@canonical.com> References: <1392996262-27970-1-git-send-email-david.henningsson@canonical.com> Cc: David Henningsson Subject: [alsa-devel] [PATCH 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..ffc283f 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 safe_chmapchannel(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 = safe_chmapchannel(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 = safe_chmapchannel(id, &schannel); if (err < 0 || schannel < 0 || (unsigned int) schannel > tt_ssize || (schannels > 0 && schannel >= schannels)) {