]> git.draconx.ca Git - gentoo-fixes.git/commitdiff
media-sound/apulse: New package with fixed deps.
authorNick Bowler <nbowler@draconx.ca>
Thu, 11 Nov 2021 03:02:25 +0000 (22:02 -0500)
committerNick Bowler <nbowler@draconx.ca>
Thu, 11 Nov 2021 03:02:25 +0000 (22:02 -0500)
I have no idea why the gentoo ebuild blocks alsa-plugins.  They do not
appear to conflict in any manner whatsoever.

media-sound/apulse/Manifest [new file with mode: 0644]
media-sound/apulse/apulse-0.1.13.ebuild [new file with mode: 0644]
media-sound/apulse/files/apulse [new file with mode: 0755]
media-sound/apulse/files/check-key-before-remove.patch [new file with mode: 0644]
media-sound/apulse/files/man.patch [new file with mode: 0644]
media-sound/apulse/files/sdk.patch [new file with mode: 0644]

diff --git a/media-sound/apulse/Manifest b/media-sound/apulse/Manifest
new file mode 100644 (file)
index 0000000..1bee82d
--- /dev/null
@@ -0,0 +1,6 @@
+AUX apulse 488 BLAKE2B 20231c1041e1658e993ecc5f0dbd37f1d7e718aa5095b0bcb18b6c78639da5da29d5aa72fe77c774598d199e8284cceaab9fdb9aa07cf734957fb1c2d8d617c0 SHA512 2b1ebb3d574af2469f50a42e324b3367b5e08d3de00076620ce2133226d544ab2507e6d752ff3ed427319978ab5e1a0e73189368666a5c7f5ed61f1294417228
+AUX check-key-before-remove.patch 1888 BLAKE2B d8bee7f8acac213396d18d44740703746653a57d300c8d86967e83c24b73aca7d8ba5e91e38d7c3683d40c2a520cacb29210e2c1d739bf4b0403199beb9bda81 SHA512 e7edf75cdddc94a433ce387853cc59cfa40ef7fbdc955357141f42133bf9bde4e6528078d75c7d58001ab07dcaf209b0437a92445d770f6cd08f9b919e97caa4
+AUX man.patch 1054 BLAKE2B 37228832250f1c1e06edf79d00a4a4d7d5433f2d9b28ebb10eacb54bcfb7478d9ef64459e87f7f43a94be0b194eba024cde60175fc324ef6dad7a4ef9e2c1db3 SHA512 c2b05dd8c42f79994ae3be5df5ac495e95bfbc14355423faa75b23863418bad4bbc33524e2b86abc9e346678256c1ff454c160ebb5e09f48d466ef99cdfa407c
+AUX sdk.patch 4357 BLAKE2B ad43209ebf78f1f8937bfde54c88034a9c0f426caf62da5aa70b6171e29546af97c374765bed081cdf13827add3d02e5cdb6b30adccaae03318c102dba4cff65 SHA512 f1f743d049c120f3c8d6d1387577b53e9637881d9d5e007c55b4e42feca21b170ee24146c5fb0cc050c3eb1c26659dc6363e673710ae08c76f2844306a1ca01d
+DIST apulse-0.1.13.tar.gz 117369 BLAKE2B 8cf527daf21420a72e46968a3b07ab61029f404a2b6574ac1f08dd40528f3e6e4baf7e38f5914b0c89252e16eec5e8f3722be51e5a61b6a71c683e994740b4bf SHA512 366385ae2304f7ff697ba70951d0753a5b1630310922e3763fd0813a73e0b4088b715135295aa2fa9111b8edcf91d82849dc31346b292b2e9db598bcdd47b007
+EBUILD apulse-0.1.13.ebuild 1619 BLAKE2B e30b9957db3599b9690cad91d92acc73fd1f2b376d01ac5264aa94f4936209cbd36b632201bf5731dd128ed9eddfd425ff668ca71db3c93c7af97f214e99e8c7 SHA512 7bc704cb8eaa519fa4a786d4e91cff40ee47f01beb41474194540aa28922eaf555e48dd64f57ab210df7c346236c09342fc86653bb779dbd9c19f8b1f8531d15
diff --git a/media-sound/apulse/apulse-0.1.13.ebuild b/media-sound/apulse/apulse-0.1.13.ebuild
new file mode 100644 (file)
index 0000000..a9c6348
--- /dev/null
@@ -0,0 +1,70 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+CMAKE_ECLASS=cmake
+inherit multilib cmake-multilib
+
+DESCRIPTION="PulseAudio emulation for ALSA"
+HOMEPAGE="https://github.com/i-rinat/apulse"
+SRC_URI="https://github.com/i-rinat/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="MIT LGPL-2.1"
+SLOT="0"
+KEYWORDS="amd64 ~ppc64 x86"
+
+IUSE="debug sdk test"
+RESTRICT="!test? ( test )"
+
+DEPEND="dev-libs/glib:2[${MULTILIB_USEDEP}]
+       media-libs/alsa-lib[${MULTILIB_USEDEP}]
+       sdk? ( !media-sound/pulseaudio ) "
+RDEPEND=$DEPEND
+
+PATCHES=(
+       "${FILESDIR}/sdk.patch"
+       "${FILESDIR}/check-key-before-remove.patch"
+       "${FILESDIR}/man.patch"
+)
+
+src_prepare() {
+       cmake_src_prepare
+
+       if ! use sdk; then
+               # Ensure all relevant libdirs are added, to support all ABIs
+               DIRS=
+               _add_dir() { DIRS="${EPREFIX}/usr/$(get_libdir)/apulse${DIRS:+:${DIRS}}"; }
+               multilib_foreach_abi _add_dir
+               sed -e "s#@@DIRS@@#${DIRS}#g" "${FILESDIR}"/apulse > "${T}"/apulse || die
+       fi
+}
+
+multilib_src_configure() {
+       local mycmakeargs=(
+               "-DINSTALL_SDK=$(usex sdk)"
+               "-DLOG_TO_STDERR=$(usex debug)"
+               "-DWITH_TRACE=$(usex debug)"
+       )
+       cmake_src_configure
+}
+
+multilib_src_test() {
+       _test() {
+               pushd tests || die
+               cmake -S "${S}/tests" -B . || die
+               emake test_ringbuffer
+               ctest -j "$(makeopts_jobs)" --test-load "$(makeopts_loadavg)" || die
+               popd || die
+       }
+       multilib_foreach_abi _test
+}
+
+multilib_src_install_all() {
+       if ! use sdk; then
+               _install_wrapper() { newbin "${BUILD_DIR}/apulse" "${CHOST}-apulse"; }
+               multilib_foreach_abi _install_wrapper
+               dobin "${T}/apulse"
+       fi
+       einstalldocs
+}
diff --git a/media-sound/apulse/files/apulse b/media-sound/apulse/files/apulse
new file mode 100755 (executable)
index 0000000..32633b2
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Author:  Daniel Campbell <zlg@gentoo.org>
+# License: Creative Commons Public Domain Dedication (CC0 1.0)
+#          <https://creativecommons.org/publicdomain/zero/1.0/>
+
+# apulse needs at least one argument
+if [ $# -lt 1 ]; then
+       echo "Usage: apulse <app-path> [options]"
+       exit
+fi
+
+# Set library path for the application so it'll use apulse. DIRS is
+# replaced by the ebuild to include the correct paths
+LD_LIBRARY_PATH=@@DIRS@@${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} exec "$@"
diff --git a/media-sound/apulse/files/check-key-before-remove.patch b/media-sound/apulse/files/check-key-before-remove.patch
new file mode 100644 (file)
index 0000000..28fe0fc
--- /dev/null
@@ -0,0 +1,54 @@
+From bf146f0d711ce3e48cdc8ba772039d843d590b47 Mon Sep 17 00:00:00 2001
+From: "Miouyouyou (Myy)" <myy@miouyouyou.fr>
+Date: Sun, 20 Oct 2019 05:09:29 +0200
+Subject: [PATCH] stream: Check the key before invoking g_hash_table_remove
+
+Turns out that I hit a bug where pa_stream_unref would
+call g_hash_table_remove with a NULL key.
+
+Thanks for the lightweight and smooth error handling from
+Glib, g_hash_table_remove generated an ABORT call, crashing
+some Unity3D games I was trying to start.
+Now, you also CANNOT call g_hash_table_lookup with a NULL
+key. That also generate a crash... Ugh...
+
+So, yeah, we first check that the key is not 0, then check
+if the key is actually inside the Hash table and THEN remove
+it.
+
+Note, here's my ~/.asoundrc, just in case :
+defaults.pcm.!card Audio
+defaults.ctl.!card Audio
+
+Audio being :
+card 3: Audio [DigiHug USB Audio], device 0: USB Audio [USB Audio]
+  Subdevices: 0/1
+  Subdevice #0: subdevice #0
+card 3: Audio [DigiHug USB Audio], device 1: USB Audio [USB Audio #1]
+  Subdevices: 1/1
+  Subdevice #0: subdevice #0
+
+I'm using a FiiO device for sound output.
+
+Signed-off-by: Miouyouyou (Myy) <myy@miouyouyou.fr>
+---
+ src/apulse-stream.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/apulse-stream.c b/src/apulse-stream.c
+index 84b18bb..1de4885 100644
+--- a/src/apulse-stream.c
++++ b/src/apulse-stream.c
+@@ -1019,7 +1019,11 @@ pa_stream_unref(pa_stream *s)
+     s->ref_cnt--;
+     if (s->ref_cnt == 0) {
+-        g_hash_table_remove(s->c->streams_ht, GINT_TO_POINTER(s->idx));
++        GHashTable * __restrict const streams_ht =
++            s->c->streams_ht;
++        void const * key = GINT_TO_POINTER(s->idx);
++        if (key && g_hash_table_lookup(streams_ht, key))
++            g_hash_table_remove(streams_ht, key);
+         ringbuffer_free(s->rb);
+         free(s->peek_buffer);
+         free(s->write_buffer);
diff --git a/media-sound/apulse/files/man.patch b/media-sound/apulse/files/man.patch
new file mode 100644 (file)
index 0000000..a26e32d
--- /dev/null
@@ -0,0 +1,30 @@
+From 2c2bf366599d957837acbdf54eb300526fc125a1 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
+Date: Tue, 5 May 2020 14:24:52 -0300
+Subject: [PATCH] Add ENVIRONMENT to man-page.
+
+---
+ man/apulse.1 | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/man/apulse.1 b/man/apulse.1
+index cd67cf3..df75c60 100644
+--- a/man/apulse.1
++++ b/man/apulse.1
+@@ -36,6 +36,16 @@ compatibility layer between OSS programs and \fBALSA\fR, \fBapulse\fR was
+ designed to be compatibility layer between PulseAudio applications and
+ \fBALSA\fR.
++.SH ENVIRONMENT
++
++The following environment variables can be used to configure the devices used
++by \fBapulse\fR. Try \fIhw:0,0\fR, \fIplughw:0,0\fR and the like.
++Refer to the ALSA user guide for a full list of device names.
++
++\fIAPULSE_CAPTURE_DEVICE\fR: Can be used to configure the capture device.
++
++\fIAPULSE_PLAYBACK_DEVICE\fR: Can be used to configure the playback device.
++
+ .SH RETURN VALUE
+ \fBapulse\fR is a simple shell wrapper script that calls \fBexec\fR on the
diff --git a/media-sound/apulse/files/sdk.patch b/media-sound/apulse/files/sdk.patch
new file mode 100644 (file)
index 0000000..bc12090
--- /dev/null
@@ -0,0 +1,103 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 072f3b1..5fe6bcd 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,5 +1,6 @@
+ project(apulse)
+ cmake_minimum_required (VERSION 2.8)
++include(GNUInstallDirs)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -fPIC -fvisibility=hidden")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
+@@ -28,6 +29,8 @@ else()
+     include_directories(${PA_INCLUDE_DIRECTORIES})
+ endif()
++set(INSTALL_SDK 0 CACHE BOOLEAN "Install SDK files to build applications with apulse (Pulse Audio headers and pkg-config files) instead of system ones")
++
+ link_directories(${REQ_LIBRARY_DIRS})
+ add_library(trace-helper STATIC
+@@ -72,12 +75,30 @@ target_link_libraries(pulse-simple ${SYMBOLMAP} trace-helper ${REQ_LIBRARIES})
+ add_subdirectory(tests)
+-set(APULSEPATH "${CMAKE_INSTALL_PREFIX}/lib/apulse" CACHE PATH "library installation directory")
+-set(APULSE_SEARCH_PATHS "${APULSEPATH}" CACHE PATH "directory list for LD_LIBRARY_PATH")
+-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/apulse.template"
+-               "${CMAKE_CURRENT_BINARY_DIR}/apulse" @ONLY)
++if (${INSTALL_SDK})
++    set(APULSEPATH "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "library installation directory")
++
++    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/libpulse.pc.in"
++                   "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libpulse.pc" @ONLY)
++    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/libpulse-simple.pc.in"
++                   "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libpulse-simple.pc" @ONLY)
++    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/libpulse-mainloop-glib.pc.in"
++                   "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libpulse-mainloop-glib.pc" @ONLY)
++else()
++    set(APULSEPATH "${CMAKE_INSTALL_LIBDIR}/apulse" CACHE PATH "library installation directory")
++    set(APULSE_SEARCH_PATHS "${CMAKE_INSTALL_PREFIX}/${APULSEPATH}" CACHE PATH "directory list for LD_LIBRARY_PATH")
++
++    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/apulse.template"
++                   "${CMAKE_CURRENT_BINARY_DIR}/apulse" @ONLY)
++endif()
+-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/apulse" DESTINATION bin
+-        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+ install(TARGETS pulse-simple pulse pulse-mainloop-glib DESTINATION "${APULSEPATH}")
+-install(FILES "${CMAKE_SOURCE_DIR}/man/apulse.1" DESTINATION share/man/man1)
++
++if (${INSTALL_SDK})
++    install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty/pulseaudio-headers/pulse" DESTINATION include)
++    install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig" DESTINATION "${CMAKE_INSTALL_LIBDIR}")
++else()
++    install(FILES "${CMAKE_CURRENT_BINARY_DIR}/apulse" DESTINATION bin
++            PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
++    install(FILES "${CMAKE_SOURCE_DIR}/man/apulse.1" DESTINATION share/man/man1)
++endif()
+diff --git a/pkgconfig/libpulse-mainloop-glib.pc.in b/pkgconfig/libpulse-mainloop-glib.pc.in
+new file mode 100644
+index 0000000..957e3b2
+--- /dev/null
++++ b/pkgconfig/libpulse-mainloop-glib.pc.in
+@@ -0,0 +1,9 @@
++libdir=@CMAKE_INSTALL_FULL_LIBDIR@
++includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
++
++Name: libpulse-mainloop-glib
++Description: PulseAudio GLib 2.0 Main Loop Wrapper (apulse)
++Version: 5.0
++Libs: -L${libdir} -lpulse-mainloop-glib -pthread
++Cflags: -I${includedir}
++Requires: glib-2.0
+diff --git a/pkgconfig/libpulse-simple.pc.in b/pkgconfig/libpulse-simple.pc.in
+new file mode 100644
+index 0000000..57d917f
+--- /dev/null
++++ b/pkgconfig/libpulse-simple.pc.in
+@@ -0,0 +1,9 @@
++libdir=@CMAKE_INSTALL_FULL_LIBDIR@
++includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
++
++Name: libpulse-simple
++Description: PulseAudio Simplified Synchronous Client Interface (apulse)
++Version: 5.0
++Libs: -L${libdir} -lpulse-simple -pthread
++Cflags: -I${includedir}
++Requires: glib-2.0
+diff --git a/pkgconfig/libpulse.pc.in b/pkgconfig/libpulse.pc.in
+new file mode 100644
+index 0000000..edcbbd8
+--- /dev/null
++++ b/pkgconfig/libpulse.pc.in
+@@ -0,0 +1,9 @@
++libdir=@CMAKE_INSTALL_FULL_LIBDIR@
++includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
++
++Name: libpulse
++Description: PulseAudio Client Interface (apulse)
++Version: 5.0
++Libs: -L${libdir} -lpulse -pthread
++Cflags: -I${includedir}
++Requires: glib-2.0 alsa