Hi,

i3status doesn't display the volume on some hardware, specifically
auich(4), and I think anything else in the ac97(4) family possibly has
the same problem.

On auich at least the AUDIO_MIXER_READ ioctl fails if num_channels isn't
specified. Also i3status reads the mute status from the wrong device as
there's an "outputs.mono.mute" that has a higher index than
"outputs.master.mute", and i3status just ends up using the last one
it finds that's called "mute" in the outputs group.

If this patch is okay I'll try and submit it upstream.


-- 
Carlin


Index: Makefile
===================================================================
RCS file: /cvs/ports/x11/i3status/Makefile,v
retrieving revision 1.47
diff -u -p -u -r1.47 Makefile
--- Makefile    14 Aug 2017 22:32:17 -0000      1.47
+++ Makefile    7 Feb 2018 14:16:13 -0000
@@ -5,7 +5,7 @@ ONLY_FOR_ARCHS=         ${APM_ARCHS}
 COMMENT=               generate a statusbar for use with i3/xmobar/dzen2
 
 DISTNAME=              i3status-2.11
-REVISION=              5
+REVISION=              6
 CATEGORIES=            x11 sysutils
 
 HOMEPAGE=              http://i3wm.org/i3status/
Index: patches/patch-src_print_volume_c
===================================================================
RCS file: patches/patch-src_print_volume_c
diff -N patches/patch-src_print_volume_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_print_volume_c    7 Feb 2018 14:16:13 -0000
@@ -0,0 +1,44 @@
+$OpenBSD$
+
+Fix volume display on some hardware by selecting the right mute device 
+and specifying the current channel count
+
+Index: src/print_volume.c
+--- src/print_volume.c.orig
++++ src/print_volume.c
+@@ -211,6 +211,7 @@ void print_volume(yajl_gen json_gen, char *buffer, con
+ 
+ #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, con
+ 
+     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, con
+ 
+     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;
+ 

Reply via email to