Re: libossaudio: start using sndio

2020-04-02 Thread Alexandre Ratchov
On Thu, Apr 02, 2020 at 05:21:45PM +0100, Stuart Henderson wrote:
> On 2020/04/02 17:13, Landry Breuil wrote:
> > On Wed, Apr 01, 2020 at 07:27:12PM +0200, Alexandre Ratchov wrote:
> > > ping!
> > > 
> > > FWIW, the diff below affects the following ports:
> > >   - emulators/gambatte
> > >   - gstreamer-0.10 mixer plugin
> > >   - sysutils/conky
> > >   - sysutils/gkrellm
> > >   - sysutil/tpb
> > >   - telephony/iaxclient
> > >   - anything depending on gstreamer, ex xfce4-mixer
> > > 
> > > If you use one of above ports and want to test, just apply this diff
> > > to src/lib/libossaudio in base, rebuild it and reinstall it. The ABI
> > > is not changing, so no need to rebuild or update ports.
> 
> btw, most of these ports are either not really used (tpb, iaxclient),
> or where the mixer functionality isn't hugely important (conky, gkrellm),
> so Landry's tests here should cover things fairly well.

I've tested conky and gkrellm, it works. They show the new controls,
but this is an improvement, imho



Re: libossaudio: start using sndio

2020-04-02 Thread Alexandre Ratchov
On Thu, Apr 02, 2020 at 05:13:49PM +0200, Landry Breuil wrote:
> On Wed, Apr 01, 2020 at 07:27:12PM +0200, Alexandre Ratchov wrote:
> > ping!
> > 
> > FWIW, the diff below affects the following ports:
> > - emulators/gambatte
> > - gstreamer-0.10 mixer plugin
> > - sysutils/conky
> > - sysutils/gkrellm
> > - sysutil/tpb
> > - telephony/iaxclient
> > - anything depending on gstreamer, ex xfce4-mixer
> > 
> > If you use one of above ports and want to test, just apply this diff
> > to src/lib/libossaudio in base, rebuild it and reinstall it. The ABI
> > is not changing, so no need to rebuild or update ports.
> 
> I've briefly tested it with xfce4-mixer which uses gst 0.10 - on a t430u
> with:
> 
> azalia0 at pci0 dev 27 function 0 "Intel 7 Series HD Audio" rev 0x04: msi
> azalia0: codecs: Realtek ALC269, Intel/0x2806, using Realtek ALC269
> 
> previously, it saw two controls, one for the output acting/wired to
> mixerctl values inputs.dac-0:1 & inputs.dac-2:3 (ie both changes upon
> control changes), and one for the input wired to inputs.mic
> 
> with the diff, xfce4-mixer now sees the 3 expected controls:
> * 'volume', wired to aucatctl 'master' / sndioctl 'output.level' value
> * 'input gain', wired to mixerctl record.volume, record.adc-0:1 &
> * record.adc-2:3 (and to sndioctl hw/input.level)
> * 'output gain', wired to mixerctl outputs.master, inputs.dac-0:1 &
> * inputs.dac-2:3 (and to sndioctl hw/output.level)
> 
> trying to toggle the 'mute' button in xfce4-mixer (for the 'input gain'
> only) leads to 'Error setting mixer recording devices (0x0): Invalid
> argument' msgs on stderr but im not sure it matters.
> 

This is "ok", it tries to select the input source, but as there's only
one choice exposed it complains on stderr.

> toggling the mute button for volume and input gain set the level to 0
> instead of toggling the hw/output.mute button but im not sure it's a big
> deal either.

This is expected as well. The mute controls, instead xfce4-mixer saves
the current level and sets it to zero. When the control is unmuted, it
sets the level to the saved value.

> all in all that seems an improvement to me, at least does what's
> expected for gst 0.10/xfce4-mixer.
> 

Many thanks for looking at this.



Re: libossaudio: start using sndio

2020-04-02 Thread Stuart Henderson
On 2020/04/02 17:13, Landry Breuil wrote:
> On Wed, Apr 01, 2020 at 07:27:12PM +0200, Alexandre Ratchov wrote:
> > ping!
> > 
> > FWIW, the diff below affects the following ports:
> > - emulators/gambatte
> > - gstreamer-0.10 mixer plugin
> > - sysutils/conky
> > - sysutils/gkrellm
> > - sysutil/tpb
> > - telephony/iaxclient
> > - anything depending on gstreamer, ex xfce4-mixer
> > 
> > If you use one of above ports and want to test, just apply this diff
> > to src/lib/libossaudio in base, rebuild it and reinstall it. The ABI
> > is not changing, so no need to rebuild or update ports.

btw, most of these ports are either not really used (tpb, iaxclient),
or where the mixer functionality isn't hugely important (conky, gkrellm),
so Landry's tests here should cover things fairly well.

> I've briefly tested it with xfce4-mixer which uses gst 0.10 - on a t430u
> with:
> 
> azalia0 at pci0 dev 27 function 0 "Intel 7 Series HD Audio" rev 0x04: msi
> azalia0: codecs: Realtek ALC269, Intel/0x2806, using Realtek ALC269
> 
> previously, it saw two controls, one for the output acting/wired to
> mixerctl values inputs.dac-0:1 & inputs.dac-2:3 (ie both changes upon
> control changes), and one for the input wired to inputs.mic
> 
> with the diff, xfce4-mixer now sees the 3 expected controls:
> * 'volume', wired to aucatctl 'master' / sndioctl 'output.level' value
> * 'input gain', wired to mixerctl record.volume, record.adc-0:1 &
> * record.adc-2:3 (and to sndioctl hw/input.level)
> * 'output gain', wired to mixerctl outputs.master, inputs.dac-0:1 &
> * inputs.dac-2:3 (and to sndioctl hw/output.level)
> 
> trying to toggle the 'mute' button in xfce4-mixer (for the 'input gain'
> only) leads to 'Error setting mixer recording devices (0x0): Invalid
> argument' msgs on stderr but im not sure it matters.
> 
> toggling the mute button for volume and input gain set the level to 0
> instead of toggling the hw/output.mute button but im not sure it's a big
> deal either.
> 
> all in all that seems an improvement to me, at least does what's
> expected for gst 0.10/xfce4-mixer.



Re: libossaudio: start using sndio

2020-04-02 Thread Landry Breuil
On Wed, Apr 01, 2020 at 07:27:12PM +0200, Alexandre Ratchov wrote:
> ping!
> 
> FWIW, the diff below affects the following ports:
>   - emulators/gambatte
>   - gstreamer-0.10 mixer plugin
>   - sysutils/conky
>   - sysutils/gkrellm
>   - sysutil/tpb
>   - telephony/iaxclient
>   - anything depending on gstreamer, ex xfce4-mixer
> 
> If you use one of above ports and want to test, just apply this diff
> to src/lib/libossaudio in base, rebuild it and reinstall it. The ABI
> is not changing, so no need to rebuild or update ports.

I've briefly tested it with xfce4-mixer which uses gst 0.10 - on a t430u
with:

azalia0 at pci0 dev 27 function 0 "Intel 7 Series HD Audio" rev 0x04: msi
azalia0: codecs: Realtek ALC269, Intel/0x2806, using Realtek ALC269

previously, it saw two controls, one for the output acting/wired to
mixerctl values inputs.dac-0:1 & inputs.dac-2:3 (ie both changes upon
control changes), and one for the input wired to inputs.mic

with the diff, xfce4-mixer now sees the 3 expected controls:
* 'volume', wired to aucatctl 'master' / sndioctl 'output.level' value
* 'input gain', wired to mixerctl record.volume, record.adc-0:1 &
* record.adc-2:3 (and to sndioctl hw/input.level)
* 'output gain', wired to mixerctl outputs.master, inputs.dac-0:1 &
* inputs.dac-2:3 (and to sndioctl hw/output.level)

trying to toggle the 'mute' button in xfce4-mixer (for the 'input gain'
only) leads to 'Error setting mixer recording devices (0x0): Invalid
argument' msgs on stderr but im not sure it matters.

toggling the mute button for volume and input gain set the level to 0
instead of toggling the hw/output.mute button but im not sure it's a big
deal either.

all in all that seems an improvement to me, at least does what's
expected for gst 0.10/xfce4-mixer.



libossaudio: start using sndio

2020-04-01 Thread Alexandre Ratchov
ping!

FWIW, the diff below affects the following ports:
- emulators/gambatte
- gstreamer-0.10 mixer plugin
- sysutils/conky
- sysutils/gkrellm
- sysutil/tpb
- telephony/iaxclient
- anything depending on gstreamer, ex xfce4-mixer

If you use one of above ports and want to test, just apply this diff
to src/lib/libossaudio in base, rebuild it and reinstall it. The ABI
is not changing, so no need to rebuild or update ports.

- Forwarded message from Alexandre Ratchov  -

Date: Tue, 17 Mar 2020 12:27:40 +0100
From: Alexandre Ratchov 
To: po...@openbsd.org
Subject: libossaudio: important diff to test
User-Agent: Mutt/1.11.4 (2019-03-13)

Hi,

This diff makes libossaudio use sndio instead of the kernel mixer(4)
interface. I post it to ports@ as it's only used by few ports.

Switching libossaudio to sndio implies that programs using it will
always use the right device (instead of the first one) and will always
see at least the sndiod master level control.

With this diff, libossaudio will expose the following controls:
  - output.level, sndiod master level, always present
  - hw/output.level, hardware output level, present on certain devices only
  - hw/input.level, hardware input level, present on certain devices only

OK?

-- Alexandre

Index: lib/libossaudio/Makefile
===
RCS file: /cvs/src/lib/libossaudio/Makefile,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 Makefile
--- lib/libossaudio/Makefile16 Jul 2014 20:02:17 -  1.5
+++ lib/libossaudio/Makefile22 Feb 2020 16:07:05 -
@@ -4,9 +4,11 @@
 LIB=   ossaudio
 MAN=   ossaudio.3
 
-SRCS=  ossaudio.c
+SRCS=  ossaudio.c aucat.c debug.c sioctl.c sioctl_aucat.c sioctl_sun.c
 
 CPPFLAGS+= -I${.CURDIR}
+
+.PATH: ${.CURDIR}/../libsndio
 
 includes:
@cd ${.CURDIR}; cmp -s soundcard.h ${DESTDIR}/usr/include/soundcard.h 
|| \
Index: lib/libossaudio/ossaudio.c
===
RCS file: /cvs/src/lib/libossaudio/ossaudio.c,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 ossaudio.c
--- lib/libossaudio/ossaudio.c  28 Jun 2019 13:32:42 -  1.20
+++ lib/libossaudio/ossaudio.c  22 Feb 2020 16:07:05 -
@@ -36,26 +36,38 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
-
+#include 
+#include 
+#include 
+#include 
 #include "soundcard.h"
-#undef ioctl
 
-#define GET_DEV(com) ((com) & 0xff)
+#ifdef DEBUG
+#define DPRINTF(...) do { fprintf(stderr, __VA_ARGS__); } while (0)
+#else
+#define DPRINTF(...) do {} while (0)
+#endif
 
-#define TO_OSSVOL(x)   (((x) * 100 + 127) / 255)
-#define FROM_OSSVOL(x) x) > 100 ? 100 : (x)) * 255 + 50) / 100)
+#define GET_DEV(com) ((com) & 0xff)
+#define INTARG (*(int*)argp)
 
-static struct audiodevinfo *getdevinfo(int);
+struct control {
+   struct control *next;
+   int type;   /* one of SOUND_MIXER_xxx */
+   int chan;   /* 0 -> left, 1 -> right, -1 -> mono */
+   int addr;   /* sioctl control id */
+   int value;  /* current value */
+   int max;
+};
 
 static int mixer_ioctl(int, unsigned long, void *);
-static int opaque_to_enum(struct audiodevinfo *di, audio_mixer_name_t *label, 
int opq);
-static int enum_to_ord(struct audiodevinfo *di, int enm);
-static int enum_to_mask(struct audiodevinfo *di, int enm);
 
-#define INTARG (*(int*)argp)
+static int initialized;
+static struct control *controls;
+static struct sioctl_hdl *hdl;
+static char *dev_name = SIO_DEVANY;
+static struct pollfd *pfds;
 
 int
 _oss_ioctl(int fd, unsigned long com, ...)
@@ -71,201 +83,163 @@ _oss_ioctl(int fd, unsigned long com, ..
else if (IOCGROUP(com) == 'M')
return mixer_ioctl(fd, com, argp);
else
-   return ioctl(fd, com, argp);
+   return (ioctl)(fd, com, argp);
 }
 
-/* If the mixer device should have more than MAX_MIXER_DEVS devices
- * some will not be available to Linux */
-#define MAX_MIXER_DEVS 64
-struct audiodevinfo {
-   int done;
-   dev_t dev;
-   ino_t ino;
-   int16_t devmap[SOUND_MIXER_NRDEVICES],
-   rdevmap[MAX_MIXER_DEVS];
-   char names[MAX_MIXER_DEVS][MAX_AUDIO_DEV_LEN];
-   int enum2opaque[MAX_MIXER_DEVS];
-u_long devmask, recmask, stereomask;
-   u_long caps, recsource;
-};
-
-static int
-opaque_to_enum(struct audiodevinfo *di, audio_mixer_name_t *label, int opq)
+/*
+ * new control
+ */
+static void
+mixer_ondesc(void *unused, struct sioctl_desc *d, int val)
 {
-   int i, o;
+   struct control *i, **pi;
+   int type;
 
-   for (i = 0; i < MAX_MIXER_DEVS; i++) {
-   o = di->enum2opaque[i];
-   if (o == opq)
-   break;
-   if (o == -1 && label != NULL &&
-   !strncmp(di->names[i], label->name, sizeof di->names[i])) {
-