From alsa-devel-owner@alsa.jcu.cz  Sat Oct  3 10:42:48 1998
Received: from entry.jcu.cz (IDENT:perex@entry.jcu.cz [160.217.1.111])
	by marvin.jcu.cz (8.9.1a/8.9.1) with SMTP id KAA10680;
	Sat, 3 Oct 1998 10:42:39 +0200
Date: Sat, 3 Oct 1998 10:42:41 +0200 (CEST)
From: Jaroslav Kysela <perex@jcu.cz>
To: Brion Vibber <brion@pobox.com>
cc: "Christopher T. Lansdown" <lansdoct@screech.cs.alfred.edu>,
        alsa-devel@jcu.cz
Subject: Re: XAmixer
In-Reply-To: <Pine.LNX.4.03.9810022350290.18073-100000@rdaneel.dyn.ml.org>
Message-ID: <Pine.LNX.3.96.981003103356.1610C-100000@entry.jcu.cz>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list

On Sat, 3 Oct 1998, Brion Vibber wrote:

> 
> 
> On Sat, 3 Oct 1998, Christopher T. Lansdown wrote:
> 
> > hi,
> > 	I fixed the link on the page.  I've updated my code to be more
> > modularized, it will take less work to maintain (i.e. the code that
> > handles user interaction doesn't need to be duplicated for each channel).
> > The reason that I didn't code in the mono channels is that I didn't see them 
> > anywhere in the docs.  If you could send me the appropriate SND_MIXER_* names,
> >  I'll write it in.  The code has changed significantly, so I doubt a patch
> > would work at the moment.  Thanks for offering, though.
> 
> >From asound.h of alsa-driver-0.2.0-pre8:
> #define SND_MIXER_ID_MONO               "Mono"
> #define SND_MIXER_ID_MONO1              "Mono 1"
> #define SND_MIXER_ID_MONO2              "Mono 2"
> 
> > 	The counter-intuitive volume settings are due to gtk, so far as I
> > can tell.  I have posted to the gtk-app-devel-list, and am awaiting an
> > answer.  I've played with things and looked around as much as I can tell,
> > there's no way to get it to be otherwise, which I don't entirely believe.
> > At least not yet... :-)
> 
> In the mean time it's a simple matter to invert the value... ie if you
> have a range of 0-255 and have 64 you set the widget to 255-64=191. Then
> when the widget gives you 200 you send 255-200=55 to the card.
> 
> > 	You are correct, the |-| button is a lock left\right.  The reason
> > that it didn't work for you was that I didn't code it in. :-)
> 
> I suspected that was the case but it's worth checking... :)
> 
> >  The code is
> > now there.  It locks both volume and muting.
> > 	Please take a look at the program again, I've updated it on my web
> > page, and tell me what you think now.
> 
> Great! The locking is working fine now.
> 
> As far as modularity... It's definately improved a bit having the channel 
> info in its own struct, but one would still (in what I just downloaded 
> at least) need to go through the entire source and add sections for:
> checking for the presence of the channel, reading the volume, creating the
> volume widget, and setting the volume for each new channel.
> 
> What I'm thinking of would be something more like this:
> 
> ...
> struct _Card
> {
>   int number; /* The card's number */
>   void *handle; /* The handle for the card */
>   snd_mixer_info_t info; /* The info for the card */
>   Channel *channels;
> }
> 
> ...
> char *MixerChannels[] = {
>   SND_MIXER_ID_MASTER,
>   ...,
>   SND_MIXER_ID_AUXB,
>   NULL
> };
> ...

Wrong... Mixer IDs (SND_MIXER_ID_*) is subject to expansion. This is main
reason why these IDs are represented by strings and not integer constants
as OSS does. If you want create universal mixer for future, doesn't use
simply list of SND_MIXER_ID_*.

For tracking of all mixer channels use:

...
int channels, index;
snd_mixer_channel_info_t info;

channels = snd_mixer_channels( mixer_handle );
if ( channel < 0 ) { perror( "channels" ); exit( 1 ); }
/* track all channels for name and other info */
for ( index = 0; index < channels; index++ ) {
  if ( snd_mixer_channel_info( mixer_handle, index, &info ) < 0 ) {
    perror( "info" );
    exit( 1 );
  }
  printf( "Channel ID: %s\n", info.name );
}
...


							Jaroslav

-----
Jaroslav Kysela <perex@jcu.cz>
Academic Computer Centre, University of South Bohemia
Branisovska 31, C. Budejovice, CZ-370 05 Czech Republic


