commit: 817c3900b0fd9ad2355f9709e86b0cfb4b8e3b10
parent add900e7b06008cd0d2cc475ce8a2f06a11c30f3
Author: Michael Forney <mforney@mforney.org>
Date: Thu, 5 Nov 2020 00:31:48 -0800
Add sndio 1.7.0
Diffstat:
8 files changed, 148 insertions(+), 0 deletions(-)
diff --git a/.gitmodules b/.gitmodules
@@ -286,6 +286,10 @@
[submodule "pkg/sinit/src"]
path = pkg/sinit/src
url = git://git.suckless.org/sinit
+[submodule "pkg/sndio/src"]
+ path = pkg/sndio/src
+ url = https://caoua.org/git/sndio
+ ignore = all
[submodule "pkg/squashfs-tools-ng/src"]
path = pkg/squashfs-tools-ng/src
url = https://github.com/AgentD/squashfs-tools-ng.git
diff --git a/pkg/gen.lua b/pkg/gen.lua
@@ -102,6 +102,7 @@ subgen 'sfeed'
subgen 'sfeed_curses'
subgen 'sinit'
subgen 'skeleton'
+subgen 'sndio'
subgen 'squashfs-tools-ng'
subgen 'sshfs'
subgen 'st'
diff --git a/pkg/sndio/config.h b/pkg/sndio/config.h
@@ -0,0 +1,2 @@
+#define HAVE_CLOCK_GETTIME 1
+#define HAVE_SOCK_CLOEXEC 1
diff --git a/pkg/sndio/gen.lua b/pkg/sndio/gen.lua
@@ -0,0 +1,55 @@
+cflags{
+ '-std=c99', '-Wall', '-Wpedantic',
+ '-Wno-format-truncation',
+ '-D _GNU_SOURCE',
+ '-I $srcdir/libsndio',
+ '-I $srcdir/bsd-compat',
+ '-isystem $builddir/pkg/alsa-lib/include',
+ '-include $dir/config.h',
+}
+
+pkg.deps = {
+ 'pkg/alsa-lib/headers',
+}
+pkg.hdrs = copy('$outdir/include', '$srcdir/libsndio', {'sndio.h'})
+
+-- everything but mio.c and sio.c
+local objs = objects[[
+ libsndio/(
+ debug.c aucat.c
+ mio_aucat.c
+ sio_aucat.c
+ sioctl.c sioctl_aucat.c
+ )
+ bsd-compat/(issetugid.c strlcat.c strlcpy.c strtonum.c clock_gettime.c)
+ $builddir/pkg/alsa-lib/libasound.a
+]]
+
+-- build mio.c and sio.c for sndiod with alsa support
+for _, src in ipairs{'mio.c', 'mio_alsa.c', 'sio.c', 'sio_alsa.c'} do
+ build('cc', '$outdir/sndiod/'..src..'.o', '$srcdir/libsndio/'..src, {cflags='$cflags -D USE_ALSA'})
+end
+lib('libsndio.a', {objs, 'libsndio/mio.c', 'libsndio/sio.c'})
+
+exe('bin/sndiod', {objs, paths[[
+ sndiod/(
+ abuf.c utils.c dev.c dev_sioctl.c dsp.c file.c listen.c midi.c miofile.c
+ opt.c siofile.c sndiod.c sock.c
+
+ mio.c.o mio_alsa.c.o
+ sio.c.o sio_alsa.c.o
+ )
+ $builddir/pkg/alsa-lib/libasound.a
+]]})
+file('bin/sndiod', '755', '$outdir/bin/sndiod')
+man{'sndiod/sndiod.8'}
+
+exe('bin/sndioctl', 'sndioctl/sndioctl.c libsndio.a')
+file('bin/sndioctl', '755', '$outdir/bin/sndioctl')
+man{'sndioctl/sndioctl.1'}
+
+exe('bin/aucat', 'aucat/(abuf.c afile.c aucat.c dsp.c utils.c) libsndio.a')
+file('bin/aucat', '755', '$outdir/bin/aucat')
+man{'aucat/aucat.1'}
+
+fetch 'git'
diff --git a/pkg/sndio/patch/0001-sndiod-Fix-build-without-DEBUG.patch b/pkg/sndio/patch/0001-sndiod-Fix-build-without-DEBUG.patch
@@ -0,0 +1,58 @@
+From 4ee56f07ef8be718bb1f24f5b73c440527c93bc9 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Thu, 5 Nov 2020 00:28:06 -0800
+Subject: [PATCH] sndiod: Fix build without DEBUG
+
+---
+ aucat/afile.c | 4 ++--
+ sndiod/listen.c | 4 ++++
+ 2 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/aucat/afile.c b/aucat/afile.c
+index b880878..3e400ce 100644
+--- a/aucat/afile.c
++++ b/aucat/afile.c
+@@ -743,13 +743,13 @@ afile_au_writehdr(struct afile *f)
+ case 32:
+ fmt = AU_FMT_PCM32;
+ break;
+-#ifdef DEBUG
+ default:
++#ifdef DEBUG
+ log_puts(f->path);
+ log_puts(": wrong precision\n");
+ panic();
+- return 0;
+ #endif
++ return 0;
+ }
+ be32_set(&hdr.fmt, fmt);
+ be32_set(&hdr.rate, f->rate);
+diff --git a/sndiod/listen.c b/sndiod/listen.c
+index 54c9684..c87f600 100644
+--- a/sndiod/listen.c
++++ b/sndiod/listen.c
+@@ -254,16 +254,20 @@ listen_in(void *arg)
+ return;
+ }
+ if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1) {
++#ifdef DEBUG
+ file_log(f->file);
+ log_puts(": failed to set non-blocking mode\n");
++#endif
+ goto bad_close;
+ }
+ if (f->path == NULL) {
+ opt = 1;
+ if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
+ &opt, sizeof(int)) == -1) {
++#ifdef DEBUG
+ file_log(f->file);
+ log_puts(": failed to set TCP_NODELAY flag\n");
++#endif
+ goto bad_close;
+ }
+ }
+--
+2.29.2
+
diff --git a/pkg/sndio/patch/0002-aucat-Use-unsigned-char-for-wav_guid-to-prevent-over.patch b/pkg/sndio/patch/0002-aucat-Use-unsigned-char-for-wav_guid-to-prevent-over.patch
@@ -0,0 +1,26 @@
+From 3ae08254ba1f5555e0bfcf71be12d67a3ea2a1b5 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Thu, 5 Nov 2020 00:58:34 -0800
+Subject: [PATCH] aucat: Use unsigned char for wav_guid to prevent overflow
+
+0x80 is not representable as char.
+---
+ aucat/afile.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/aucat/afile.c b/aucat/afile.c
+index 3e400ce..f1188b5 100644
+--- a/aucat/afile.c
++++ b/aucat/afile.c
+@@ -135,7 +135,7 @@ char wav_id_riff[4] = {'R', 'I', 'F', 'F'};
+ char wav_id_wave[4] = {'W', 'A', 'V', 'E'};
+ char wav_id_data[4] = {'d', 'a', 't', 'a'};
+ char wav_id_fmt[4] = {'f', 'm', 't', ' '};
+-char wav_guid[14] = {
++unsigned char wav_guid[14] = {
+ 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x00, 0x80, 0x00,
+ 0x00, 0xAA, 0x00, 0x38,
+--
+2.29.2
+
diff --git a/pkg/sndio/src b/pkg/sndio/src
@@ -0,0 +1 @@
+Subproject commit 97413ec61430ce999d3e6fa0e1880ec01d61f9df
diff --git a/pkg/sndio/ver b/pkg/sndio/ver
@@ -0,0 +1 @@
+1.7.0 r0