Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Elimar Riesebieter <riesebie@lxtec.de>
Cc: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>,
	Debian ALSA Maintainers <pkg-alsa-devel@lists.alioth.debian.org>,
	alsa-devel <alsa-devel@alsa-project.org>,
	David Decotigny <com.d2@free.fr>
Subject: Re: [Pkg-alsa-devel] [PATCH] amixer and special	'front...' channels
Date: Mon, 09 Jul 2007 12:06:36 +0200	[thread overview]
Message-ID: <s5hhcodvqkz.wl%tiwai@suse.de> (raw)
In-Reply-To: <20070707221925.GA31973@frodo.home.lxtec.de>

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

      reply	other threads:[~2007-07-09 10:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hhcodvqkz.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=com.d2@free.fr \
    --cc=pkg-alsa-devel@lists.alioth.debian.org \
    --cc=riesebie@lxtec.de \
    --cc=ubuntu-devel-discuss@lists.ubuntu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox