audio/pcaudiolib: Add pcaudiolib version 1.2
Packaged in wip by adr The Portable C Audio Library (pcaudiolib) provides a C API to different audio devices. It supports: ALSA, CoreAudio (Mac OS), OSS and PulseAudio.
This commit is contained in:
parent
432669198d
commit
41f901254a
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.690 2024/02/25 22:00:26 wiz Exp $
|
||||
# $NetBSD: Makefile,v 1.691 2024/02/29 14:15:41 bsiegert Exp $
|
||||
#
|
||||
|
||||
COMMENT= Audio tools, players, and libraries
|
||||
|
@ -359,6 +359,7 @@ SUBDIR+= parlatype
|
|||
SUBDIR+= pavucontrol
|
||||
SUBDIR+= pavucontrol-qt
|
||||
SUBDIR+= pavumeter
|
||||
SUBDIR+= pcaudiolib
|
||||
SUBDIR+= pd
|
||||
SUBDIR+= pianobar
|
||||
SUBDIR+= picard
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
The Portable C Audio Library (pcaudiolib) provides a C API to
|
||||
different audio devices. It supports: ALSA, CoreAudio (Mac OS),
|
||||
OSS and PulseAudio.
|
|
@ -0,0 +1,46 @@
|
|||
# $NetBSD: Makefile,v 1.1 2024/02/29 14:15:41 bsiegert Exp $
|
||||
|
||||
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
|
||||
HOMEPAGE= https://github.com/espeak-ng/pcaudiolib/
|
||||
COMMENT= Provides a C API to different audio devices
|
||||
LICENSE= gnu-gpl-v3
|
||||
|
||||
GNU_CONFIGURE= yes
|
||||
USE_LIBTOOL= yes
|
||||
USE_LANGUAGES= c c++
|
||||
USE_TOOLS+= automake autoconf autoreconf pkg-config
|
||||
|
||||
.include "../../mk/bsd.prefs.mk"
|
||||
|
||||
.if ${OPSYS} == "NetBSD"
|
||||
CONFIGURE_ARGS+= --with-netbsd
|
||||
.else
|
||||
CONFIGURE_ARGS+= --without-netbsd
|
||||
.endif
|
||||
|
||||
.if ${OPSYS} == "Darwin"
|
||||
CONFIGURE_ARGS+= --with-coreaudio
|
||||
.else
|
||||
CONFIGURE_ARGS+= --without-coreaudio
|
||||
.endif
|
||||
|
||||
.include "../../mk/oss.buildlink3.mk"
|
||||
.if ${OSS_TYPE} != "none"
|
||||
SUBST_CLASSES+= oss
|
||||
SUBST_STAGE.oss= pre-configure
|
||||
SUBST_FILES.oss= src/oss.c
|
||||
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"
|
|
@ -0,0 +1,3 @@
|
|||
@comment $NetBSD: PLIST,v 1.1 2024/02/29 14:15:41 bsiegert Exp $
|
||||
include/pcaudiolib/audio.h
|
||||
lib/libpcaudio.la
|
|
@ -0,0 +1,26 @@
|
|||
# $NetBSD: buildlink3.mk,v 1.1 2024/02/29 14:15:41 bsiegert Exp $
|
||||
|
||||
BUILDLINK_TREE+= pcaudiolib
|
||||
|
||||
.if !defined(PCAUDIOLIB_BUILDLINK3_MK)
|
||||
PCAUDIOLIB_BUILDLINK3_MK:=
|
||||
|
||||
BUILDLINK_API_DEPENDS.pcaudiolib+= pcaudiolib>=1.2
|
||||
BUILDLINK_ABI_DEPENDS.pcaudiolib+= pcaudiolib>=1.2
|
||||
BUILDLINK_PKGSRCDIR.pcaudiolib?= ../../audio/pcaudiolib
|
||||
BUILDLINK_INCDIRS.pcaudiolib?= include/pcaudiolib
|
||||
|
||||
pkgbase:= pcaudiolib
|
||||
.include "../../mk/pkg-build-options.mk"
|
||||
|
||||
.if ${PKG_BUILD_OPTIONS.pcaudiolib:Malsa}
|
||||
. include "../../audio/alsa-lib/buildlink3.mk"
|
||||
.endif
|
||||
|
||||
.if ${PKG_BUILD_OPTIONS.pcaudiolib:Mpulseaudio}
|
||||
. include "../../audio/pulseaudio/buildlink3.mk"
|
||||
.endif
|
||||
|
||||
.endif # PCAUDIOLIB_BUILDLINK3_MK
|
||||
|
||||
BUILDLINK_TREE+= -pcaudiolib
|
|
@ -0,0 +1,10 @@
|
|||
$NetBSD: distinfo,v 1.1 2024/02/29 14:15:41 bsiegert Exp $
|
||||
|
||||
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) = 98b94b9187db8c10980081fb2db54f4305734a71
|
||||
SHA1 (patch-configure.ac) = f5cfa55793b644572ccb3d26ae82d2699204e894
|
||||
SHA1 (patch-src_audio.c) = c249bf6b0efe3f6b9a6166b3ab7857314d73e297
|
||||
SHA1 (patch-src_audio__priv.h) = d38ff94692362e8e801c9a7f671b8ac46bdf8b21
|
||||
SHA1 (patch-src_netbsd.c) = 96ff1f35bbcee8107b33166a4daad902c9a1e1b9
|
|
@ -0,0 +1,22 @@
|
|||
# $NetBSD: options.mk,v 1.1 2024/02/29 14:15:41 bsiegert Exp $
|
||||
|
||||
PKG_OPTIONS_VAR= PKG_OPTIONS.pcaudiolib
|
||||
|
||||
PKG_SUPPORTED_OPTIONS+= alsa pulseaudio
|
||||
PKG_SUGGESTED_OPTIONS.Linux+= alsa
|
||||
|
||||
.include "../../mk/bsd.options.mk"
|
||||
|
||||
.if !empty(PKG_OPTIONS:Malsa)
|
||||
. include "../../audio/alsa-lib/buildlink3.mk"
|
||||
CONFIGURE_ARGS+= --with-alsa
|
||||
.else
|
||||
CONFIGURE_ARGS+= --without-alsa
|
||||
.endif
|
||||
|
||||
.if !empty(PKG_OPTIONS:Mpulseaudio)
|
||||
. include "../../audio/pulseaudio/buildlink3.mk"
|
||||
CONFIGURE_ARGS+= --with-pulseaudio
|
||||
.else
|
||||
CONFIGURE_ARGS+= --without-pulseaudio
|
||||
.endif
|
|
@ -0,0 +1,16 @@
|
|||
$NetBSD: patch-Makefile.am,v 1.1 2024/02/29 14:15:41 bsiegert Exp $
|
||||
|
||||
Add netbsd.c to the source list when NetBSD native 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
|
||||
+
|
||||
+# NetBSD audio support
|
||||
+if HAVE_NETBSD
|
||||
+src_libpcaudio_la_SOURCES += \
|
||||
+ src/netbsd.c
|
||||
+endif
|
|
@ -0,0 +1,42 @@
|
|||
$NetBSD: patch-configure.ac,v 1.1 2024/02/29 14:15:41 bsiegert Exp $
|
||||
|
||||
Add NetBSD native audio support
|
||||
|
||||
--- configure.ac.orig 2021-07-30 12:08:56.000000000 +0000
|
||||
+++ configure.ac
|
||||
@@ -152,6 +152,29 @@ else
|
||||
fi
|
||||
|
||||
dnl ================================================================
|
||||
+dnl NetBSD checks.
|
||||
+dnl ================================================================
|
||||
+
|
||||
+AC_ARG_WITH([netbsd],
|
||||
+ [AS_HELP_STRING([--with-netbsd], [support for NetBSD audio output @<:@default=no@:>@])],
|
||||
+ [])
|
||||
+
|
||||
+if test "$with_netbsd" = "no"; then
|
||||
+ echo "Disabling NetBSD audio output support"
|
||||
+ have_netbsd=no
|
||||
+else
|
||||
+ case $host_os in
|
||||
+ *netbsd*)
|
||||
+ have_netbsd=yes
|
||||
+ ;;
|
||||
+ *)
|
||||
+ have_netbsd=no
|
||||
+ ;;
|
||||
+ esac
|
||||
+fi
|
||||
+AM_CONDITIONAL([HAVE_NETBSD], [test "x${have_netbsd}" = "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}
|
||||
+ NetBSD support: ${have_netbsd}
|
||||
])
|
|
@ -0,0 +1,25 @@
|
|||
$NetBSD: patch-src_audio.c,v 1.1 2024/02/29 14:15:41 bsiegert Exp $
|
||||
|
||||
Add NetBSD native 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(__NetBSD__)
|
||||
+ if ((object = create_netbsd_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;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
$NetBSD: patch-src_audio__priv.h,v 1.1 2024/02/29 14:15:41 bsiegert Exp $
|
||||
|
||||
Add NetBSD native audio support
|
||||
|
||||
--- src/audio_priv.h.orig 2021-07-30 08:54:26.000000000 +0000
|
||||
+++ src/audio_priv.h
|
||||
@@ -86,6 +86,15 @@ create_xaudio2_object(const char *device
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
+#ifdef __NetBSD__
|
||||
+
|
||||
+struct audio_object *
|
||||
+create_netbsd_object(const char *device,
|
||||
+ const char *application_name,
|
||||
+ const char *description);
|
||||
+
|
||||
+#else
|
||||
+
|
||||
#ifdef __APPLE__
|
||||
|
||||
struct audio_object *
|
||||
@@ -117,7 +126,8 @@ create_oss_object(const char *device,
|
||||
|
||||
#endif
|
||||
#endif
|
||||
-
|
||||
+#endif
|
||||
+
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,200 @@
|
|||
$NetBSD: patch-src_netbsd.c,v 1.1 2024/02/29 14:15:41 bsiegert Exp $
|
||||
|
||||
Add NetBSD native audio support
|
||||
|
||||
--- src/netbsd.c.orig 2024-01-30 02:16:50.046541412 +0000
|
||||
+++ src/netbsd.c
|
||||
@@ -0,0 +1,193 @@
|
||||
+/* Netbsd 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 netbsd_object
|
||||
+{
|
||||
+ struct audio_object vtable;
|
||||
+ int fd;
|
||||
+ int ctlfd;
|
||||
+ char *device;
|
||||
+
|
||||
+};
|
||||
+
|
||||
+#define to_netbsd_object(object) container_of(object, struct netbsd_object, vtable)
|
||||
+
|
||||
+int
|
||||
+netbsd_object_open(struct audio_object *object,
|
||||
+ enum audio_object_format format,
|
||||
+ uint32_t rate,
|
||||
+ uint8_t channels)
|
||||
+{
|
||||
+ struct netbsd_object *self = to_netbsd_object(object);
|
||||
+
|
||||
+ if (self->fd != -1)
|
||||
+ return EEXIST;
|
||||
+
|
||||
+ struct aformat_sun
|
||||
+ {
|
||||
+ int audio_object_format;
|
||||
+ int netbsd_format;
|
||||
+ int netbsd_precision;
|
||||
+ };
|
||||
+ struct aformat_sun aformat_netbsd_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_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},
|
||||
+ };
|
||||
+#define NETBSDFORMATS (sizeof(aformat_netbsd_tbl)/sizeof(aformat_netbsd_tbl[0]))
|
||||
+ int i;
|
||||
+ for(i=0; i < NETBSDFORMATS; i++)
|
||||
+ if(aformat_netbsd_tbl[i].audio_object_format == format)
|
||||
+ break;
|
||||
+ if(i >= NETBSDFORMATS)
|
||||
+ return EINVAL;
|
||||
+
|
||||
+ 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_netbsd_tbl[i].netbsd_precision;
|
||||
+ audioinfo.play.encoding = aformat_netbsd_tbl[i].netbsd_format;
|
||||
+ if (ioctl(self->fd, AUDIO_SETINFO, &audioinfo) == -1)
|
||||
+ goto error;
|
||||
+ return 0;
|
||||
+error:
|
||||
+ close(self->fd);
|
||||
+ self->fd = -1;
|
||||
+ return errno;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+netbsd_object_close(struct audio_object *object)
|
||||
+{
|
||||
+ struct netbsd_object *self = to_netbsd_object(object);
|
||||
+
|
||||
+ if (self->fd != -1) {
|
||||
+ close(self->fd);
|
||||
+ self->fd = -1;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+netbsd_object_destroy(struct audio_object *object)
|
||||
+{
|
||||
+ struct netbsd_object *self = to_netbsd_object(object);
|
||||
+
|
||||
+ free(self->device);
|
||||
+ free(self);
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+netbsd_object_drain(struct audio_object *object)
|
||||
+{
|
||||
+ struct netbsd_object *self = to_netbsd_object(object);
|
||||
+
|
||||
+ if (ioctl(self->fd, AUDIO_DRAIN, NULL) == -1)
|
||||
+ return errno;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+netbsd_object_flush(struct audio_object *object)
|
||||
+{
|
||||
+ struct netbsd_object *self = to_netbsd_object(object);
|
||||
+
|
||||
+ if (ioctl(self->fd, AUDIO_FLUSH, NULL) == -1)
|
||||
+ return errno;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+netbsd_object_write(struct audio_object *object,
|
||||
+ const void *data,
|
||||
+ size_t bytes)
|
||||
+{
|
||||
+ struct netbsd_object *self = to_netbsd_object(object);
|
||||
+
|
||||
+ if (write(self->fd, data, bytes) == -1)
|
||||
+ return errno;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+const char *
|
||||
+netbsd_object_strerror(struct audio_object *object,
|
||||
+ int error)
|
||||
+{
|
||||
+ return strerror(error);
|
||||
+}
|
||||
+
|
||||
+struct audio_object *
|
||||
+create_netbsd_object(const char *device,
|
||||
+ const char *application_name,
|
||||
+ const char *description)
|
||||
+{
|
||||
+ struct netbsd_object *self = malloc(sizeof(struct netbsd_object));
|
||||
+ if (!self)
|
||||
+ return NULL;
|
||||
+
|
||||
+ self->fd = -1;
|
||||
+ self->device = device ? strdup(device) : NULL;
|
||||
+
|
||||
+ self->vtable.open = netbsd_object_open;
|
||||
+ self->vtable.close = netbsd_object_close;
|
||||
+ self->vtable.destroy = netbsd_object_destroy;
|
||||
+ self->vtable.write = netbsd_object_write;
|
||||
+ self->vtable.drain = netbsd_object_drain;
|
||||
+ self->vtable.flush = netbsd_object_flush;
|
||||
+ self->vtable.strerror = netbsd_object_strerror;
|
||||
+
|
||||
+ return &self->vtable;
|
||||
+}
|
Loading…
Reference in New Issue