[Pkg-alsa-devel] [PATCH] amixer and special 'front...' channels

Elimar Riesebieter riesebie at lxtec.de
Sat Jul 7 22:19:25 UTC 2007


This isn't Ubuntu/Debian specific and should be applied upstream?

On Sat, 07 Jul 2007 the mental interface of
David Decotigny told:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> Hi,
> 
> Imagine you have this kind of control:
> 
> Simple mixer control 'Input Source',0
>   Capabilities: enum
>   Items: 'Mic' 'Front Mic' 'Line'
>   Item0: 'Mic'
> 
> ... and you want to set it to 'Front Mic':
> 
> shell> amixer sset 'Input Source' 'Front Mic'
> Simple mixer control 'Input Source',0
>   Capabilities: enum
>   Items: 'Mic' 'Front Mic' 'Line'
>   Item0: 'Mic'
> 
> This does not work ! Because amixer will think that 'Front' is a
> modifier for 'Mic'.
> 
> Attached is a patch against alsa-utils-1.0.13-1ubuntu5 that solves this.
> With this patch, one can bypass the modifier parsing: one simply escapes
> the parameter with one or more backslash(es), and that's all:
> 
> shell> amixer sset 'Input Source' '\Front Mic'
> Simple mixer control 'Input Source',0
>   Capabilities: enum
>   Items: 'Mic' 'Front Mic' 'Line'
>   Item0: 'Front Mic'
> 
> What this patch also does, is that it adds correct identification of
> items. With the original version, given the following enumeration:
>   foo foobar
> Then the parameter 'foobar' will be identified as 'foo', not 'foobar'.
> The patch should solve this potential problem (not tested though).
> 
> Bye,
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFGj/X0ld7vhusVrCERAjIZAJ9w9GLD+QBwDCaTs32hpW6i9nVMfgCfdS5w
> jhipZ2jm87fq4zx4f5Q9Vsc=
> =M2KP
> -----END PGP SIGNATURE-----

> diff -ru alsa-utils-1.0.13/amixer/amixer.1 alsa-utils-1.0.13-mine/amixer/amixer.1
> --- alsa-utils-1.0.13/amixer/amixer.1	2006-09-29 04:53:26.000000000 -0700
> +++ alsa-utils-1.0.13-mine/amixer/amixer.1	2007-07-07 13:09:04.000000000 -0700
> @@ -44,11 +44,14 @@
>  The parameters \fIcap, nocap, mute, unmute, toggle\fP are used to
>  change capture (recording) and muting for the group specified.
>  
> -The optional modifiers can be put as extra parameters to specify
> -the stream direction or channels to apply.
> -The modifiers \fIplayback\fP and \fIcapture\fP specify the stream,
> -and the modifiers \fIfront, rear, center, woofer\fP are used to specify
> -channels to be changed. 
> +The optional modifiers can be put as extra parameters to specify the
> +stream direction or channels to apply.  The modifiers \fIplayback\fP
> +and \fIcapture\fP specify the stream, and the modifiers \fIfront,
> +rear, center, woofer\fP are used to specify channels to be changed. If
> +there is a confusion between the parameter and these modifiers, then
> +any character in the parameter may be escaped with a backslash to
> +disambiguate: '\\Front Mic' will be understood as "parameter 'Front
> +Mic'", and not as "modifier 'Front' applied to 'Mic' parameter".
>  
>  A simple mixer control must be specified. Only one device can be controlled
>  at a time.
> diff -ru alsa-utils-1.0.13/amixer/amixer.c alsa-utils-1.0.13-mine/amixer/amixer.c
> --- alsa-utils-1.0.13/amixer/amixer.c	2007-07-07 13:03:39.000000000 -0700
> +++ alsa-utils-1.0.13-mine/amixer/amixer.c	2007-07-07 12:59:19.000000000 -0700
> @@ -1333,6 +1333,16 @@
>  	return def;
>  }
>  
> +/** Transform '\a\b c \de' into 'ab c de' */
> +static void unescape(char * arg)
> +{
> +  char * c;
> +  for (c = arg ; arg && *arg ; arg ++)
> +    if (*arg != '\\')
> +      *(c++) = *arg;
> +  *c = '\0';
> +}
> +
>  static int get_enum_item_index(snd_mixer_elem_t *elem, char **ptrp)
>  {
>  	char *ptr = *ptrp;
> @@ -1347,7 +1357,7 @@
>  		if (snd_mixer_selem_get_enum_item_name(elem, i, sizeof(name)-1, name) < 0)
>  			continue;
>  		len = strlen(name);
> -		if (! strncmp(name, ptr, len)) {
> +		if (!strncmp(name, ptr, len) && (ptr[len] == '\0')) {
>  			if (! ptr[len] || ptr[len] == ',' || ptr[len] == '\n') {
>  				ptr += len;
>  				*ptrp = ptr;
> @@ -1428,6 +1438,7 @@
>  		dir = dir_mask(&ptr, dir);
>  		if (*ptr == '\0')
>  			continue;
> +		unescape(ptr);
>  		multi = (strchr(ptr, ',') != NULL);
>  		optr = ptr;
>  		for (chn = 0; chn <= SND_MIXER_SCHN_LAST; chn++) {

> _______________________________________________
> Pkg-alsa-devel mailing list
> Pkg-alsa-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/pkg-alsa-devel

-- 
  "Talking much about oneself can also 
   be a means to conceal oneself."
         -Friedrich Nietzsche
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/pkg-alsa-devel/attachments/20070708/975db556/attachment-0001.pgp 


More information about the Pkg-alsa-devel mailing list