diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/print_volume.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/print_volume.c b/src/print_volume.c index 1b03e5e..6a87b1e 100644 --- a/src/print_volume.c +++ b/src/print_volume.c @@ -175,12 +175,22 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * } #endif #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) - char mixerpath[] = "/dev/mixer"; + char *mixerpath; + char defaultmixer[] = "/dev/mixer"; int mixfd, vol, devmask = 0; pbval = 1; + if (mixer_idx > 0) + asprintf(&mixerpath, "/dev/mixer%d", mixer_idx); + else + mixerpath = defaultmixer; + if ((mixfd = open(mixerpath, O_RDWR)) < 0) return; + + if (mixer_idx > 0) + free(mixerpath); + if (ioctl(mixfd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1) return; if (ioctl(mixfd, MIXER_READ(0),&vol) == -1) |