-int mixer_control(int *left, int *right, int set) {
- int fd, ch, r;
-
- if(config->mixer
- && config->channel
- && (ch = mixer_channel(config->channel)) != -1) {
- if((fd = open(config->mixer, O_RDWR, 0)) < 0) {
- error(errno, "error opening %s", config->mixer);
- return -1;
- }
- if(set) {
- r = (*left & 0xff) + (*right & 0xff) * 256;
- if(ioctl(fd, SOUND_MIXER_WRITE(ch), &r) == -1) {
- error(errno, "error changing %s channel %s",
- config->mixer, config->channel);
- xclose(fd);
- return -1;
- }
- }
- if(ioctl(fd, SOUND_MIXER_READ(ch), &r) == -1) {
- error(errno, "error reading %s channel %s",
- config->mixer, config->channel);
- xclose(fd);
- return -1;
- }
- *left = r & 0xff;
- *right = (r >> 8) & 0xff;
- xclose(fd);
- return 0;
- } else
- return -1;