Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Pkg-alsa-devel] [PATCH] amixer and special 'front...' channels
       [not found] <468FF5F5.1070402@free.fr>
@ 2007-07-07 22:19 ` Elimar Riesebieter
  2007-07-09 10:06   ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Elimar Riesebieter @ 2007-07-07 22:19 UTC (permalink / raw)
  To: David Decotigny
  Cc: Ubuntu Core Developers, Debian ALSA Maintainers, alsa-devel


[-- Attachment #1.1: Type: text/plain, Size: 4596 bytes --]


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@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

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Pkg-alsa-devel] [PATCH] amixer and special 'front...' channels
  2007-07-07 22:19 ` [Pkg-alsa-devel] [PATCH] amixer and special 'front...' channels Elimar Riesebieter
@ 2007-07-09 10:06   ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2007-07-09 10:06 UTC (permalink / raw)
  To: Elimar Riesebieter
  Cc: Ubuntu Core Developers, Debian ALSA Maintainers, alsa-devel,
	David Decotigny

At Sun, 8 Jul 2007 00:19:25 +0200,
Elimar Riesebieter wrote:
> 
> 
> This isn't Ubuntu/Debian specific and should be applied upstream?

Sorry, no, it's too hackish.

There is no reason to parse the channel for enum items.  It should be
passed simply as it is.  I'll fix (and clean up the mess) later...


Takashi

> 
> 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@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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-09 10:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <468FF5F5.1070402@free.fr>
2007-07-07 22:19 ` [Pkg-alsa-devel] [PATCH] amixer and special 'front...' channels Elimar Riesebieter
2007-07-09 10:06   ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox