From patchwork Mon Feb 24 20:52:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Baert X-Patchwork-Id: 3711801 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 4A8379F35F for ; Mon, 24 Feb 2014 20:53:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 31B2420149 for ; Mon, 24 Feb 2014 20:53:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C3D5420136 for ; Mon, 24 Feb 2014 20:53:18 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 953C626552D; Mon, 24 Feb 2014 21:53:14 +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,FREEMAIL_FROM, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id AC1532654EB; Mon, 24 Feb 2014 21:53:09 +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 F24A726527F; Mon, 24 Feb 2014 21:53:07 +0100 (CET) Received: from blu0-omc3-s6.blu0.hotmail.com (blu0-omc3-s6.blu0.hotmail.com [65.55.116.81]) by alsa0.perex.cz (Postfix) with ESMTP id B436426527F for ; Mon, 24 Feb 2014 21:53:00 +0100 (CET) Received: from BLU0-SMTP456 ([65.55.116.73]) by blu0-omc3-s6.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 24 Feb 2014 12:52:59 -0800 X-TMN: [pfinHIhOaVa2SjpcqknaoM+60aTNsix2] X-Originating-Email: [maarten-baert@hotmail.com] Message-ID: Received: from [192.168.1.106] ([91.176.253.92]) by BLU0-SMTP456.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 24 Feb 2014 12:52:57 -0800 Date: Mon, 24 Feb 2014 21:52:56 +0100 From: Maarten Baert User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: alsa-devel@alsa-project.org References: In-Reply-To: X-Enigmail-Version: 1.6 X-OriginalArrivalTime: 24 Feb 2014 20:52:57.0586 (UTC) FILETIME=[65968520:01CF31A2] Subject: Re: [alsa-devel] [PATCH] Bugfix: Fix resampling when client and slave both use format float 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP On 24/02/14 14:37, Takashi Iwai wrote: > Looking at the code again, the PCM rate plugin version checks are done > slightly differently from ext-plugin or io-plugin; it's rather done in > the plugin side. pcm_rate.c repeats to trying to hook a plugin until > it matches by degrading the version. In the plugin side, it provides > additional ops depending on the version it's asked. That complicates things a lot. Currently the format conversion is decided before the rate conversion is done. If not all rate conversion plugins support float, then the format conversion plugin needs to know this ahead of time to make the right decision. Or the plugin insertion code needs to be changed so the plugins aren't created in a fixed order. They are currently created back-to-front, it would probably make more sense to choose a rate conversion and channel remapping plugin first, and then insert format conversions where needed. Re-submitting my original patch as requested. Maarten Baert snd_pcm_plug_change_format: Insert linear-to-float conversion when rate or channel count is incorrect. This fixes a bug where snd_pcm_plug_insert_plugins fails when both client and slave use format float, but the rate or channel count does not match. I also removed some redundant code. Signed-off-by: Maarten Baert diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c index fa84eaa..ede9c15 100644 --- a/src/pcm/pcm_plug.c +++ b/src/pcm/pcm_plug.c @@ -522,15 +522,13 @@ static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_p } #ifdef BUILD_PCM_PLUGIN_LFLOAT } else if (snd_pcm_format_float(slv->format)) { - /* Conversion is done in another plugin */ - if (clt->format == slv->format && - clt->rate == slv->rate && - clt->channels == slv->channels) - return 0; - cfmt = clt->format; - if (snd_pcm_format_linear(clt->format)) + if (snd_pcm_format_linear(clt->format)) { + cfmt = clt->format; f = snd_pcm_lfloat_open; - else + } else if (clt->rate != slv->rate || clt->channels != slv->channels) { + cfmt = SND_PCM_FORMAT_S16; + f = snd_pcm_lfloat_open; + } else return -EINVAL; #endif #ifdef BUILD_PCM_NONLINEAR