From patchwork Mon Jun 16 15:52:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey X-Patchwork-Id: 4360471 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 4DA5DBEEAA for ; Mon, 16 Jun 2014 15:53:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7AA602020A for ; Mon, 16 Jun 2014 15:53:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A8305201C8 for ; Mon, 16 Jun 2014 15:53:18 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id BB1BF26548F; Mon, 16 Jun 2014 17:53:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,FROM_EXCESS_BASE64,NO_DNS_FOR_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 C2AE3265466; Mon, 16 Jun 2014 17:53:05 +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 847ED265468; Mon, 16 Jun 2014 17:53:04 +0200 (CEST) Received: from f359.i.mail.ru (f359.i.mail.ru [217.69.141.1]) by alsa0.perex.cz (Postfix) with ESMTP id A9135265466 for ; Mon, 16 Jun 2014 17:52:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Content-Transfer-Encoding:Content-Type:Message-ID:Reply-To:Date:Mime-Version:Subject:To:From; bh=Hmau3a+0dP+0MmsRh1pEWfevO0Q883hoGHLTnMOi+mY=; b=WVKxXGbUoQp4VLMfjYu/hZlgcNhHtDpVHzZ+kCsa6+kE/CEOW0CjQKDvSGnNSaOimnPEbCOtknE+oSc/mcmzL3VZ4GxpajK31Xm6MHqD/20SvTqrdimIsiAQps4Qm7kofeQpIjHRDrTpZbqPqv3y9+ADKLy68o3F2ju69sLgWU4=; Received: from mail by f359.i.mail.ru with local (envelope-from ) id 1WwZDH-0003PX-TK for alsa-devel@alsa-project.org; Mon, 16 Jun 2014 19:52:52 +0400 Received: from [85.198.167.125] by e.mail.ru with HTTP; Mon, 16 Jun 2014 19:52:51 +0400 From: =?UTF-8?B?U2VyZ2V5?= To: =?UTF-8?B?YWxzYS1kZXZlbA==?= Mime-Version: 1.0 X-Mailer: Mail.Ru Mailer 1.0 X-Originating-IP: [85.198.167.125] Date: Mon, 16 Jun 2014 19:52:51 +0400 X-Priority: 3 (Normal) Message-ID: <1402933971.835286264@f359.i.mail.ru> X-Mras: Ok X-Spam: undefined Subject: [alsa-devel] =?utf-8?q?alsa-lib=3A_pcm=5Fplug=3A_fix_float_conver?= =?utf-8?q?sion_for_user_specified_ttable?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: =?UTF-8?B?U2VyZ2V5?= 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 Move custom ttable with equal channels case from a separate ttable_last exception into a common plugins insertion loop. Fixes plug with ttable for float pcms (jack, ladspa). Example: aplay -fFLOAT_LE /dev/zero pcm.!default { type plug slave.pcm { type null } ttable.0.0 1 } --- src/pcm/pcm_plug.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c index ede9c15..6d0454f 100644 --- a/src/pcm/pcm_plug.c +++ b/src/pcm/pcm_plug.c @@ -53,7 +53,7 @@ typedef struct { const snd_config_t *rate_converter; enum snd_pcm_plug_route_policy route_policy; snd_pcm_route_ttable_entry_t *ttable; - int ttable_ok, ttable_last; + int ttable_ok; unsigned int tt_ssize, tt_cused, tt_sused; } snd_pcm_plug_t; @@ -380,7 +380,7 @@ static int snd_pcm_plug_change_channels(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm snd_pcm_route_ttable_entry_t *ttable; int err; if (clt->channels == slv->channels && - (!plug->ttable || !plug->ttable_last)) + (!plug->ttable || plug->ttable_ok)) return 0; if (clt->rate != slv->rate && clt->channels > slv->channels) @@ -485,13 +485,15 @@ static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_p /* No conversion is needed */ if (clt->format == slv->format && clt->rate == slv->rate && - clt->channels == slv->channels) + clt->channels == slv->channels && + (!plug->ttable || plug->ttable_ok)) return 0; if (snd_pcm_format_linear(slv->format)) { /* Conversion is done in another plugin */ if (clt->rate != slv->rate || - clt->channels != slv->channels) + clt->channels != slv->channels || + (plug->ttable && !plug->ttable_ok)) return 0; cfmt = clt->format; switch (clt->format) { @@ -525,7 +527,8 @@ static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_p if (snd_pcm_format_linear(clt->format)) { cfmt = clt->format; f = snd_pcm_lfloat_open; - } else if (clt->rate != slv->rate || clt->channels != slv->channels) { + } else if (clt->rate != slv->rate || clt->channels != slv->channels || + (plug->ttable && !plug->ttable_ok)) { cfmt = SND_PCM_FORMAT_S16; f = snd_pcm_lfloat_open; } else @@ -641,11 +644,12 @@ static int snd_pcm_plug_insert_plugins(snd_pcm_t *pcm, }; snd_pcm_plug_params_t p = *slave; unsigned int k = 0; - plug->ttable_ok = plug->ttable_last = 0; + plug->ttable_ok = 0; while (client->format != p.format || client->channels != p.channels || client->rate != p.rate || - client->access != p.access) { + client->access != p.access || + (plug->ttable && !plug->ttable_ok)) { snd_pcm_t *new; int err; if (k >= sizeof(funcs)/sizeof(*funcs)) @@ -660,24 +664,6 @@ static int snd_pcm_plug_insert_plugins(snd_pcm_t *pcm, } k++; } -#ifdef BUILD_PCM_PLUGIN_ROUTE - /* it's exception, user specified ttable, but no reduction/expand */ - if (plug->ttable && !plug->ttable_ok) { - snd_pcm_t *new; - int err; - plug->ttable_last = 1; - err = snd_pcm_plug_change_channels(pcm, &new, client, &p); - if (err < 0) { - snd_pcm_plug_clear(pcm); - return err; - } - assert(err); - assert(plug->ttable_ok); - plug->gen.slave = new; - pcm->fast_ops = new->fast_ops; - pcm->fast_op_arg = new->fast_op_arg; - } -#endif return 0; }