pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
wip/pcaudiolib: Add code to achieve the hardcoded latency in netbsd.c and clean up
Module Name: pkgsrc-wip
Committed By: adr <adr%sdf.org@localhost>
Pushed By: adr
Date: Tue Jan 30 02:09:20 2024 +0000
Changeset: 83a39bdc34d4138d4b5c623526b14b31ab27807f
Modified Files:
pcaudiolib/COMMIT_MSG
pcaudiolib/Makefile
pcaudiolib/distinfo
pcaudiolib/options.mk
pcaudiolib/patches/patch-Makefile.am
pcaudiolib/patches/patch-configure.ac
pcaudiolib/patches/patch-src_audio.c
pcaudiolib/patches/patch-src_audio__priv.h
sonic/buildlink3.mk
Added Files:
pcaudiolib/patches/patch-src_netbsd.c
Removed Files:
pcaudiolib/patches/patch-src_sun.c
Log Message:
wip/pcaudiolib: Add code to achieve the hardcoded latency in netbsd.c and clean up
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=83a39bdc34d4138d4b5c623526b14b31ab27807f
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
pcaudiolib/COMMIT_MSG | 2 +-
pcaudiolib/Makefile | 14 ++
pcaudiolib/distinfo | 10 +-
pcaudiolib/options.mk | 10 +-
pcaudiolib/patches/patch-Makefile.am | 6 +-
pcaudiolib/patches/patch-configure.ac | 20 +--
pcaudiolib/patches/patch-src_audio.c | 4 +-
pcaudiolib/patches/patch-src_audio__priv.h | 24 +++-
pcaudiolib/patches/patch-src_netbsd.c | 203 +++++++++++++++++++++++++++++
pcaudiolib/patches/patch-src_sun.c | 202 ----------------------------
sonic/buildlink3.mk | 4 +-
11 files changed, 260 insertions(+), 239 deletions(-)
diffs:
diff --git a/pcaudiolib/COMMIT_MSG b/pcaudiolib/COMMIT_MSG
index 9696971183..b8337f0886 100644
--- a/pcaudiolib/COMMIT_MSG
+++ b/pcaudiolib/COMMIT_MSG
@@ -1,3 +1,3 @@
audio/pcaudiolib: Add pcaudiolib version 1.2
-Packaged in wip by adr
\ No newline at end of file
+Packaged in wip by adr
diff --git a/pcaudiolib/Makefile b/pcaudiolib/Makefile
index a81940317a..968cb3772c 100644
--- a/pcaudiolib/Makefile
+++ b/pcaudiolib/Makefile
@@ -16,6 +16,20 @@ 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
diff --git a/pcaudiolib/distinfo b/pcaudiolib/distinfo
index a655b2fd98..c0271ca0a1 100644
--- a/pcaudiolib/distinfo
+++ b/pcaudiolib/distinfo
@@ -3,8 +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) = 88238b7703d6ced3f7ed0934d507364d174941c3
-SHA1 (patch-src_audio.c) = b15ab14dac93cf10a282e488a17585f2999e58fe
-SHA1 (patch-src_audio__priv.h) = d9712a2d0a66e4f4f96ca8f8de4020beeffac828
-SHA1 (patch-src_sun.c) = f6f83d11f39f8c6d43894210813dcd5f551aa8a4
+SHA1 (patch-Makefile.am) = 3b43eb33eedcc72e5db3fd979b1ed063027e35fa
+SHA1 (patch-configure.ac) = b63548a43ba29e090533d1465917241afdfcfc06
+SHA1 (patch-src_audio.c) = 60151f3351d2edba425f2e83947c1177bde46c50
+SHA1 (patch-src_audio__priv.h) = 7c99cffc279d31b00deadd0a4690627bd7331863
+SHA1 (patch-src_netbsd.c) = b188ed04fef7aa55a5e41c5c8d54aa7c9cdb69db
diff --git a/pcaudiolib/options.mk b/pcaudiolib/options.mk
index 8d948e8485..6da95636de 100644
--- a/pcaudiolib/options.mk
+++ b/pcaudiolib/options.mk
@@ -2,19 +2,11 @@
PKG_OPTIONS_VAR= PKG_OPTIONS.pcaudiolib
-PKG_SUPPORTED_OPTIONS+= alsa pulseaudio sun
+PKG_SUPPORTED_OPTIONS+= alsa pulseaudio
PKG_SUGGESTED_OPTIONS.Linux+= alsa
-PKG_SUGGESTED_OPTIONS.NetBSD+= sun
.include "../../mk/bsd.options.mk"
-.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"
CONFIGURE_ARGS+= --with-alsa
diff --git a/pcaudiolib/patches/patch-Makefile.am b/pcaudiolib/patches/patch-Makefile.am
index ec83ed2649..3e5717bb67 100644
--- a/pcaudiolib/patches/patch-Makefile.am
+++ b/pcaudiolib/patches/patch-Makefile.am
@@ -9,8 +9,8 @@ Add sun.c to the source list when Sun audio is enabled
src/TPCircularBuffer/TPCircularBuffer.podspec
endif
+
-+# Sun audio support
-+if HAVE_SUN
++# NetBSD audio support
++if HAVE_NETBSD
+src_libpcaudio_la_SOURCES += \
-+ src/sun.c
++ src/netbsd.c
+endif
diff --git a/pcaudiolib/patches/patch-configure.ac b/pcaudiolib/patches/patch-configure.ac
index 732c2deba3..d545dab0ef 100644
--- a/pcaudiolib/patches/patch-configure.ac
+++ b/pcaudiolib/patches/patch-configure.ac
@@ -8,27 +8,27 @@ Add Sun audio support
fi
dnl ================================================================
-+dnl Sun checks.
++dnl NetBSD checks.
+dnl ================================================================
+
-+AC_ARG_WITH([sun],
-+ [AS_HELP_STRING([--with-sun], [support for Sun audio output @<:@default=no@:>@])],
++AC_ARG_WITH([netbsd],
++ [AS_HELP_STRING([--with-netbsd], [support for NetBSD audio output @<:@default=no@:>@])],
+ [])
+
-+if test "$with_sun" = "no"; then
-+ echo "Disabling Sun audio output support"
-+ have_sun=no
++if test "$with_netbsd" = "no"; then
++ echo "Disabling NetBSD audio output support"
++ have_netbsd=no
+else
+ case $host_os in
+ *netbsd*)
-+ have_sun=yes
++ have_netbsd=yes
+ ;;
+ *)
-+ have_sun=no
++ have_netbsd=no
+ ;;
+ esac
+fi
-+AM_CONDITIONAL([HAVE_SUN], [test "x${have_sun}" = "xyes"])
++AM_CONDITIONAL([HAVE_NETBSD], [test "x${have_netbsd}" = "xyes"])
+
+dnl ================================================================
dnl Generate output.
@@ -38,5 +38,5 @@ Add Sun audio support
QSA support: ${have_qsa}
Coreaudio support: ${have_coreaudio}
OSS support: ${have_oss}
-+ Sun support: ${have_sun}
++ NetBSD support: ${have_netbsd}
])
diff --git a/pcaudiolib/patches/patch-src_audio.c b/pcaudiolib/patches/patch-src_audio.c
index 3bde6a0cde..16963466e3 100644
--- a/pcaudiolib/patches/patch-src_audio.c
+++ b/pcaudiolib/patches/patch-src_audio.c
@@ -10,8 +10,8 @@ Add Sun audio support
return object;
-
+#else
-+#if defined(_SUNAUDIO)
-+ if ((object = create_sun_object(device, application_name, description)) != NULL)
++#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)
diff --git a/pcaudiolib/patches/patch-src_audio__priv.h b/pcaudiolib/patches/patch-src_audio__priv.h
index ad98dc830d..1e33f3b088 100644
--- a/pcaudiolib/patches/patch-src_audio__priv.h
+++ b/pcaudiolib/patches/patch-src_audio__priv.h
@@ -4,15 +4,29 @@ 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);
+@@ -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_sun_object(const char *device,
++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
diff --git a/pcaudiolib/patches/patch-src_netbsd.c b/pcaudiolib/patches/patch-src_netbsd.c
new file mode 100644
index 0000000000..1a8e9dcc35
--- /dev/null
+++ b/pcaudiolib/patches/patch-src_netbsd.c
@@ -0,0 +1,203 @@
+$NetBSD$
+
+--- src/netbsd.c.orig 2024-01-30 01:47:27.652017641 +0000
++++ src/netbsd.c
+@@ -0,0 +1,198 @@
++/* 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;
++ if (ioctl(self->fd, AUDIO_GETINFO, &audioinfo) == -1)
++ goto error;
++ 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;
++ /* Use the high and low water marks to achieve the desired latency (LATENCY is in ms) */
++ audioinfo.hiwat = (rate * channels * audioinfo.play.precision * LATENCY) / (1000 * audioinfo.blocksize);
++ audioinfo.lowat = (audioinfo.hiwat * 70) / 100;
++ if (ioctl(self->fd, AUDIO_SETINFO, &audioinfo) == -1)
++ goto error;
++ ioctl(self->fd, AUDIO_GETINFO, &audioinfo);
++ 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;
++}
diff --git a/pcaudiolib/patches/patch-src_sun.c b/pcaudiolib/patches/patch-src_sun.c
deleted file mode 100644
index 7f6eb806cd..0000000000
--- a/pcaudiolib/patches/patch-src_sun.c
+++ /dev/null
@@ -1,202 +0,0 @@
-$NetBSD$
-
-Add Sun audio support
-
---- src/sun.c.orig 2024-01-26 01:42:30.586543911 +0000
-+++ src/sun.c
-@@ -0,0 +1,195 @@
-+/* 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_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 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;
-+}
diff --git a/sonic/buildlink3.mk b/sonic/buildlink3.mk
index 9abba908d9..b0998fa6d9 100644
--- a/sonic/buildlink3.mk
+++ b/sonic/buildlink3.mk
@@ -5,8 +5,8 @@ BUILDLINK_TREE+= sonic
.if !defined(SONIC_BUILDLINK3_MK)
SONIC_BUILDLINK3_MK:=
-BUILDLINK_API_DEPENDS.sonic+= sonic>=0.2.0
-BUILDLINK_ABI_DEPENDS.sonic+= sonic>=0.2.0
+BUILDLINK_API_DEPENDS.sonic+= sonic>=0.0.0.225
+BUILDLINK_ABI_DEPENDS.sonic+= sonic>=0.0.0.225
BUILDLINK_PKGSRCDIR.sonic?= ../../audio/sonic
.endif # SONIC_BUILDLINK3_MK
Home |
Main Index |
Thread Index |
Old Index