From patchwork Fri Aug 8 21:31:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: branan@gmail.com X-Patchwork-Id: 4699971 X-Patchwork-Delegate: tiwai@suse.de 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 9F46C9F373 for ; Fri, 8 Aug 2014 21:31:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D146D20154 for ; Fri, 8 Aug 2014 21:31:38 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1B78B20138 for ; Fri, 8 Aug 2014 21:31:36 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2A8C126530F; Fri, 8 Aug 2014 23:31:34 +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, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id DCC56265327; Fri, 8 Aug 2014 23:31: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 1F28C26557E; Fri, 8 Aug 2014 23:31:22 +0200 (CEST) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by alsa0.perex.cz (Postfix) with ESMTP id AE8F2265571; Fri, 8 Aug 2014 23:31:13 +0200 (CEST) Received: by mail-pa0-f43.google.com with SMTP id lf10so7947732pab.30 for ; Fri, 08 Aug 2014 14:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=6FilWm3V6+lwWlv01ATLBoG1Qlaaiw5806NJzq6CgoM=; b=ydVQytSS2mC3/XLdJ5I/pENn/jxI4+fOYJpfLtvS9erNdnbOAsbx9rSsYALu9vaUtN wSvk/cBUIq/OO7Xo8EauKk9GGyTdTdIKMsWDtbjTsK1mlqejS2MVoTtXV/n2yDnaO7jE wryXAT12pK2gNvG5RfAOPqLMKAzPFwne8bodjw5M0/3MOuzco5HPVrvkiWuxLefn7LmZ iMvZWdYt0JJZVe95wulRN0Abe8E24Yqx9KQfjCGuii7D/FT4PVkQ1X2PnZ80YRIX+WJ7 7rE2GcmtThh5gqvMA07MwYVFSt9y06yI3X7VHP2/ssw82H/RmSzrhRh6SS6h2d3sRIWM WTrQ== X-Received: by 10.70.100.34 with SMTP id ev2mr26513206pdb.81.1407533472089; Fri, 08 Aug 2014 14:31:12 -0700 (PDT) Received: from branan-thinkpad.corp.puppetlabs.net ([74.85.255.11]) by mx.google.com with ESMTPSA id bl12sm29129438pac.44.2014.08.08.14.31.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Aug 2014 14:31:11 -0700 (PDT) From: branan@gmail.com To: patch@alsa-project.org Date: Fri, 8 Aug 2014 14:31:06 -0700 Message-Id: <1407533466-26581-1-git-send-email-branan@gmail.com> X-Mailer: git-send-email 2.0.4 Cc: alsa-devel@alsa-project.org, Branan Purvine-Riley Subject: [alsa-devel] [PATCH - pcm_jack plugin 1/1] Restore PID to jack client name when not specified explicitly 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 From: Branan Purvine-Riley Commit 14190cd8 added a facility to explicitly name Jack clients with a 'name' option, but did so in a way that was not fully backwards-compatible with older versions of the alsa-plugins. There were two issues: 1. Re-using the magical "name" variable, which comes preloaded with the name of the PCM 2. The code assumed snd_config_get_string sets a variable to NULL if the config entry does not exist. Instead, this function leaves the variable unchanged. The result of these two errors meant that the PCM name would be treated as if it were a user-defined name, and the old code which embedded the PID would never be run This code uses a completely new variable to store the explicitly-set client name, so that the two code paths no longer collide. Signed-off-by: Branan Purvine-Riley diff --git a/jack/pcm_jack.c b/jack/pcm_jack.c index f5b7129..33f87b1 100644 --- a/jack/pcm_jack.c +++ b/jack/pcm_jack.c @@ -372,6 +372,7 @@ static int make_nonblock(int fd) } static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name, + const char* client_name, snd_config_t *playback_conf, snd_config_t *capture_conf, snd_pcm_stream_t stream, int mode) @@ -405,14 +406,14 @@ static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name, return -EINVAL; } - if (name == NULL) + if (client_name == NULL) err = snprintf(jack_client_name, sizeof(jack_client_name), "alsa-jack.%s%s.%d.%d", name, stream == SND_PCM_STREAM_PLAYBACK ? "P" : "C", getpid(), num++); else err = snprintf(jack_client_name, sizeof(jack_client_name), - "%s", name); + "%s", client_name); if (err >= (int)sizeof(jack_client_name)) { fprintf(stderr, "%s: WARNING: JACK client name '%s' truncated to %d characters, might not be unique\n", @@ -470,6 +471,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack) snd_config_iterator_t i, next; snd_config_t *playback_conf = NULL; snd_config_t *capture_conf = NULL; + const char* client_name = NULL; int err; snd_config_for_each(i, next, conf) { @@ -480,7 +482,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack) if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0 || strcmp(id, "hint") == 0) continue; if (strcmp(id, "name") == 0) { - snd_config_get_string(n, &name); + snd_config_get_string(n, &client_name); continue; } if (strcmp(id, "playback_ports") == 0) { @@ -503,7 +505,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack) return -EINVAL; } - err = snd_pcm_jack_open(pcmp, name, playback_conf, capture_conf, stream, mode); + err = snd_pcm_jack_open(pcmp, name, client_name, playback_conf, capture_conf, stream, mode); return err; }