summaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authornia <nia@pkgsrc.org>2020-05-28 19:30:45 +0000
committernia <nia@pkgsrc.org>2020-05-28 19:30:45 +0000
commit64904eb80296ef4e634c5bbda4b425f1dd932163 (patch)
tree188954b0b54d5de3d4cfc030e85276ecb5ecb6d2 /audio
parent76619d6cec88c7e435a6f186a96fa0b7bc0c7d20 (diff)
downloadpkgsrc-64904eb80296ef4e634c5bbda4b425f1dd932163.tar.gz
libao-sun: convert 24-bit samples to 32-bit samples
working around the inability of the netbsd 9 kernel (at least) to handle 24-bit lpcm directly in its default configuration. this fixes problems playing 24-bit flac in cmus, at least. with the kernel compiled with AUDIO_SUPPORT_LINEAR24 this is not actually necessary and we should maybe consider doing that by default.
Diffstat (limited to 'audio')
-rw-r--r--audio/libao-sun/Makefile3
-rw-r--r--audio/libao/distinfo4
-rw-r--r--audio/libao/patches/patch-src_plugins_sun_ao__sun.c91
3 files changed, 92 insertions, 6 deletions
diff --git a/audio/libao-sun/Makefile b/audio/libao-sun/Makefile
index 856ffd2b6b1..bd21e30c38d 100644
--- a/audio/libao-sun/Makefile
+++ b/audio/libao-sun/Makefile
@@ -1,8 +1,9 @@
-# $NetBSD: Makefile,v 1.11 2019/11/24 00:35:57 nia Exp $
+# $NetBSD: Makefile,v 1.12 2020/05/28 19:30:45 nia Exp $
.include "../../audio/libao/Makefile.common"
PKGNAME= ${DISTNAME:S/libao/libao-sun/}
+PKGREVISION= 1
COMMENT+= (Sun audio plugin)
diff --git a/audio/libao/distinfo b/audio/libao/distinfo
index 525a9cfe4b6..fb963530820 100644
--- a/audio/libao/distinfo
+++ b/audio/libao/distinfo
@@ -1,8 +1,8 @@
-$NetBSD: distinfo,v 1.26 2019/11/24 00:35:56 nia Exp $
+$NetBSD: distinfo,v 1.27 2020/05/28 19:30:45 nia Exp $
SHA1 (libao-1.2.2.tar.gz) = aa2a6ac0df63c702e46477ea5ce4a9b32e0d4306
RMD160 (libao-1.2.2.tar.gz) = d65fa3dc31b591d22bb8a47c71a91615cc1919cf
SHA512 (libao-1.2.2.tar.gz) = d2736d25b60862e7d7469611ce31b1df40a4366ab160e2ff1b46919ae91692d1596c8468e4f016303b306fc3ac1bddc7b727f535a362f403c3fe7c6532e9045a
Size (libao-1.2.2.tar.gz) = 96134 bytes
SHA1 (patch-src_plugins_alsa_ao__alsa.c) = 9047608f232c4e4bfd5e4b3fcac3831750b0eef3
-SHA1 (patch-src_plugins_sun_ao__sun.c) = 6ba6d6ae4311a8a48dd7bb55e33d4516ac68b607
+SHA1 (patch-src_plugins_sun_ao__sun.c) = b1e9b11a4b5211e69172cc3d6418ec8e35d014f2
diff --git a/audio/libao/patches/patch-src_plugins_sun_ao__sun.c b/audio/libao/patches/patch-src_plugins_sun_ao__sun.c
index 7db75365894..8eb7ab0dac9 100644
--- a/audio/libao/patches/patch-src_plugins_sun_ao__sun.c
+++ b/audio/libao/patches/patch-src_plugins_sun_ao__sun.c
@@ -1,15 +1,100 @@
-$NetBSD: patch-src_plugins_sun_ao__sun.c,v 1.1 2019/11/24 00:35:56 nia Exp $
+$NetBSD: patch-src_plugins_sun_ao__sun.c,v 1.2 2020/05/28 19:30:45 nia Exp $
-Fix device selection.
+- Fix device selection on NetBSD.
+- Support 24-bit playback on NetBSD.
--- src/plugins/sun/ao_sun.c.orig 2016-11-14 08:03:30.000000000 +0000
+++ src/plugins/sun/ao_sun.c
-@@ -160,7 +160,7 @@ int ao_plugin_open(ao_device *device, ao
+@@ -78,6 +78,9 @@ typedef struct ao_sun_internal {
+ char *dev;
+ int id;
+ int fd;
++ int linear24;
++ void *convbuf;
++ size_t convbuf_sz;
+ } ao_sun_internal;
+
+
+@@ -160,7 +163,11 @@ int ao_plugin_open(ao_device *device, ao
if(internal->dev==NULL){
char buf[80];
- sprintf(buf,"/dev/sound/%d",internal->id);
++#ifdef __sun
+ snprintf(buf,sizeof(buf),"/dev/audio%d",internal->id);
++#else
++ snprintf(buf,sizeof(buf),"/dev/sound/%d",internal->id);
++#endif
internal->dev=strdup(buf);
}
+@@ -172,7 +179,12 @@ int ao_plugin_open(ao_device *device, ao
+ info.mode = AUMODE_PLAY;
+ #endif
+ info.play.encoding = AUDIO_ENCODING_SLINEAR;
+- info.play.precision = format->bits;
++ if (format->bits == 24) {
++ info.play.precision = 32;
++ internal->linear24 = 1;
++ } else {
++ info.play.precision = format->bits;
++ }
+ info.play.sample_rate = format->rate;
+ info.play.channels = device->output_channels;
+
+@@ -198,8 +210,46 @@ int ao_plugin_play(ao_device *device, co
+ uint_32 num_bytes)
+ {
+ ao_sun_internal *internal = (ao_sun_internal *) device->internal;
++ void *out;
++
++ /* convert 24-bit linear to 32-bit linear for NetBSD compat */
++ if (internal->linear24) {
++ unsigned char *srcp = (unsigned char *)output_samples;
++ size_t nsamples = num_bytes / 3;
++ size_t bufsz = nsamples * 4;
++ sint_32 *outp, temp;
++
++ if (internal->convbuf_sz < bufsz) {
++ internal->convbuf = realloc(internal->convbuf, bufsz);
++ if (!internal->convbuf)
++ return 1;
++ internal->convbuf_sz = bufsz;
++ }
++ outp = internal->convbuf;
++ if (device->driver_byte_format != AO_FMT_BIG) {
++ while (nsamples--) {
++ temp = (((sint_32)srcp[0]) << 8);
++ temp = temp | (((sint_32)srcp[1]) << 16);
++ temp = temp | (((sint_32)srcp[2]) << 24);
++ *(outp++) = temp;
++ srcp += 3;
++ }
++ } else {
++ while (nsamples--) {
++ temp = (((sint_32)srcp[0]) << 24);
++ temp = temp | (((sint_32)srcp[1]) << 16);
++ temp = temp | (((sint_32)srcp[2]) << 8);
++ *(outp++) = temp;
++ srcp += 3;
++ }
++ }
++ num_bytes = bufsz;
++ out = internal->convbuf;
++ } else {
++ out = (void *)output_samples;
++ }
+
+- if (write(internal->fd, output_samples, num_bytes) < 0)
++ if (write(internal->fd, out, num_bytes) < 0)
+ return 0;
+ else
+ return 1;
+@@ -224,6 +274,7 @@ void ao_plugin_device_clear(ao_device *d
+
+ if(internal->dev)
+ free(internal->dev);
++ free(internal->convbuf);
+ free(internal);
+ device->internal=NULL;
+ }