From alsa-devel-owner@alsa.jcu.cz  Sun Oct  4 11:02:17 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 LAA25168;
	Sun, 4 Oct 1998 11:01:59 +0200
Date: Sun, 4 Oct 1998 11:01:57 +0200 (CEST)
From: Jaroslav Kysela <perex@jcu.cz>
To: "Christopher T. Lansdown" <lansdoct@screech.cs.alfred.edu>
cc: alsa-devel@jcu.cz
Subject: Re: Updating...
In-Reply-To: <Pine.LNX.4.05.9810040155520.20436-100000@screech.cs.alfred.edu>
Message-ID: <Pine.LNX.3.96.981004104924.4238B-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 Sun, 4 Oct 1998, Christopher T. Lansdown wrote:

> Hi,
> 	What is the best method for updating XAmixer when another program
> changes a mixer value?  Alsamixer seems to wait on the file descriptor for
> the particular sound card... is something sent down it when a mixer value
> changes?  Thanks.

ALSA mixer kernel supports select() (read direction) for file descriptor
which gives info to process if some mixer channel was changed by another
process.

The example:

function void mixer_update( void *private_data, int channel )
{
  printf( "channel %i changed!!!\n", channel );
}

....

  fd_set in;
  fd_set out;
  int mixer_fd;		/* mixer file descriptor */
  int last_fd;		/* last file descriptor */
  snd_mixer_callbacks_t callbacks;

  mixer_fd = snd_mixer_file_descriptor( mixer_handle );
  bzero( &callbacks, sizeof( callbacks ) );
  callbacks.private_data = NULL;	/* assign what you need */
  callbacks.channel_was_changed = mixer_update;
  ... main event loop ...
  FD_ZERO( &in );
  FD_ZERO( &out );
  FD_SET( last_fd = mixer_fd, &in );
  /* todo: setup all other read/write file descriptors */
  if ( select( last_fd + 1, &in, &out, NULL, NULL ) < 0 )
    exit(1);
  if ( FD_ISSET( mixer_fd ) )
    snd_mixer_read( mixer_handle, &callbacks );
  ...

Don't remember assign all filedescriptors (including user input
filedescriptor to main loop otherwise only mixer input will be active).
Maybe GTK handling of select() is different.

						Jaroslav

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


