Dunno if anyone else has bothered before, but here is a small C program to set the volume level on a RioCar/Empeg player.

This is useful when attempting to play sounds prior to the player having started up, especially when Hijack is installed since Hijack zeros the volume controls at init time.

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>

#define MIXER "/dev/mixer"

int main(int argc, char *argv[])
{
int fd;
int vol = -1;

if (argc != 2 || (vol = atoi(argv[1])) < 0 || vol > 100) {
fprintf(stderr, "Usage: %s volume (where 0 <= volume <= 100)\n", argv[0]);
exit(1);
}

fd = open(MIXER, O_WRONLY);
if (fd == -1) {
perror(MIXER);
exit(1);
}

vol |= (vol << 8);
if (ioctl(fd, SOUND_MIXER_WRITE_VOLUME, &vol) == -1) {
perror("SOUND_MIXER_WRITE_VOLUME");
exit(-1);
}
close(fd);
printf("Volume=%d\n", vol & 0xff);
exit(0);
}


Attachments
96458-setvol.gz (82 downloads)