Thu Sep 9 21:42:00 2021 UTC ()
portaudio: Fix playing very short files in Audacity with Sun backend

According to portaudio's own docs, my previous code was correct -
aborting the stream should cause any queued samples to be dropped.
However, audacity seems to be abusing the portaudio API and calling
Abort immediately once it's finished processing the output...


(nia)
diff -r1.33 -r1.34 pkgsrc/audio/portaudio/Makefile
diff -r1.25 -r1.26 pkgsrc/audio/portaudio/distinfo
diff -r1.3 -r1.4 pkgsrc/audio/portaudio/patches/patch-src_hostapi_sun_pa__unix__sun.c

cvs diff -r1.33 -r1.34 pkgsrc/audio/portaudio/Makefile (expand / switch to unified diff)

--- pkgsrc/audio/portaudio/Makefile 2021/09/08 21:04:57 1.33
+++ pkgsrc/audio/portaudio/Makefile 2021/09/09 21:41:59 1.34
@@ -1,18 +1,18 @@ @@ -1,18 +1,18 @@
1# $NetBSD: Makefile,v 1.33 2021/09/08 21:04:57 nia Exp $ 1# $NetBSD: Makefile,v 1.34 2021/09/09 21:41:59 nia Exp $
2 2
3DISTNAME= pa_stable_v190600_20161030 3DISTNAME= pa_stable_v190600_20161030
4PKGNAME= ${DISTNAME:S/^pa_stable_v/portaudio-/1:S/_/./g} 4PKGNAME= ${DISTNAME:S/^pa_stable_v/portaudio-/1:S/_/./g}
5PKGREVISION= 8 5PKGREVISION= 9
6CATEGORIES= audio 6CATEGORIES= audio
7MASTER_SITES= http://www.portaudio.com/archives/ 7MASTER_SITES= http://www.portaudio.com/archives/
8EXTRACT_SUFX= .tgz 8EXTRACT_SUFX= .tgz
9 9
10MAINTAINER= nia@NetBSD.org 10MAINTAINER= nia@NetBSD.org
11HOMEPAGE= http://www.portaudio.com/ 11HOMEPAGE= http://www.portaudio.com/
12COMMENT= Portable cross-platform audio API 12COMMENT= Portable cross-platform audio API
13LICENSE= mit 13LICENSE= mit
14 14
15CONFLICTS+= portaudio-devel-[0-9]* 15CONFLICTS+= portaudio-devel-[0-9]*
16SUPERSEDES+= portaudio-devel-[0-9]* 16SUPERSEDES+= portaudio-devel-[0-9]*
17 17
18WRKSRC= ${WRKDIR}/portaudio 18WRKSRC= ${WRKDIR}/portaudio

cvs diff -r1.25 -r1.26 pkgsrc/audio/portaudio/distinfo (expand / switch to unified diff)

--- pkgsrc/audio/portaudio/distinfo 2021/01/16 21:06:52 1.25
+++ pkgsrc/audio/portaudio/distinfo 2021/09/09 21:41:59 1.26
@@ -1,18 +1,18 @@ @@ -1,18 +1,18 @@
1$NetBSD: distinfo,v 1.25 2021/01/16 21:06:52 reinoud Exp $ 1$NetBSD: distinfo,v 1.26 2021/09/09 21:41:59 nia Exp $
2 2
3SHA1 (pa_stable_v190600_20161030.tgz) = 56c596bba820d90df7d057d8f6a0ec6bf9ab82e8 3SHA1 (pa_stable_v190600_20161030.tgz) = 56c596bba820d90df7d057d8f6a0ec6bf9ab82e8
4RMD160 (pa_stable_v190600_20161030.tgz) = e6e5cd3f3cb7469aa17549c189e445d573567e13 4RMD160 (pa_stable_v190600_20161030.tgz) = e6e5cd3f3cb7469aa17549c189e445d573567e13
5SHA512 (pa_stable_v190600_20161030.tgz) = 7ec692cbd8c23878b029fad9d9fd63a021f57e60c4921f602995a2fca070c29f17a280c7f2da5966c4aad29d28434538452f4c822eacf3a60af59a6dc8e9704c 5SHA512 (pa_stable_v190600_20161030.tgz) = 7ec692cbd8c23878b029fad9d9fd63a021f57e60c4921f602995a2fca070c29f17a280c7f2da5966c4aad29d28434538452f4c822eacf3a60af59a6dc8e9704c
6Size (pa_stable_v190600_20161030.tgz) = 1450572 bytes 6Size (pa_stable_v190600_20161030.tgz) = 1450572 bytes
7SHA1 (patch-Makefile.in) = 28f587f171b4a504e3982e6f8fcf3f148e5aa5c9 7SHA1 (patch-Makefile.in) = 28f587f171b4a504e3982e6f8fcf3f148e5aa5c9
8SHA1 (patch-bindings_cpp_Makefile.am) = bcd45cba537c867ed9b2e20e1468e9f16ed0b3f7 8SHA1 (patch-bindings_cpp_Makefile.am) = bcd45cba537c867ed9b2e20e1468e9f16ed0b3f7
9SHA1 (patch-configure.in) = 9ccc782631a6aaa9e2c7b8390a6b527ead25d0a5 9SHA1 (patch-configure.in) = 9ccc782631a6aaa9e2c7b8390a6b527ead25d0a5
10SHA1 (patch-include_pa__unix__oss.h) = 8e4ede09d5bf730bf8c2e8ca4aca6f700f58f2f7 10SHA1 (patch-include_pa__unix__oss.h) = 8e4ede09d5bf730bf8c2e8ca4aca6f700f58f2f7
11SHA1 (patch-include_portaudio.h) = 9a2e4aeb126056aded5cc49c40cde40e16738757 11SHA1 (patch-include_portaudio.h) = 9a2e4aeb126056aded5cc49c40cde40e16738757
12SHA1 (patch-src_common_pa__front.c) = cdddb6f537f803b55873ad6bfa936a6bff47556d 12SHA1 (patch-src_common_pa__front.c) = cdddb6f537f803b55873ad6bfa936a6bff47556d
13SHA1 (patch-src_common_pa__stream.c) = 58e6ab2a61957208973a59be2f1140abc922f360 13SHA1 (patch-src_common_pa__stream.c) = 58e6ab2a61957208973a59be2f1140abc922f360
14SHA1 (patch-src_common_pa__stream.h) = 94781a9ae79ea1340eea8caadc106416c019cf74 14SHA1 (patch-src_common_pa__stream.h) = 94781a9ae79ea1340eea8caadc106416c019cf74
15SHA1 (patch-src_hostapi_alsa_pa__linux__alsa.c) = 71daf913422f72aa379ae8cc302186800cff7717 15SHA1 (patch-src_hostapi_alsa_pa__linux__alsa.c) = 71daf913422f72aa379ae8cc302186800cff7717
16SHA1 (patch-src_hostapi_oss_pa__unix__oss.c) = 572c48f64104e22e7ae49acc54a26e549e381b5b 16SHA1 (patch-src_hostapi_oss_pa__unix__oss.c) = 572c48f64104e22e7ae49acc54a26e549e381b5b
17SHA1 (patch-src_hostapi_sun_pa__unix__sun.c) = 0a2d26e477bb4c45d56b8d70db5a939911f4cf64 17SHA1 (patch-src_hostapi_sun_pa__unix__sun.c) = bab9b21d35d76afafa06c929bb35954d3870bc0d
18SHA1 (patch-src_os_unix_pa__unix__hostapis.c) = 8cfc7d7aac8f9803e204711ded3d64842913f4fd 18SHA1 (patch-src_os_unix_pa__unix__hostapis.c) = 8cfc7d7aac8f9803e204711ded3d64842913f4fd

cvs diff -r1.3 -r1.4 pkgsrc/audio/portaudio/patches/patch-src_hostapi_sun_pa__unix__sun.c (expand / switch to unified diff)

--- pkgsrc/audio/portaudio/patches/patch-src_hostapi_sun_pa__unix__sun.c 2021/01/16 21:06:52 1.3
+++ pkgsrc/audio/portaudio/patches/patch-src_hostapi_sun_pa__unix__sun.c 2021/09/09 21:42:00 1.4
@@ -1,20 +1,20 @@ @@ -1,20 +1,20 @@
1$NetBSD: patch-src_hostapi_sun_pa__unix__sun.c,v 1.3 2021/01/16 21:06:52 reinoud Exp $ 1$NetBSD: patch-src_hostapi_sun_pa__unix__sun.c,v 1.4 2021/09/09 21:42:00 nia Exp $
2 2
3Sun/NetBSD audio support. 3Sun/NetBSD audio support.
4 4
5--- src/hostapi/sun/pa_unix_sun.c.orig 2021-01-16 19:57:35.080979704 +0000 5--- src/hostapi/sun/pa_unix_sun.c.orig 2021-09-09 21:10:47.132269006 +0000
6+++ src/hostapi/sun/pa_unix_sun.c 6+++ src/hostapi/sun/pa_unix_sun.c
7@@ -0,0 +1,1140 @@ 7@@ -0,0 +1,1123 @@
8+/* 8+/*
9+ * $Id" 9+ * $Id"
10+ * PortAudio Portable Real-Time Audio Library 10+ * PortAudio Portable Real-Time Audio Library
11+ * Latest Version at: http://www.portaudio.com 11+ * Latest Version at: http://www.portaudio.com
12+ * Sun implementation by: 12+ * Sun implementation by:
13+ * Nia Alarie 13+ * Nia Alarie
14+ * 14+ *
15+ * Based on the Open Source API proposed by Ross Bencina 15+ * Based on the Open Source API proposed by Ross Bencina
16+ * Copyright (c) 1999-2002 Ross Bencina, Phil Burk 16+ * Copyright (c) 1999-2002 Ross Bencina, Phil Burk
17+ * 17+ *
18+ * Permission is hereby granted, free of charge, to any person obtaining 18+ * Permission is hereby granted, free of charge, to any person obtaining
19+ * a copy of this software and associated documentation files 19+ * a copy of this software and associated documentation files
20+ * (the "Software"), to deal in the Software without restriction, 20+ * (the "Software"), to deal in the Software without restriction,
@@ -90,31 +90,26 @@ Sun/NetBSD audio support. @@ -90,31 +90,26 @@ Sun/NetBSD audio support.
90+ 90+
91+#ifndef SUN_DEV_PREFIX 91+#ifndef SUN_DEV_PREFIX
92+# ifdef __sun 92+# ifdef __sun
93+# define SUN_DEV_PREFIX "/dev/sound/" 93+# define SUN_DEV_PREFIX "/dev/sound/"
94+# else 94+# else
95+# define SUN_DEV_PREFIX "/dev/audio" 95+# define SUN_DEV_PREFIX "/dev/audio"
96+# endif 96+# endif
97+#endif 97+#endif
98+ 98+
99+#ifndef SUN_DEV_DEFAULT 99+#ifndef SUN_DEV_DEFAULT
100+#define SUN_DEV_DEFAULT "/dev/audio" 100+#define SUN_DEV_DEFAULT "/dev/audio"
101+#endif 101+#endif
102+ 102+
103+#ifndef AUDIO_FLUSH 
104+#include <sys/stropts.h> 
105+#define AUDIO_FLUSH I_FLUSH 
106+#endif 
107+ 
108+#ifndef AUDIO_ENCODING_SLINEAR 103+#ifndef AUDIO_ENCODING_SLINEAR
109+#define AUDIO_ENCODING_SLINEAR AUDIO_ENCODING_LINEAR 104+#define AUDIO_ENCODING_SLINEAR AUDIO_ENCODING_LINEAR
110+#endif 105+#endif
111+ 106+
112+#if 0 107+#if 0
113+/* testing */ 108+/* testing */
114+#undef AUDIO_GETPROPS 109+#undef AUDIO_GETPROPS
115+#undef AUDIO_GETFORMAT 110+#undef AUDIO_GETFORMAT
116+#undef AUDIO_GETBUFINFO 111+#undef AUDIO_GETBUFINFO
117+#endif 112+#endif
118+ 113+
119+PaError PaSun_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index ); 114+PaError PaSun_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index );
120+static void Terminate( struct PaUtilHostApiRepresentation *hostApi ); 115+static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
@@ -909,39 +904,27 @@ Sun/NetBSD audio support. @@ -909,39 +904,27 @@ Sun/NetBSD audio support.
909+ 904+
910+ if( stream->bufferProcessor.streamCallback ) 905+ if( stream->bufferProcessor.streamCallback )
911+ PA_ENSURE( PaUtil_CancelThreading( &stream->threading, 1, NULL ) ); 906+ PA_ENSURE( PaUtil_CancelThreading( &stream->threading, 1, NULL ) );
912+ 907+
913+ if( stream->play.fd != -1 ) 908+ if( stream->play.fd != -1 )
914+ (void)ioctl(stream->play.fd, AUDIO_DRAIN); 909+ (void)ioctl(stream->play.fd, AUDIO_DRAIN);
915+ 910+
916+error: 911+error:
917+ return result; 912+ return result;
918+} 913+}
919+ 914+
920+static PaError AbortStream( PaStream *s ) 915+static PaError AbortStream( PaStream *s )
921+{ 916+{
922+ PaError result = paNoError; 917+ StopStream(s);
923+ PaSunStream *stream = (PaSunStream*)s; 
924+ 
925+ stream->stopped = true; 
926+ 
927+ if( stream->bufferProcessor.streamCallback ) 
928+ PA_ENSURE( PaUtil_CancelThreading( &stream->threading, 0, NULL ) ); 
929+ 
930+ if( stream->play.fd != -1 ) 
931+ (void)ioctl(stream->play.fd, AUDIO_FLUSH); 
932+ 
933+error: 
934+ return result; 
935+} 918+}
936+ 919+
937+static PaError IsStreamStopped( PaStream *s ) 920+static PaError IsStreamStopped( PaStream *s )
938+{ 921+{
939+ PaSunStream *stream = (PaSunStream*)s; 922+ PaSunStream *stream = (PaSunStream*)s;
940+ 923+
941+ return stream->stopped; 924+ return stream->stopped;
942+} 925+}
943+ 926+
944+ 927+
945+static PaError IsStreamActive( PaStream *s ) 928+static PaError IsStreamActive( PaStream *s )
946+{ 929+{
947+ PaSunStream *stream = (PaSunStream*)s; 930+ PaSunStream *stream = (PaSunStream*)s;