From patchwork Wed Feb 8 10:50:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Young X-Patchwork-Id: 9562189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3989860434 for ; Wed, 8 Feb 2017 10:50:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B5202849C for ; Wed, 8 Feb 2017 10:50:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2044B284D0; Wed, 8 Feb 2017 10:50:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 489302849C for ; Wed, 8 Feb 2017 10:50:50 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 27A5526714C; Wed, 8 Feb 2017 11:50:49 +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 09F8C267153; Wed, 8 Feb 2017 11:50:47 +0100 (CET) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by alsa0.perex.cz (Postfix) with ESMTP id 5C11426684C for ; Wed, 8 Feb 2017 11:50:46 +0100 (CET) Received: by mail-wm0-f45.google.com with SMTP id r141so182118029wmg.1 for ; Wed, 08 Feb 2017 02:50:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to; bh=iEE7l4IDlwub4l6/ZSZjC/n6QReoKI2Z7m6mkfiFfCc=; b=fatCiQZAurzCIOVtKlSNG8IzG1k9nYdCkGqED83HYqJi/PGG23+W1iYXCLSglRjaU2 f4kHSi+tcQP0m7YKZiea3fT2h8lYFV7p0ue3RI30zc1DQ2f13HGug4BUlqR0STZuPANu vr+9R0ApiJcg4z98Yrf/IG3fV4XKtN8R50sBXvuS1MfRh9YYKSOG6dujjMRWVV5cUO/b FwGwrog5Z+jhz0dASUNpbmbmHaFoOwBJglDM7iJuCOhwtLAzha8cDP2lm5as7HX8VADz 6Xs+oca5cbsswpmQuxFJAuVkvFgN0aWav41xs+EVjSmSK82VoBdnsWMgS7APHx4OKwcA KN5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to; bh=iEE7l4IDlwub4l6/ZSZjC/n6QReoKI2Z7m6mkfiFfCc=; b=Omiomz000/+g72kXTLpFxM9xQtJyUPOEWxUWVhitZ0odO5CpU0JwIO5WrvxLQvGS+l n3gVim2WVJGhcGzuEL9Cgi/DBJmUZAh5Cjd7mfyxvtqoLqWcut6rPTSh69c3rlGUlkKG Kai67T5CYxPCPBye2RmLyAPgHg4sb8a0xR+g8Ntu3vH9F9gcp1DIt8iMqk+h37/xpTyb pvEw0bVi/P18IQ7702VfHvDniSkBApJgUTkBiduD7FRwbBkFed1mTEzYk6FyLCmYTs5y QjUkrYhFwpYmQCQW56ULI9wQ9p0hPwmuyBw8mw9U8iHZRSdCCJYMHB34cjO8djgXNKG7 Vorg== X-Gm-Message-State: AMke39nmB1snc7VrPP7CYV3Ml2Jmmps1HdVaCdWBobbBP4E47NqbxpOFO93XE9KCxvB7Xw== X-Received: by 10.28.6.210 with SMTP id 201mr18527360wmg.85.1486551045819; Wed, 08 Feb 2017 02:50:45 -0800 (PST) Received: from [192.168.11.11] (225.55.208.46.dyn.plus.net. [46.208.55.225]) by smtp.googlemail.com with ESMTPSA id r6sm2685965wmd.4.2017.02.08.02.50.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Feb 2017 02:50:44 -0800 (PST) From: Alan Young To: alsa-devel@alsa-project.org References: Message-ID: <6d7c74b7-da90-5ae9-c355-c6884b2edf09@gmail.com> Date: Wed, 8 Feb 2017 10:50:44 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Takashi Iwai Subject: [alsa-devel] [PATCH] pcm: rate: Add capability to pass configuration node to plugins 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 It is useful for the converter used by a rate plugin to be capable of receiving configuration. This patch enables the "converter" node of the configuration of a "type rate" plugin to be specified as a compound and passed to open func of the converter plugin. The SND_PCM_RATE_PLUGIN_VERSION is incremented and SND_PCM_RATE_PLUGIN_VERSION_CONFIGURE is defined so that a converter plugin can test whether it should expect the extra parameter on its open func. Alan. From febb2e95682e99fee04f5853f783ba48748850b5 Mon Sep 17 00:00:00 2001 From: Alan Young Date: Thu, 7 Apr 2016 09:15:04 +0100 Subject: [PATCH] pcm: rate: Add capability to pass configuration node to plugins If a rate plugin uses a node (compound) instead of a plain string for its "converter" then that compound will be passed as an additional parameter to the plugin open() function (SND_PCM_RATE_PLUGIN_ENTRY(XXX)). The existing behaviour of using the first (usable) plain string value, regardless of parameter name, within the configuration node as the converter name is unchanged. Signed-off-by: Alan Young --- include/pcm_rate.h | 5 +++-- src/pcm/pcm_rate.c | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/pcm_rate.h b/include/pcm_rate.h index 4d70df2..fb7ec55 100644 --- a/include/pcm_rate.h +++ b/include/pcm_rate.h @@ -38,7 +38,8 @@ extern "C" { /** * Protocol version */ -#define SND_PCM_RATE_PLUGIN_VERSION 0x010002 +#define SND_PCM_RATE_PLUGIN_VERSION 0x010003 +#define SND_PCM_RATE_PLUGIN_VERSION_CONFIGURE 0x010003 /** hw_params information for a single side */ typedef struct snd_pcm_rate_side_info { @@ -118,7 +119,7 @@ typedef struct snd_pcm_rate_ops { /** open function type */ typedef int (*snd_pcm_rate_open_func_t)(unsigned int version, void **objp, - snd_pcm_rate_ops_t *opsp); + snd_pcm_rate_ops_t *opsp, const snd_config_t *conf); /** * Define the object entry for external PCM rate-converter plugins diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index cbb7618..c0a60d7 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -1258,7 +1258,7 @@ static const char *const default_rate_plugins[] = { "speexrate", "linear", NULL }; -static int rate_open_func(snd_pcm_rate_t *rate, const char *type, int verbose) +static int rate_open_func(snd_pcm_rate_t *rate, const char *type, const snd_config_t *converter_conf, int verbose) { char open_name[64], lib_name[128], *lib = NULL; snd_pcm_rate_open_func_t open_func; @@ -1279,7 +1279,7 @@ static int rate_open_func(snd_pcm_rate_t *rate, const char *type, int verbose) rate->rate_max = SND_PCM_PLUGIN_RATE_MAX; rate->plugin_version = SND_PCM_RATE_PLUGIN_VERSION; - err = open_func(SND_PCM_RATE_PLUGIN_VERSION, &rate->obj, &rate->ops); + err = open_func(SND_PCM_RATE_PLUGIN_VERSION, &rate->obj, &rate->ops, converter_conf); if (!err) { rate->plugin_version = rate->ops.version; if (rate->ops.get_supported_rates) @@ -1292,7 +1292,7 @@ static int rate_open_func(snd_pcm_rate_t *rate, const char *type, int verbose) /* try to open with the old protocol version */ rate->plugin_version = SND_PCM_RATE_PLUGIN_VERSION_OLD; err = open_func(SND_PCM_RATE_PLUGIN_VERSION_OLD, - &rate->obj, &rate->ops); + &rate->obj, &rate->ops, NULL); if (err) { snd_dlobj_cache_put(open_func); rate->open_func = NULL; @@ -1353,21 +1353,21 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, if (!converter) { const char *const *types; for (types = default_rate_plugins; *types; types++) { - err = rate_open_func(rate, *types, 0); + err = rate_open_func(rate, *types, NULL, 0); if (!err) { type = *types; break; } } } else if (!snd_config_get_string(converter, &type)) - err = rate_open_func(rate, type, 1); + err = rate_open_func(rate, type, NULL, 1); else if (snd_config_get_type(converter) == SND_CONFIG_TYPE_COMPOUND) { snd_config_iterator_t i, next; snd_config_for_each(i, next, converter) { snd_config_t *n = snd_config_iterator_entry(i); if (snd_config_get_string(n, &type) < 0) break; - err = rate_open_func(rate, type, 0); + err = rate_open_func(rate, type, converter, 0); if (!err) break; } @@ -1386,7 +1386,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, #else type = "linear"; open_func = SND_PCM_RATE_PLUGIN_ENTRY(linear); - err = open_func(SND_PCM_RATE_PLUGIN_VERSION, &rate->obj, &rate->ops); + err = open_func(SND_PCM_RATE_PLUGIN_VERSION, &rate->obj, &rate->ops, 0); if (err < 0) { snd_pcm_free(pcm); free(rate); @@ -1439,6 +1439,11 @@ pcm.name { converter [ STR1 STR2 ... ] # optional # Converter type, default is taken from # defaults.pcm.rate_converter + # or + converter { # optional + name STR # Convertor type + xxx yyy # optional convertor-specific configuration + } } \endcode -- 2.5.5