From 3994eccbaa24de09116d10a56287b3c138a23c00 Mon Sep 17 00:00:00 2001 From: Matheus Date: Thu, 28 May 2026 23:55:24 -0300 Subject: [PATCH] ports: sndio --- install-hooks/sndio | 19 +++++++ patches/sndio/jinx-working-patch.patch | 71 ++++++++++++++++++++++++++ recipes/sndio | 22 ++++++++ service-scripts/sndiod | 11 ++++ source-recipes/sndio | 5 ++ 5 files changed, 128 insertions(+) create mode 100644 install-hooks/sndio create mode 100644 patches/sndio/jinx-working-patch.patch create mode 100644 recipes/sndio create mode 100755 service-scripts/sndiod create mode 100644 source-recipes/sndio diff --git a/install-hooks/sndio b/install-hooks/sndio new file mode 100644 index 00000000..e060b7be --- /dev/null +++ b/install-hooks/sndio @@ -0,0 +1,19 @@ +#!/usr/bin/bash + +set -e + +case "$1" in + pre) + ;; + post) + if ! grep -q '^sndiod:' /etc/group; then + groupadd -r sndiod + fi + + if ! grep -q '^sndiod:' /etc/passwd; then + useradd -r -g sndiod -d /var/empty -s /bin/false -c "sndio daemon" sndiod + fi + ;; +esac + +exit 0 diff --git a/patches/sndio/jinx-working-patch.patch b/patches/sndio/jinx-working-patch.patch new file mode 100644 index 00000000..f9e8524d --- /dev/null +++ b/patches/sndio/jinx-working-patch.patch @@ -0,0 +1,71 @@ +diff --git sndio-clean/configure sndio-workdir/configure +index d36e767..547c8fb 100755 +--- sndio-clean/configure ++++ sndio-workdir/configure +@@ -63,10 +63,20 @@ unset defs # no extra #defines + unset ldadd # no extra libraries (-l options) + unset dev + ++: "${UNAME:=`uname`}" ++ + # + # guess OS-specific parameters + # +-case `uname` in ++case ${UNAME} in ++ Astral) ++ oss=yes ++ ldadd="-lrt -lm" ++ user=sndiod ++ so_link="libsndio.so libsndio.so.\${MAJ} libsndio.so.\${MAJ}.0" ++ so_ldflags="-Wl,-soname=libsndio.so.\${MAJ}" ++ defs='-D_GNU_SOURCE -DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME' ++ ;; + Linux) + alsa=yes + ldadd="-lrt -lm" +diff --git sndio-clean/libsndio/sio_oss.c sndio-workdir/libsndio/sio_oss.c +index 7614497..1fc8ad6 100644 +--- sndio-clean/libsndio/sio_oss.c ++++ sndio-workdir/libsndio/sio_oss.c +@@ -66,15 +66,6 @@ static struct sio_oss_fmt formats[] = { + { AFMT_S24_BE, 24, 3, 1, 0, 1 }, + { AFMT_S24_LE, 24, 3, 1, 1, 0 }, + { AFMT_S24_LE, 24, 3, 1, 1, 1 }, +- { AFMT_U24_BE, 24, 3, 0, 0, 0 }, +- { AFMT_U24_BE, 24, 3, 0, 0, 1 }, +- { AFMT_U24_LE, 24, 3, 0, 1, 0 }, +- { AFMT_U24_LE, 24, 3, 0, 1, 1 }, +- +- { AFMT_S32_BE, 32, 4, 1, 0, 1 }, +- { AFMT_S32_LE, 32, 4, 1, 1, 1 }, +- { AFMT_U32_BE, 32, 4, 0, 0, 1 }, +- { AFMT_U32_LE, 32, 4, 0, 1, 1 }, + }; + + struct sio_oss_hdl { +@@ -147,8 +138,7 @@ sio_oss_getcap(struct sio_hdl *sh, struct sio_cap *cap) + 48000, 64000, 88200, 96000, 192000 + }; + static int afmts[] = { +- AFMT_U8, AFMT_S16_LE, AFMT_S16_BE, AFMT_S24_LE, AFMT_U24_LE, +- AFMT_S32_LE, AFMT_U32_LE ++ AFMT_U8, AFMT_S16_LE, AFMT_S16_BE, AFMT_S24_LE, + }; + struct sio_oss_hdl *hdl = (struct sio_oss_hdl *)sh; + unsigned int nconf = 0; +@@ -287,12 +277,14 @@ sio_oss_getfd(const char *str, unsigned int mode, int nbio) + return -1; + } + ++#ifndef __astral__ + val = 1; + if (ioctl(fd, SNDCTL_DSP_LOW_WATER, &val) == -1) { + DPERROR("sio_oss_start: LOW_WATER"); + close(fd); + return -1; + } ++#endif + return fd; + } + diff --git a/recipes/sndio b/recipes/sndio new file mode 100644 index 00000000..eb5dedfc --- /dev/null +++ b/recipes/sndio @@ -0,0 +1,22 @@ +name=sndio +revision=2 +from_source=sndio +imagedeps="build-essential" +hostdeps="xgcc xbinutils" +deps="base oss shadow" # shadow is here for the post-install hook + +configure() { + cp -rp ${source_dir}/* . + UNAME=Astral ./configure --prefix=${prefix} CFLAGS="-I'${sysroot_dir}/usr/lib/oss/include' ${CFLAGS}" CC=x86_64-astral-gcc +} + +build() { + make -j ${parallelism} +} + +package() { + make install DESTDIR=${dest_dir} + mkdir -p ${dest_dir}/etc/init.d + cp ${base_dir}/service-scripts/sndiod ${dest_dir}/etc/init.d + copy_install_hook +} diff --git a/service-scripts/sndiod b/service-scripts/sndiod new file mode 100755 index 00000000..4d2dc957 --- /dev/null +++ b/service-scripts/sndiod @@ -0,0 +1,11 @@ +#!/sbin/openrc-run + +description="start the sndio audio server" +command=/usr/bin/sndiod +command_args="${sndiod_options}" +retry="${retry:-TERM/5/KILL/5}" + +depend() { + need localmount + after bootmisc +} diff --git a/source-recipes/sndio b/source-recipes/sndio new file mode 100644 index 00000000..bada7a39 --- /dev/null +++ b/source-recipes/sndio @@ -0,0 +1,5 @@ +name=sndio +version=1.10.0 +source_method=tarball +tarball_url="https://sndio.org/sndio-${version}.tar.gz" +tarball_sha512="c35462976a1bffd128eacb185165964dac6b03505255e9ab9a933e24be5ed146cd9ac6995fd7af23247cb9133c010cce0876572db53b783ebabeb563fec7a1cf"