[alsa-devel] [PATCH - extplug without conversion 1/1] pcm: extplug: Use same format and channels for slave

Takashi Iwai tiwai at suse.de
Fri Dec 7 17:30:08 CET 2018


On Fri, 07 Dec 2018 17:12:13 +0100,
<twischer at de.adit-jv.com> wrote:
> 
> From: Timo Wischer <twischer at de.adit-jv.com>
> 
> if conversion is not supported by the implemented extplug.
> 
> Currently only the parameters for client and slave PCM can be limited
> separately. But there is no dependency between this parameters.
> This patch allows the user to link both parameter sets also if
> snd_pcm_extplug_set_param*() was used to limit the capabilities of the
> plugin.
> 
> Signed-off-by: Timo Wischer <twischer at de.adit-jv.com>

That's somewhat similar I had in my mind, but I'd rather leave the
current API as is.

Basically what you need is to tell which parameter to be linked, so
let's add just a simpler API to set/clear the link flag that can be
used on top of the existing API, something like below.

The concept of link is a bit difficult for readers, but it should be
understandable once when the actual usage is found.


thanks,

Takashi

---
diff --git a/include/pcm_extplug.h b/include/pcm_extplug.h
--- a/include/pcm_extplug.h
+++ b/include/pcm_extplug.h
@@ -184,6 +184,7 @@ int snd_pcm_extplug_set_param_list(snd_pcm_extplug_t *extplug, int type, unsigne
 int snd_pcm_extplug_set_param_minmax(snd_pcm_extplug_t *extplug, int type, unsigned int min, unsigned int max);
 int snd_pcm_extplug_set_slave_param_list(snd_pcm_extplug_t *extplug, int type, unsigned int num_list, const unsigned int *list);
 int snd_pcm_extplug_set_slave_param_minmax(snd_pcm_extplug_t *extplug, int type, unsigned int min, unsigned int max);
+int snd_pcm_extplug_set_param_link(snd_pcm_extplug_t *extplug, int type, int keep_link);
 
 /**
  * set the parameter constraint with a single value
diff --git a/src/pcm/pcm_ext_parm.h b/src/pcm/pcm_ext_parm.h
--- a/src/pcm/pcm_ext_parm.h
+++ b/src/pcm/pcm_ext_parm.h
@@ -5,6 +5,7 @@ struct snd_ext_parm {
 	unsigned int *list;
 	unsigned int active: 1;
 	unsigned int integer: 1;
+	unsigned int keep_link: 1;
 };
 
 static inline snd_mask_t *hw_param_mask(snd_pcm_hw_params_t *params,
diff --git a/src/pcm/pcm_extplug.c b/src/pcm/pcm_extplug.c
--- a/src/pcm/pcm_extplug.c
+++ b/src/pcm/pcm_extplug.c
@@ -249,7 +249,7 @@ static unsigned int get_links(struct snd_ext_parm *params)
 			      SND_PCM_HW_PARBIT_TICK_TIME);
 
 	for (i = 0; i < SND_PCM_EXTPLUG_HW_PARAMS; i++) {
-		if (params[i].active)
+		if (params[i].active && !params[i].keep_link)
 			links &= ~excl_parbits[i];
 	}
 	return links;
@@ -849,3 +849,16 @@ int snd_pcm_extplug_set_param_minmax(snd_pcm_extplug_t *extplug, int type, unsig
 	return snd_ext_parm_set_minmax(&ext->params[type], min, max);
 }
 
+/**
+ * DOCUMENTATION HERE PLEASE
+ */
+int snd_pcm_extplug_set_param_link(snd_pcm_extplug_t *extplug, int type, int keep_link)
+{
+	extplug_priv_t *ext = extplug->pcm->private_data;
+	if (type < 0 || type >= SND_PCM_EXTPLUG_HW_PARAMS) {
+		SNDERR("EXTPLUG: invalid parameter type %d", type);
+		return -EINVAL;
+	}
+	ext->params[type].keep_link = keep_link;
+	return 0;
+}


More information about the Alsa-devel mailing list