Skip to contentSkip to conversation

pcm: extplug: Use same format for slave

PATCH In review [email protected] 2 participants 3 messages Dec 7, 2018

lore
Share & tools
lore
#0 lore raw

cover pcm: extplug: Use same format for slave

Hi Takashi,

I have the following new idea for
[PATCH - extplug refinement from hw_params 1/1] pcm: extplug: Update slave PCM if extplug slave params were changed

May be you could give a short feedback.
I will try to provide a reproduction scenario.

Do you have an idea how to handle this additional function parameter without breaking the API.

Best regards
Timo

#1 lore raw

PATCH 1/1 pcm: extplug: Use same format and channels for slave

From: Timo Wischer <[email protected]>

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.

include/pcm_extplug.h +14 -4
index e3b71bc..27ae848 100644
@@ -31,6 +31,8 @@
 #ifndef __ALSA_PCM_EXTPLUG_H
 #define __ALSA_PCM_EXTPLUG_H
 
+#include <stdbool.h>
+
 /**
  * \defgroup PCM_ExtPlug External Filter plugin SDK
  * \ingroup Plugin_SDK
@@ -180,17 +182,25 @@ int snd_pcm_extplug_delete(snd_pcm_extplug_t *ext);
 void snd_pcm_extplug_params_reset(snd_pcm_extplug_t *ext);
 
 /* hw_parameter setting */
-int snd_pcm_extplug_set_param_list(snd_pcm_extplug_t *extplug, int type, unsigned int num_list, const unsigned int *list);
-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_param_list(snd_pcm_extplug_t *extplug, int type,
+				   unsigned int num_list,
+				   const unsigned int *list,
+				   const bool conversion_supported);
+int snd_pcm_extplug_set_param_minmax(snd_pcm_extplug_t *extplug, int type,
+				     unsigned int min, unsigned int max,
+				     const bool conversion_supported);
 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);
 
 /**
  * set the parameter constraint with a single value
  */
-static __inline__ int snd_pcm_extplug_set_param(snd_pcm_extplug_t *extplug, int type, unsigned int val)
+static __inline__ int snd_pcm_extplug_set_param(snd_pcm_extplug_t *extplug,
+						int type, unsigned int val,
+						const bool conversion_supported)
 {
-	return snd_pcm_extplug_set_param_list(extplug, type, 1, &val);
+	return snd_pcm_extplug_set_param_list(extplug, type, 1, &val,
+					      conversion_supported);
 }
 
 /**
src/pcm/pcm_extplug.c +44 -6

134 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

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

Quoted 5 lines · On Fri, 07 Dec 2018 17:12:13 +0100, <[email protected]> wrote:

From: Timo Wischer <[email protected]>

if conversion is not supported by the implemented extplug.

Quoted 7 lines

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.

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

---

include/pcm_extplug.h +1 -0
@@ -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
src/pcm/pcm_ext_parm.h +1 -0
@@ -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,
src/pcm/pcm_extplug.c +14 -1
@@ -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;
+}