summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlin Bingham <cb@viennan.net>2018-02-13 02:12:04 +1300
committerCarlin Bingham <cb@viennan.net>2018-02-13 02:12:04 +1300
commit5b416d4ac00caf6028416999d3cef3b997d33f3b (patch)
tree0b1dce6701fa6ddef71580586390f6197a72c17e /src
parent0880b0ec03a7201c2bf178ee7613dcb9eec48fd2 (diff)
OpenBSD: fix volume display on some hardware
On some hardware the AUDIO_MIXER_READ ioctl requires the current number of channels to be set, and the mute device found needs to be checked if it belongs to the master output device.
Diffstat (limited to 'src')
-rw-r--r--src/print_volume.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/print_volume.c b/src/print_volume.c
index 51e84f3..be6a1d7 100644
--- a/src/print_volume.c
+++ b/src/print_volume.c
@@ -211,6 +211,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *
#if defined(__OpenBSD__)
int oclass_idx = -1, master_idx = -1, master_mute_idx = -1;
+ int master_next = AUDIO_MIXER_LAST;
mixer_devinfo_t devinfo, devinfo2;
mixer_ctrl_t vinfo;
@@ -228,12 +229,17 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *
devinfo2.index = 0;
while (ioctl(mixfd, AUDIO_MIXER_DEVINFO, &devinfo2) >= 0) {
- if ((devinfo2.type == AUDIO_MIXER_VALUE) && (devinfo2.mixer_class == oclass_idx) && (strncmp(devinfo2.label.name, AudioNmaster, MAX_AUDIO_DEV_LEN) == 0))
+ if ((devinfo2.type == AUDIO_MIXER_VALUE) && (devinfo2.mixer_class == oclass_idx) && (strncmp(devinfo2.label.name, AudioNmaster, MAX_AUDIO_DEV_LEN) == 0)) {
master_idx = devinfo2.index;
+ master_next = devinfo2.next;
+ }
if ((devinfo2.type == AUDIO_MIXER_ENUM) && (devinfo2.mixer_class == oclass_idx) && (strncmp(devinfo2.label.name, AudioNmute, MAX_AUDIO_DEV_LEN) == 0))
- master_mute_idx = devinfo2.index;
+ if (master_next == devinfo2.index)
+ master_mute_idx = devinfo2.index;
+ if (master_next != AUDIO_MIXER_LAST)
+ master_next = devinfo2.next;
devinfo2.index++;
}
@@ -246,6 +252,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *
vinfo.dev = master_idx;
vinfo.type = AUDIO_MIXER_VALUE;
+ vinfo.un.value.num_channels = devinfo.un.v.num_channels;
if (ioctl(mixfd, AUDIO_MIXER_READ, &vinfo) == -1)
goto out;