1
/* Gtick - A Gtk+ Metronome
3
* mixer.c: Sound mixer code, for volume type stuff..
5
* Copyright (c) 1999, Alex Roberts
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Library General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Library General Public License for more details.
17
* You should have received a copy of the GNU Library General Public
18
* License along with this library; if not, write to the
19
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
25
#include <sys/ioctl.h>
30
#include <machine/soundcard.h>
32
#include <linux/soundcard.h>
39
static gchar devName[] = "/dev/mixer";
44
g_print ("gtInitMixer: Initialising %s..\n", devName);
47
if ((mix = open (devName, O_RDWR, 0)) == -1)
49
g_error ("Couldnt open mixer device /dev/mixer\n");
58
g_print ("gtCloseMixer: Closing /dev/mixer..\n");
68
ioctl (mix, MIXER_READ(SOUND_MIXER_PCM), &vol);
71
r = (vol & 0xff00) >> 8;
74
g_print ("gtGetMixer: vol=%d, l=%d, r=%d\n", vol, l, r);
80
void gtSetMixer (gint vol)
84
tvol = (vol << 8) + vol;
87
g_print ("gtSetMixer: Setting mixer value: %d\n", tvol);
90
ioctl (mix, MIXER_WRITE(SOUND_MIXER_PCM), &tvol);