pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

wip/pcaudiolib: Add sun audio support, package prepared to be included in pkgsrc



Module Name:	pkgsrc-wip
Committed By:	adr <adr%sdf.org@localhost>
Pushed By:	adr
Date:		Thu Jan 25 21:42:03 2024 +0000
Changeset:	63140e6973887312595628ff5c30ef77a5e37e61

Modified Files:
	pcaudiolib/Makefile
	pcaudiolib/distinfo
	pcaudiolib/options.mk
Added Files:
	pcaudiolib/COMMIT_MSG
	pcaudiolib/patches/patch-Makefile.am
	pcaudiolib/patches/patch-configure.ac
	pcaudiolib/patches/patch-src_audio.c
	pcaudiolib/patches/patch-src_audio__priv.h
	pcaudiolib/patches/patch-src_sun.c

Log Message:
wip/pcaudiolib: Add sun audio support, package prepared to be included in pkgsrc

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=63140e6973887312595628ff5c30ef77a5e37e61

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 pcaudiolib/COMMIT_MSG                      |   1 +
 pcaudiolib/Makefile                        |   7 +-
 pcaudiolib/distinfo                        |   5 +
 pcaudiolib/options.mk                      |  10 +-
 pcaudiolib/patches/patch-Makefile.am       |  16 +++
 pcaudiolib/patches/patch-configure.ac      |  42 ++++++
 pcaudiolib/patches/patch-src_audio.c       |  25 ++++
 pcaudiolib/patches/patch-src_audio__priv.h |  18 +++
 pcaudiolib/patches/patch-src_sun.c         | 207 +++++++++++++++++++++++++++++
 9 files changed, 327 insertions(+), 4 deletions(-)

diffs:
diff --git a/pcaudiolib/COMMIT_MSG b/pcaudiolib/COMMIT_MSG
new file mode 100644
index 0000000000..67e50ec5a9
--- /dev/null
+++ b/pcaudiolib/COMMIT_MSG
@@ -0,0 +1 @@
+audio/pcaudiolib: Add pcaudiolib version 1.2
diff --git a/pcaudiolib/Makefile b/pcaudiolib/Makefile
index 14a09c7d20..a81940317a 100644
--- a/pcaudiolib/Makefile
+++ b/pcaudiolib/Makefile
@@ -1,9 +1,9 @@
 # $NetBSD$
 
-GITHUB_PROJECT=	pcaudiolib
 DISTNAME=	pcaudiolib-1.2
 CATEGORIES=	audio
 MASTER_SITES=	${MASTER_SITE_GITHUB:=espeak-ng/}
+GITHUB_PROJECT=	pcaudiolib
 GITHUB_RELEASE=	1.2
 
 MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
@@ -14,7 +14,7 @@ LICENSE=	gnu-gpl-v3
 GNU_CONFIGURE=	yes
 USE_LIBTOOL=	yes
 USE_LANGUAGES=	c c++
-USE_TOOLS+=	pkg-config
+USE_TOOLS+=	automake autoconf autoreconf pkg-config
 
 .include "../../mk/oss.buildlink3.mk"
 .if ${OSS_TYPE} != "none"
@@ -25,5 +25,8 @@ SUBST_SED.oss=          -e s,/dev/dsp,${DEVOSSAUDIO},g
 SUBST_MESSAGE.oss=      Fixing hardcoded audio device.
 .endif
 
+pre-configure:
+	set -e; cd ${WRKSRC} && autoreconf -fi
+
 .include "options.mk"
 .include "../../mk/bsd.pkg.mk"
diff --git a/pcaudiolib/distinfo b/pcaudiolib/distinfo
index 35211f886b..08e811b09e 100644
--- a/pcaudiolib/distinfo
+++ b/pcaudiolib/distinfo
@@ -3,3 +3,8 @@ $NetBSD$
 BLAKE2s (pcaudiolib-1.2.tar.gz) = 11dc27e944fb2edba51c0b4f1da100e7279e44e24821941e3fdd222c85b2da94
 SHA512 (pcaudiolib-1.2.tar.gz) = 803e8c36646f780b9e9a98600092af366ad47ecf9cb447b9b6c82b75eb316ee65674832fc0cbfa56ee4d508ae1d0f69890f5885817e6df3e2ecef54571b936d6
 Size (pcaudiolib-1.2.tar.gz) = 377066 bytes
+SHA1 (patch-Makefile.am) = 880ffb94a684952451b40aa34db94300119cbeeb
+SHA1 (patch-configure.ac) = 4e62afeab13d00de11fa80c4f1ff47aff20acb6b
+SHA1 (patch-src_audio.c) = b15ab14dac93cf10a282e488a17585f2999e58fe
+SHA1 (patch-src_audio__priv.h) = d9712a2d0a66e4f4f96ca8f8de4020beeffac828
+SHA1 (patch-src_sun.c) = 4e713a2157cff64420b1b7b38720a855757f5f0a
diff --git a/pcaudiolib/options.mk b/pcaudiolib/options.mk
index 7b350f6798..8d948e8485 100644
--- a/pcaudiolib/options.mk
+++ b/pcaudiolib/options.mk
@@ -2,12 +2,18 @@
 
 PKG_OPTIONS_VAR=		PKG_OPTIONS.pcaudiolib
 
-PKG_SUPPORTED_OPTIONS+=		alsa pulseaudio
+PKG_SUPPORTED_OPTIONS+=		alsa pulseaudio sun
 PKG_SUGGESTED_OPTIONS.Linux+=	alsa
+PKG_SUGGESTED_OPTIONS.NetBSD+=	sun
 
 .include "../../mk/bsd.options.mk"
 
-PLIST_VARS+=	${PKG_SUPPORTED_OPTIONS}
+.if !empty(PKG_OPTIONS:Msun)
+CONFIGURE_ARGS+=	--with-sun
+CFLAGS+=		-D_SUNAUDIO
+.else
+CONFIGURE_ARGS+=	--without-sun
+.endif
 
 .if !empty(PKG_OPTIONS:Malsa)
 .  include "../../audio/alsa-lib/buildlink3.mk"
diff --git a/pcaudiolib/patches/patch-Makefile.am b/pcaudiolib/patches/patch-Makefile.am
new file mode 100644
index 0000000000..ec83ed2649
--- /dev/null
+++ b/pcaudiolib/patches/patch-Makefile.am
@@ -0,0 +1,16 @@
+$NetBSD$
+
+Add sun.c to the source list when Sun audio is enabled
+
+--- Makefile.am.orig	2018-03-14 09:47:45.000000000 +0000
++++ Makefile.am
+@@ -90,3 +90,9 @@ EXTRA_DIST += \
+ 	src/TPCircularBuffer/README.markdown \
+ 	src/TPCircularBuffer/TPCircularBuffer.podspec
+ endif
++
++# Sun audio support
++if HAVE_SUN
++src_libpcaudio_la_SOURCES += \
++	src/sun.c
++endif
diff --git a/pcaudiolib/patches/patch-configure.ac b/pcaudiolib/patches/patch-configure.ac
new file mode 100644
index 0000000000..37c0896559
--- /dev/null
+++ b/pcaudiolib/patches/patch-configure.ac
@@ -0,0 +1,42 @@
+$NetBSD$
+
+Add Sun audio support
+
+--- configure.ac.orig	2021-07-30 12:08:56.000000000 +0000
++++ configure.ac
+@@ -152,6 +152,29 @@ else
+ fi
+ 
+ dnl ================================================================
++dnl Sun checks.
++dnl ================================================================
++
++AC_ARG_WITH([sun],
++    [AS_HELP_STRING([--with-sun], [support for Sun audio output @<:@default=yes@:>@])],
++    [])
++
++if test "$with_sun" = "no"; then
++    echo "Disabling Sun audio output support"
++    have_sun=no
++else
++    case $host_os in
++        *netbsd*)
++            have_sun=yes
++	    ;;
++        *)
++            have_sun=no
++            ;;
++    esac
++fi
++AM_CONDITIONAL([HAVE_SUN], [test "x${have_sun}" = "xyes"])
++
++dnl ================================================================
+ dnl Generate output.
+ dnl ================================================================
+ 
+@@ -172,4 +195,5 @@ AC_MSG_NOTICE([
+ 	QSA support:                   ${have_qsa}
+ 	Coreaudio support:             ${have_coreaudio} 
+ 	OSS support:                   ${have_oss}
++	Sun support:                   ${have_sun}
+ ])
diff --git a/pcaudiolib/patches/patch-src_audio.c b/pcaudiolib/patches/patch-src_audio.c
new file mode 100644
index 0000000000..3bde6a0cde
--- /dev/null
+++ b/pcaudiolib/patches/patch-src_audio.c
@@ -0,0 +1,25 @@
+$NetBSD$
+
+Add Sun audio support
+
+--- src/audio.c.orig	2017-01-08 13:01:50.000000000 +0000
++++ src/audio.c
+@@ -94,7 +94,10 @@ create_audio_device_object(const char *d
+ #if defined(__APPLE__)
+ 	if ((object = create_coreaudio_object(device, application_name, description)) != NULL)
+ 		return object;
+-
++#else
++#if defined(_SUNAUDIO)       
++	if ((object = create_sun_object(device, application_name, description)) != NULL)
++		return object;
+ #else
+ 	if ((object = create_pulseaudio_object(device, application_name, description)) != NULL)
+ 		return object;
+@@ -106,5 +109,6 @@ create_audio_device_object(const char *d
+ 		return object;
+ #endif
+ #endif
++#endif
+ 	return NULL;
+ }
diff --git a/pcaudiolib/patches/patch-src_audio__priv.h b/pcaudiolib/patches/patch-src_audio__priv.h
new file mode 100644
index 0000000000..ad98dc830d
--- /dev/null
+++ b/pcaudiolib/patches/patch-src_audio__priv.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+Add Sun audio support
+
+--- src/audio_priv.h.orig	2021-07-30 08:54:26.000000000 +0000
++++ src/audio_priv.h
+@@ -115,6 +115,11 @@ create_oss_object(const char *device,
+                   const char *application_name,
+                   const char *description);
+ 
++struct audio_object *
++create_sun_object(const char *device,
++                  const char *application_name,
++                  const char *description);
++
+ #endif
+ #endif
+ 
diff --git a/pcaudiolib/patches/patch-src_sun.c b/pcaudiolib/patches/patch-src_sun.c
new file mode 100644
index 0000000000..03637074f0
--- /dev/null
+++ b/pcaudiolib/patches/patch-src_sun.c
@@ -0,0 +1,207 @@
+$NetBSD$
+
+Add Sun audio support
+
+--- src/sun.c.orig	2024-01-25 07:46:34.728325542 +0000
++++ src/sun.c
+@@ -0,0 +1,200 @@
++/* Sun Output.
++ *
++ * Based on Oss Output by Reece H. Dunn
++ *
++ * This file is part of pcaudiolib.
++ *
++ * pcaudiolib is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation, either version 3 of the License, or
++ * (at your option) any later version.
++ *
++ * pcaudiolib is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with pcaudiolib.  If not, see <http://www.gnu.org/licenses/>.
++ */
++
++#include "config.h"
++#include "audio_priv.h"
++
++#include <sys/audioio.h>
++
++#include <errno.h>
++#include <fcntl.h>
++#include <string.h>
++#include <stdio.h>
++#include <sys/ioctl.h>
++#include <unistd.h>
++
++struct sun_object
++{
++	struct audio_object vtable;
++	int fd;
++	int ctlfd;
++	char *device;
++
++};
++
++#define to_sun_object(object) container_of(object, struct sun_object, vtable)
++
++int
++sun_object_open(struct audio_object *object,
++                enum audio_object_format format,
++                uint32_t rate,
++                uint8_t channels)
++{
++	struct sun_object *self = to_sun_object(object);
++		
++	if (self->fd != -1)
++		return EEXIST;
++
++	struct aformat_sun
++	{
++		int audio_object_format;
++		int sun_format;
++		int sun_precision;
++	};
++	struct aformat_sun aformat_sun_tbl[] = {
++		{AUDIO_OBJECT_FORMAT_ALAW, AUDIO_ENCODING_ALAW, 8},
++		{AUDIO_OBJECT_FORMAT_ULAW, AUDIO_ENCODING_ULAW, 8},
++		{AUDIO_OBJECT_FORMAT_S8, AUDIO_ENCODING_SLINEAR, 8},
++		{AUDIO_OBJECT_FORMAT_U8, AUDIO_ENCODING_ULINEAR, 8},
++		{AUDIO_OBJECT_FORMAT_S16LE, AUDIO_ENCODING_SLINEAR_LE, 16},
++		{AUDIO_OBJECT_FORMAT_S16BE, AUDIO_ENCODING_SLINEAR_BE, 16},
++		{AUDIO_OBJECT_FORMAT_U16LE, AUDIO_ENCODING_ULINEAR_LE, 16},
++		{AUDIO_OBJECT_FORMAT_U16BE, AUDIO_ENCODING_ULINEAR_BE, 16},
++		{AUDIO_OBJECT_FORMAT_S18LE, AUDIO_ENCODING_SLINEAR_LE, 18},
++		{AUDIO_OBJECT_FORMAT_S18BE, AUDIO_ENCODING_SLINEAR_BE, 18},
++		{AUDIO_OBJECT_FORMAT_U18LE, AUDIO_ENCODING_ULINEAR_LE, 18},
++		{AUDIO_OBJECT_FORMAT_U18BE, AUDIO_ENCODING_ULINEAR_BE, 18},
++		{AUDIO_OBJECT_FORMAT_S20LE, AUDIO_ENCODING_SLINEAR_LE, 20},
++		{AUDIO_OBJECT_FORMAT_S20BE, AUDIO_ENCODING_SLINEAR_BE, 20},
++		{AUDIO_OBJECT_FORMAT_U20LE, AUDIO_ENCODING_ULINEAR_LE, 20},
++		{AUDIO_OBJECT_FORMAT_U20BE, AUDIO_ENCODING_ULINEAR_BE, 20},
++		{AUDIO_OBJECT_FORMAT_S24LE, AUDIO_ENCODING_SLINEAR_LE, 24},
++		{AUDIO_OBJECT_FORMAT_S24BE, AUDIO_ENCODING_SLINEAR_BE, 24},
++		{AUDIO_OBJECT_FORMAT_U24LE, AUDIO_ENCODING_ULINEAR_LE, 24},
++		{AUDIO_OBJECT_FORMAT_U24BE, AUDIO_ENCODING_ULINEAR_BE, 24},
++		{AUDIO_OBJECT_FORMAT_S24_32LE, AUDIO_ENCODING_SLINEAR_LE, 32},
++		{AUDIO_OBJECT_FORMAT_S24_32BE, AUDIO_ENCODING_SLINEAR_BE, 32},
++		{AUDIO_OBJECT_FORMAT_U24_32LE, AUDIO_ENCODING_ULINEAR_LE, 32},
++		{AUDIO_OBJECT_FORMAT_U24_32BE, AUDIO_ENCODING_ULINEAR_BE, 32},
++		{AUDIO_OBJECT_FORMAT_S32LE, AUDIO_ENCODING_SLINEAR_LE, 32},
++		{AUDIO_OBJECT_FORMAT_S32BE, AUDIO_ENCODING_SLINEAR_BE, 32},
++		{AUDIO_OBJECT_FORMAT_U32LE, AUDIO_ENCODING_ULINEAR_LE, 32},
++		{AUDIO_OBJECT_FORMAT_U32BE, AUDIO_ENCODING_ULINEAR_BE, 32},
++		{AUDIO_OBJECT_FORMAT_ADPCM, AUDIO_ENCODING_ADPCM, 8},
++		{AUDIO_OBJECT_FORMAT_AC3, AUDIO_ENCODING_AC3, 32},
++	};
++#define SUNFORMATS (sizeof(aformat_sun_tbl)/sizeof(aformat_sun_tbl[0]))
++	int i;
++	for(i=0; i < SUNFORMATS; i++)
++		if(aformat_sun_tbl[i].audio_object_format == format)
++			break;
++	if(i >= SUNFORMATS)
++		return EINVAL;
++
++	int data;
++	audio_info_t audioinfo;
++	if ((self->fd = open(self->device ? self->device : "/dev/audio", O_WRONLY, 0)) == -1)
++		return errno;
++	AUDIO_INITINFO(&audioinfo);
++	audioinfo.play.sample_rate = rate;
++	audioinfo.play.channels = channels;
++	audioinfo.play.precision = aformat_sun_tbl[i].sun_precision;
++	audioinfo.play.encoding = aformat_sun_tbl[i].sun_format;	
++	if (ioctl(self->fd, AUDIO_SETINFO, &audioinfo) == -1)
++		goto error;
++	return 0;
++error:
++	data = errno;
++	close(self->fd);
++	self->fd = -1;
++	return data;
++}
++
++void
++sun_object_close(struct audio_object *object)
++{
++	struct sun_object *self = to_sun_object(object);
++
++	if (self->fd == -1) {
++		close(self->fd);
++		self->fd = -1;
++	}
++}
++
++void
++sun_object_destroy(struct audio_object *object)
++{
++	struct sun_object *self = to_sun_object(object);
++
++	free(self->device);
++	free(self);
++}
++
++int
++sun_object_drain(struct audio_object *object)
++{
++	struct sun_object *self = to_sun_object(object);
++
++	if (ioctl(self->fd, AUDIO_DRAIN, NULL) == -1)
++		return errno;
++	return 0;
++}
++
++int
++sun_object_flush(struct audio_object *object)
++{
++	struct sun_object *self = to_sun_object(object);
++
++	if (ioctl(self->fd, AUDIO_FLUSH, NULL) == -1)
++		return errno;
++	return 0;
++}
++
++int
++sun_object_write(struct audio_object *object,
++                 const void *data,
++                 size_t bytes)
++{
++	struct sun_object *self = to_sun_object(object);
++
++	if (write(self->fd, data, bytes) == -1)
++		return errno;
++	return 0;
++}
++
++const char *
++sun_object_strerror(struct audio_object *object,
++                    int error)
++{
++	return strerror(error);
++}
++
++struct audio_object *
++create_sun_object(const char *device,
++                  const char *application_name,
++                  const char *description)
++{
++	struct sun_object *self = malloc(sizeof(struct sun_object));
++	if (!self)
++		return NULL;
++
++	self->fd = -1;
++	self->device = device ? strdup(device) : NULL;
++
++	self->vtable.open = sun_object_open;
++	self->vtable.close = sun_object_close;
++	self->vtable.destroy = sun_object_destroy;
++	self->vtable.write = sun_object_write;
++	self->vtable.drain = sun_object_drain;
++	self->vtable.flush = sun_object_flush;
++	self->vtable.strerror = sun_object_strerror;
++
++	return &self->vtable;
++}


Home | Main Index | Thread Index | Old Index