- 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;
+ const struct mixer *const m = find_mixer(config->api);
+
+ if(m) {
+ if(set)
+ return m->set(left, right);
+ else
+ return m->get(left, right);
+ } else {
+ static int reported;
+
+ if(!reported) {
+ error(0, "don't know how to get/set volume with this api");
+ reported = 1;