View | Details | Raw Unified | Return to bug 259255 | Differences between
and this patch

Collapse All | Expand All

(-)b/audio/portaudio/Makefile (-48 / +50 lines)
Lines 1-73 Link Here
1
PORTNAME=	portaudio
1
PORTNAME=	portaudio
2
PORTVERSION=	19.6.0
2
PORTVERSION=	19.7.0
3
PORTREVISION=	7
4
PORTEPOCH=	1
3
PORTEPOCH=	1
5
CATEGORIES=	audio
4
CATEGORIES=	audio
6
MASTER_SITES=	http://www.portaudio.com/archives/
7
DISTNAME=	pa_stable_v190600_20161030
8
5
9
MAINTAINER=	multimedia@FreeBSD.org
6
MAINTAINER=	multimedia@FreeBSD.org
10
COMMENT=	Portable cross-platform Audio API
7
COMMENT=	Portable cross-platform Audio API
11
WWW=		http://www.portaudio.com/
8
WWW=		https://www.portaudio.com/
12
9
13
LICENSE=	MIT
10
LICENSE=	MIT
14
LICENSE_FILE=	${WRKSRC}/LICENSE.txt
11
LICENSE_FILE=	${WRKSRC}/LICENSE.txt
15
12
16
USES=		autoreconf:2.69 cpe dos2unix gmake libtool localbase:ldflags \
13
USES=		cmake cpe pathfix pkgconfig
17
		pathfix pkgconfig tar:tgz
18
USE_LDCONFIG=	yes
19
CPE_VENDOR=	portaudio_project
14
CPE_VENDOR=	portaudio_project
20
15
USE_GITHUB=	yes
21
GNU_CONFIGURE=	yes
16
GH_ACCOUNT=	PortAudio
22
CONFIGURE_ARGS=	--disable-dependency-tracking \
17
GH_TAGNAME=	88ab584e7bf4358599744cd662cfbc978f41efbf
23
		--enable-cxx \
18
USE_LDCONFIG=	yes
24
		--without-alsa
19
CMAKE_ARGS=	-DOSS_INCLUDE_DIR:PATH=/usr/include \
25
MAKE_ARGS=	EXAMPLES=""
20
		-DCMAKE_INSTALL_DOCDIR:PATH=${DOCSDIR_REL:Q}
26
21
CMAKE_ON=	PA_BUILD_SHARED_LIBS \
27
MAKE_JOBS_UNSAFE=	yes
22
		PA_USE_OSS
28
23
CMAKE_OFF=	PA_ALSA_DYNAMIC \
29
WRKSRC=		${WRKDIR}/${PORTNAME}
24
		PA_USE_SKELETON \
30
25
		PA_WARNINGS_ARE_ERRORS
26
SUB_FILES=	pkg-message
31
PORTDOCS=	*
27
PORTDOCS=	*
32
PORTEXAMPLES=	*
28
PORTEXAMPLES=	*
33
29
34
OPTIONS_DEFINE=	DOCS DOXYGEN EXAMPLES JACK PATEST SNDIO
30
OPTIONS_DEFINE=	ALSA DOCS DOXYGEN EXAMPLES JACK PATEST PULSEAUDIO SNDIO
31
OPTIONS_DEFAULT=
35
OPTIONS_SUB=	yes
32
OPTIONS_SUB=	yes
36
37
SUB_FILES=	pkg-message
38
39
PATEST_DESC=	PortAudio Test Programs
33
PATEST_DESC=	PortAudio Test Programs
40
34
ALSA_LIB_DEPENDS=	libasound.so:audio/alsa-lib
35
ALSA_CMAKE_BOOL=	PA_USE_ALSA
41
DOXYGEN_IMPLIES=	DOCS
36
DOXYGEN_IMPLIES=	DOCS
42
DOXYGEN_BUILD_DEPENDS=	doxygen:devel/doxygen
37
DOXYGEN_BUILD_DEPENDS=	doxygen:devel/doxygen
43
38
EXAMPLES_CMAKE_BOOL=	PA_BUILD_EXAMPLES
44
JACK_LIB_DEPENDS=	libjack.so:audio/jack
39
JACK_LIB_DEPENDS=	libjack.so:audio/jack
45
JACK_CONFIGURE_WITH=	jack
40
JACK_CMAKE_BOOL=	PA_USE_JACK
46
41
PATEST_CMAKE_BOOL=	PA_BUILD_TESTS
47
PATEST_MAKE_ARGS_OFF=	SELFTESTS="" \
42
PULSEAUDIO_BROKEN=	mutex is unstable
48
			TESTS=""
43
PULSEAUDIO_LIB_DEPENDS=	libpulse.so:audio/pulseaudio
49
44
PULSEAUDIO_CMAKE_BOOL=	PA_USE_PULSEAUDIO
50
SNDIO_LIB_DEPENDS=	libsndio.so:audio/sndio
45
SNDIO_LIB_DEPENDS=	libsndio.so:audio/sndio
51
SNDIO_CONFIGURE_WITH=	sndio
46
SNDIO_CMAKE_BOOL=	PA_USE_SNDIO
52
47
53
post-extract:
48
.include <bsd.port.options.mk>
54
	@${MKDIR} ${WRKSRC}/src/hostapi/sndio
55
	@${CP} ${FILESDIR}/pa_sndio.c ${WRKSRC}/src/hostapi/sndio
56
49
57
post-install:
50
.ifdef WITH_DEBUG
58
	@${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/libportaudio.so \
51
CMAKE_ON+=	PA_ENABLE_DEBUG_OUTPUT
59
		${STAGEDIR}${PREFIX}/lib/libportaudiocpp.so
52
.else
60
	${INSTALL_DATA} ${FILESDIR}/pa_unix_oss.h ${STAGEDIR}${PREFIX}/include
53
CMAKE_OFF+=	PA_ENABLE_DEBUG_OUTPUT
54
.endif
61
55
62
post-install-DOCS-on:
56
do-build-DOXYGEN-on:
57
	@(cd ${WRKSRC}; if ! doxygen ; then \
58
		(${ECHO_CMD} "===> ${.TARGET} failed unexpectedly.") | ${FMT_80} ; \
59
		${FALSE}; \
60
		fi)
61
62
${STAGEDIR}${DOCSDIR}:
63
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
63
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
64
	cd ${WRKSRC} && ${INSTALL_DATA} README.txt index.html ${STAGEDIR}${DOCSDIR}
65
64
66
post-install-DOXYGEN-on:
65
do-install-DOCS-on: ${STAGEDIR}${DOCSDIR}
67
	@cd ${WRKSRC} && doxygen
66
67
do-install-DOXYGEN-on: ${STAGEDIR}${DOCSDIR}
68
	@cd ${WRKSRC}/doc && ${COPYTREE_SHARE} html ${STAGEDIR}${DOCSDIR}
68
	@cd ${WRKSRC}/doc && ${COPYTREE_SHARE} html ${STAGEDIR}${DOCSDIR}
69
69
70
post-install-EXAMPLES-on:
70
do-install-EXAMPLES-on:
71
	${FIND} ${INSTALL_WRKSRC}/examples -maxdepth 1 -type f -name pa\* -print0 |\
72
		${XARGS} -0 -J % ${INSTALL_PROGRAM} % ${STAGEDIR}${PREFIX}/bin
71
	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
73
	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
72
	${INSTALL_DATA} ${WRKSRC}/bindings/cpp/example/*.cxx \
74
	${INSTALL_DATA} ${WRKSRC}/bindings/cpp/example/*.cxx \
73
		${WRKSRC}/examples/*.c ${WRKSRC}/examples/*.cpp \
75
		${WRKSRC}/examples/*.c ${WRKSRC}/examples/*.cpp \
Lines 75-84 post-install-EXAMPLES-on: Link Here
75
		${WRKSRC}/src/common/*.[ch] \
77
		${WRKSRC}/src/common/*.[ch] \
76
		${STAGEDIR}${EXAMPLESDIR}
78
		${STAGEDIR}${EXAMPLESDIR}
77
79
78
post-install-PATEST-on:
80
do-install-PATEST-on:
79
.for f in pa_m* paqa_* patest*
81
	${FIND} ${INSTALL_WRKSRC}/test -maxdepth 1 -type f -name pa\* -print0 |\
80
	${STRIP_CMD} ${WRKSRC}/bin/.libs/${f}
82
		${XARGS} -0 -J % ${INSTALL_PROGRAM} % ${STAGEDIR}${PREFIX}/bin
81
	${INSTALL_PROGRAM} ${WRKSRC}/bin/.libs/${f} ${STAGEDIR}${PREFIX}/bin/
83
	${FIND} ${INSTALL_WRKSRC}/qa -maxdepth 1 -type f -name pa\* -print0 |\
82
.endfor
84
		${XARGS} -0 -J % ${INSTALL_PROGRAM} % ${STAGEDIR}${PREFIX}/bin
83
85
84
.include <bsd.port.mk>
86
.include <bsd.port.mk>
(-)b/audio/portaudio/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1531882553
1
TIMESTAMP = 1712286000
2
SHA256 (pa_stable_v190600_20161030.tgz) = f5a21d7dcd6ee84397446fa1fa1a0675bb2e8a4a6dceb4305a8404698d8d1513
2
SHA256 (PortAudio-portaudio-19.7.0-88ab584e7bf4358599744cd662cfbc978f41efbf_GH0.tar.gz) = f5be535d62cab5f1becd4f19207466c813fbcf51d9057e72f7d57544a9e9ee03
3
SIZE (pa_stable_v190600_20161030.tgz) = 1450572
3
SIZE (PortAudio-portaudio-19.7.0-88ab584e7bf4358599744cd662cfbc978f41efbf_GH0.tar.gz) = 1491142
(-)a/audio/portaudio/files/pa_sndio.c (-765 lines)
Removed Link Here
1
/*
2
 * Copyright (c) 2009 Alexandre Ratchov <alex@caoua.org>
3
 *
4
 * Permission to use, copy, modify, and distribute this software for any
5
 * purpose with or without fee is hereby granted, provided that the above
6
 * copyright notice and this permission notice appear in all copies.
7
 *
8
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
 */
16
#include <sys/types.h>
17
#include <pthread.h>
18
#include <poll.h>
19
#include <errno.h>
20
#include <string.h>
21
#include <stdlib.h>
22
#include <stdio.h>
23
#include <sndio.h>
24
25
#include "pa_util.h"
26
#include "pa_hostapi.h"
27
#include "pa_stream.h"
28
#include "pa_process.h"
29
#include "pa_allocation.h"
30
31
#if 0
32
#define DPR(...) do { fprintf(stderr, __VA_ARGS__); } while (0)
33
#else
34
#define DPR(...) do {} while (0)
35
#endif
36
37
/*
38
 * per-stream data
39
 */
40
typedef struct PaSndioStream
41
{
42
	PaUtilStreamRepresentation base;
43
	PaUtilBufferProcessor bufproc;	/* format conversion */
44
	struct sio_hdl *hdl;		/* handle for device i/o */
45
	struct sio_par par;		/* current device parameters */	
46
	unsigned mode;			/* SIO_PLAY, SIO_REC or both */
47
	int stopped;			/* stop requested or not started */
48
	int active;			/* thread is running */
49
	unsigned long long realpos;	/* frame number h/w is processing */
50
	char *rbuf, *wbuf;		/* bounce buffers for conversions */
51
	unsigned long long rpos, wpos;	/* bytes read/written */
52
	pthread_t thread;		/* thread of the callback interface */
53
} PaSndioStream;
54
55
/*
56
 * api "class" data, common to all streams
57
 */
58
typedef struct PaSndioHostApiRepresentation
59
{
60
	PaUtilHostApiRepresentation base;
61
	PaUtilStreamInterface callback;
62
	PaUtilStreamInterface blocking;
63
	/*
64
	 * sndio has no device discovery mechanism and PortAudio has
65
	 * no way of accepting raw device strings from users.
66
	 * Normally we just expose the default device, which can be
67
	 * changed via the AUDIODEVICE environment variable, but we
68
	 * also allow specifying a list of up to 16 devices via the
69
	 * PA_SNDIO_AUDIODEVICES environment variable.
70
	 *
71
	 * Example:
72
	 * PA_SNDIO_AUDIODEVICES=default:snd/0.monitor:snd@remote/0
73
	 */
74
#define PA_SNDIO_AUDIODEVICES_MAX	16
75
	PaDeviceInfo device_info[PA_SNDIO_AUDIODEVICES_MAX];
76
	PaDeviceInfo *infos[PA_SNDIO_AUDIODEVICES_MAX];
77
	char *audiodevices;
78
} PaSndioHostApiRepresentation;
79
80
/*
81
 * callback invoked when blocks are processed by the hardware
82
 */
83
static void
84
sndioOnMove(void *addr, int delta)
85
{
86
	PaSndioStream *s = (PaSndioStream *)addr;
87
88
	s->realpos += delta;
89
}
90
91
/*
92
 * convert PA encoding to sndio encoding, return true on success
93
 */
94
static int
95
sndioSetFmt(struct sio_par *sio, PaSampleFormat fmt)
96
{
97
	switch (fmt & ~paNonInterleaved) {
98
	case paInt32:
99
		sio->sig = 1;
100
		sio->bits = 32;
101
		break;
102
	case paInt24:
103
		sio->sig = 1;
104
		sio->bits = 24;
105
		sio->bps = 3;	/* paInt24 is packed format */
106
		break;
107
	case paInt16:
108
	case paFloat32:
109
		sio->sig = 1;
110
		sio->bits = 16;
111
		break;
112
	case paInt8:
113
		sio->sig = 1;
114
		sio->bits = 8;
115
		break;
116
	case paUInt8:
117
		sio->sig = 0;
118
		sio->bits = 8;
119
		break;
120
	default:
121
		DPR("sndioSetFmt: %x: unsupported\n", fmt);
122
		return 0;
123
	}
124
	sio->le = SIO_LE_NATIVE;
125
	return 1;
126
}
127
128
/*
129
 * convert sndio encoding to PA encoding, return true on success
130
 */
131
static int
132
sndioGetFmt(struct sio_par *sio, PaSampleFormat *fmt)
133
{
134
	if ((sio->bps * 8 != sio->bits && !sio->msb) ||
135
	    (sio->bps > 1 && sio->le != SIO_LE_NATIVE)) {
136
		DPR("sndioGetFmt: bits = %u, le = %u, msb = %u, bps = %u\n",
137
		    sio->bits, sio->le, sio->msb, sio->bps);
138
		return 0;
139
	}
140
141
	switch (sio->bits) {
142
	case 32:
143
		if (!sio->sig)
144
			return 0;
145
		*fmt = paInt32;
146
		break;
147
	case 24:
148
		if (!sio->sig)
149
			return 0;
150
		*fmt = (sio->bps == 3) ? paInt24 : paInt32;
151
		break;
152
	case 16:
153
		if (!sio->sig)
154
			return 0;
155
		*fmt = paInt16;
156
		break;
157
	case 8:
158
		*fmt = sio->sig ? paInt8 : paUInt8;
159
		break;
160
	default:
161
		DPR("sndioGetFmt: %u: unsupported\n", sio->bits);
162
		return 0;
163
	}
164
	return 1;
165
}
166
167
/*
168
 * I/O loop for callback interface
169
 */
170
static void *
171
sndioThread(void *arg)
172
{
173
	PaSndioStream *s = (PaSndioStream *)arg;
174
	PaStreamCallbackTimeInfo ti;
175
	unsigned char *data;
176
	unsigned todo, rblksz, wblksz;
177
	int n, result;
178
	
179
	rblksz = s->par.round * s->par.rchan * s->par.bps;
180
	wblksz = s->par.round * s->par.pchan * s->par.bps;
181
	
182
	DPR("sndioThread: mode = %x, round = %u, rblksz = %u, wblksz = %u\n",
183
	    s->mode, s->par.round, rblksz, wblksz);
184
	
185
	while (!s->stopped) {
186
		if (s->mode & SIO_REC) {
187
			todo = rblksz;
188
			data = s->rbuf;
189
			while (todo > 0) {
190
				n = sio_read(s->hdl, data, todo);
191
				if (n == 0) {
192
					DPR("sndioThread: sio_read failed\n");
193
					goto failed;
194
				}
195
				todo -= n;
196
				data += n;
197
			}
198
			s->rpos += s->par.round;
199
			ti.inputBufferAdcTime = 
200
			    (double)s->realpos / s->par.rate;
201
		}
202
		if (s->mode & SIO_PLAY) {
203
			ti.outputBufferDacTime =
204
			    (double)(s->realpos + s->par.bufsz) / s->par.rate;
205
		}
206
		ti.currentTime = s->realpos / (double)s->par.rate;
207
		PaUtil_BeginBufferProcessing(&s->bufproc, &ti, 0);
208
		if (s->mode & SIO_PLAY) {
209
			PaUtil_SetOutputFrameCount(&s->bufproc, s->par.round);
210
			PaUtil_SetInterleavedOutputChannels(&s->bufproc,
211
			    0, s->wbuf, s->par.pchan);
212
		}
213
		if (s->mode & SIO_REC) {
214
			PaUtil_SetInputFrameCount(&s->bufproc, s->par.round);
215
			PaUtil_SetInterleavedInputChannels(&s->bufproc,
216
			    0, s->rbuf, s->par.rchan);
217
		}
218
		result = paContinue;
219
		n = PaUtil_EndBufferProcessing(&s->bufproc, &result);
220
		if (n != s->par.round) {
221
			DPR("sndioThread: %d < %u frames, result = %d\n",
222
			    n, s->par.round, result);
223
		}
224
		if (result != paContinue) {
225
			break;
226
		}
227
		if (s->mode & SIO_PLAY) {
228
			n = sio_write(s->hdl, s->wbuf, wblksz);
229
			if (n < wblksz) {
230
				DPR("sndioThread: sio_write failed\n");
231
				goto failed;
232
			}
233
			s->wpos += s->par.round;
234
		}
235
	}
236
 failed:
237
	s->active = 0;
238
	DPR("sndioThread: done\n");
239
}
240
241
static PaError
242
OpenStream(struct PaUtilHostApiRepresentation *hostApi,
243
    PaStream **stream,
244
    const PaStreamParameters *inputPar,
245
    const PaStreamParameters *outputPar,
246
    double sampleRate,
247
    unsigned long framesPerBuffer,
248
    PaStreamFlags streamFlags,
249
    PaStreamCallback *streamCallback,
250
    void *userData)
251
{
252
	PaSndioHostApiRepresentation *sndioHostApi = (PaSndioHostApiRepresentation *)hostApi;
253
	PaSndioStream *s;
254
	PaError err;
255
	struct sio_hdl *hdl;
256
	struct sio_par par;
257
	unsigned mode;
258
	int inch, onch;
259
	PaSampleFormat ifmt, ofmt, siofmt;
260
	const char *dev;
261
262
	DPR("OpenStream:\n");
263
264
	mode = 0;
265
	inch = onch = 0;
266
	ifmt = ofmt = 0;
267
	sio_initpar(&par);
268
269
	if (outputPar && outputPar->channelCount > 0) {
270
		if (outputPar->device >= sndioHostApi->base.info.deviceCount) {
271
			DPR("OpenStream: %d: bad output device\n", outputPar->device);
272
			return paInvalidDevice;
273
		}
274
		if (outputPar->hostApiSpecificStreamInfo) {
275
			DPR("OpenStream: output specific info\n");
276
			return paIncompatibleHostApiSpecificStreamInfo;
277
		}
278
		if (!sndioSetFmt(&par, outputPar->sampleFormat)) {
279
			return paSampleFormatNotSupported;
280
		}
281
		ofmt = outputPar->sampleFormat;
282
		onch = par.pchan = outputPar->channelCount;
283
		mode |= SIO_PLAY;
284
	}
285
	if (inputPar && inputPar->channelCount > 0) {
286
		if (inputPar->device >= sndioHostApi->base.info.deviceCount) {
287
			DPR("OpenStream: %d: bad input device\n", inputPar->device);
288
			return paInvalidDevice;
289
		}
290
		if (inputPar->hostApiSpecificStreamInfo) {
291
			DPR("OpenStream: input specific info\n");
292
			return paIncompatibleHostApiSpecificStreamInfo;
293
		}
294
		if (!sndioSetFmt(&par, inputPar->sampleFormat)) {
295
			return paSampleFormatNotSupported;
296
		}
297
		ifmt = inputPar->sampleFormat;
298
		inch = par.rchan = inputPar->channelCount;
299
		mode |= SIO_REC;
300
	}
301
	par.rate = sampleRate;
302
	if (framesPerBuffer != paFramesPerBufferUnspecified)
303
		par.round = framesPerBuffer;
304
305
	DPR("OpenStream: mode = %x, trying rate = %u\n", mode, par.rate);
306
307
	if (outputPar) {
308
		dev = sndioHostApi->device_info[outputPar->device].name;
309
	} else if (inputPar) {
310
		dev = sndioHostApi->device_info[inputPar->device].name;
311
	} else {
312
		return paUnanticipatedHostError;
313
	}
314
	hdl = sio_open(dev, mode, 0);
315
	if (hdl == NULL)
316
		return paUnanticipatedHostError;
317
	if (!sio_setpar(hdl, &par)) {
318
		sio_close(hdl);
319
		return paUnanticipatedHostError;
320
	}
321
	if (!sio_getpar(hdl, &par)) {
322
		sio_close(hdl);
323
		return paUnanticipatedHostError;
324
	}
325
	if (!sndioGetFmt(&par, &siofmt)) {
326
		sio_close(hdl);
327
		return paSampleFormatNotSupported;
328
	}
329
	if ((mode & SIO_REC) && par.rchan != inputPar->channelCount) {
330
		DPR("OpenStream: rchan(%u) != %d\n", par.rchan, inputPar->channelCount);
331
		sio_close(hdl);
332
		return paInvalidChannelCount;
333
	}
334
	if ((mode & SIO_PLAY) && par.pchan != outputPar->channelCount) {
335
		DPR("OpenStream: pchan(%u) != %d\n", par.pchan, outputPar->channelCount);
336
		sio_close(hdl);
337
		return paInvalidChannelCount;
338
	}
339
	if ((double)par.rate < sampleRate * 0.995 ||
340
	    (double)par.rate > sampleRate * 1.005) {
341
		DPR("OpenStream: rate(%u) != %g\n", par.rate, sampleRate);
342
		sio_close(hdl);
343
		return paInvalidSampleRate;
344
	}
345
	
346
	s = (PaSndioStream *)PaUtil_AllocateMemory(sizeof(PaSndioStream));
347
	if (s == NULL) {
348
		sio_close(hdl);
349
		return paInsufficientMemory;
350
	}
351
	PaUtil_InitializeStreamRepresentation(&s->base, 
352
	    streamCallback ? &sndioHostApi->callback : &sndioHostApi->blocking,
353
	    streamCallback, userData);
354
	DPR("inch = %d, onch = %d, ifmt = %x, ofmt = %x\n", 
355
	    inch, onch, ifmt, ofmt);
356
	err = PaUtil_InitializeBufferProcessor(&s->bufproc,
357
	    inch, ifmt, siofmt,
358
	    onch, ofmt, siofmt,
359
	    sampleRate,
360
	    streamFlags,
361
	    framesPerBuffer,
362
	    par.round,
363
	    paUtilFixedHostBufferSize, 
364
	    streamCallback, userData);
365
	if (err) {
366
		DPR("OpenStream: PaUtil_InitializeBufferProcessor failed\n");
367
		PaUtil_FreeMemory(s);
368
		sio_close(hdl);
369
		return err;
370
	}
371
	if (mode & SIO_REC) {
372
		s->rbuf = malloc(par.round * par.rchan * par.bps);
373
		if (s->rbuf == NULL) {
374
			DPR("OpenStream: failed to allocate rbuf\n");
375
			PaUtil_FreeMemory(s);
376
			sio_close(hdl);
377
			return paInsufficientMemory;
378
		}
379
	}
380
	if (mode & SIO_PLAY) {
381
		s->wbuf = malloc(par.round * par.pchan * par.bps);
382
		if (s->wbuf == NULL) {
383
			DPR("OpenStream: failed to allocate wbuf\n");
384
			free(s->rbuf);
385
			PaUtil_FreeMemory(s);
386
			sio_close(hdl);
387
			return paInsufficientMemory;
388
		}
389
	}	
390
	s->base.streamInfo.inputLatency = 0;
391
	s->base.streamInfo.outputLatency = (mode & SIO_PLAY) ?
392
	    (double)(par.bufsz + PaUtil_GetBufferProcessorOutputLatencyFrames(&s->bufproc)) / (double)par.rate : 0;
393
	s->base.streamInfo.sampleRate = par.rate;
394
	s->active = 0;
395
	s->stopped = 1;
396
	s->mode = mode;
397
	s->hdl = hdl;
398
	s->par = par;
399
	*stream = s;	
400
	DPR("OpenStream: done\n");
401
	return paNoError;
402
}
403
404
static PaError
405
BlockingReadStream(PaStream *stream, void *data, unsigned long numFrames)
406
{
407
	PaSndioStream *s = (PaSndioStream *)stream;
408
	unsigned n, res, todo;
409
	void *buf;
410
	
411
	while (numFrames > 0) {
412
		n = s->par.round;
413
		if (n > numFrames)
414
			n = numFrames;
415
		buf = s->rbuf;
416
		todo = n * s->par.rchan * s->par.bps;
417
		while (todo > 0) {
418
			res = sio_read(s->hdl, buf, todo);
419
			if (res == 0)
420
				return paUnanticipatedHostError;
421
			buf = (char *)buf + res;
422
			todo -= res;
423
		}
424
		s->rpos += n;
425
		PaUtil_SetInputFrameCount(&s->bufproc, n);
426
		PaUtil_SetInterleavedInputChannels(&s->bufproc, 0, s->rbuf, s->par.rchan);
427
		res = PaUtil_CopyInput(&s->bufproc, &data, n);
428
		if (res != n) {
429
			DPR("BlockingReadStream: copyInput: %u != %u\n");
430
			return paUnanticipatedHostError;
431
		}
432
		numFrames -= n;
433
	}
434
	return paNoError;
435
}
436
437
static PaError
438
BlockingWriteStream(PaStream* stream, const void *data, unsigned long numFrames)
439
{
440
	PaSndioStream *s = (PaSndioStream *)stream;
441
	unsigned n, res;
442
443
	while (numFrames > 0) {
444
		n = s->par.round;
445
		if (n > numFrames)
446
			n = numFrames;
447
		PaUtil_SetOutputFrameCount(&s->bufproc, n);
448
		PaUtil_SetInterleavedOutputChannels(&s->bufproc, 0, s->wbuf, s->par.pchan);
449
		res = PaUtil_CopyOutput(&s->bufproc, &data, n);
450
		if (res != n) {
451
			DPR("BlockingWriteStream: copyOutput: %u != %u\n");
452
			return paUnanticipatedHostError;
453
		}
454
		res = sio_write(s->hdl, s->wbuf, n * s->par.pchan * s->par.bps);
455
		if (res == 0)
456
			return paUnanticipatedHostError;		
457
		s->wpos += n;
458
		numFrames -= n;
459
	}
460
	return paNoError;
461
}
462
463
static signed long
464
BlockingGetStreamReadAvailable(PaStream *stream)
465
{
466
	PaSndioStream *s = (PaSndioStream *)stream;
467
	struct pollfd pfd;
468
	int n, events;
469
470
	n = sio_pollfd(s->hdl, &pfd, POLLIN);
471
	while (poll(&pfd, n, 0) < 0) {
472
		if (errno == EINTR)
473
			continue;
474
		perror("poll");
475
		abort();
476
	}
477
	events = sio_revents(s->hdl, &pfd);
478
	if (!(events & POLLIN))
479
		return 0;
480
481
	return s->realpos - s->rpos;
482
}
483
484
static signed long
485
BlockingGetStreamWriteAvailable(PaStream *stream)
486
{
487
	PaSndioStream *s = (PaSndioStream *)stream;
488
	struct pollfd pfd;
489
	int n, events;
490
491
	n = sio_pollfd(s->hdl, &pfd, POLLOUT);
492
	while (poll(&pfd, n, 0) < 0) {
493
		if (errno == EINTR)
494
			continue;
495
		perror("poll");
496
		abort();
497
	}
498
	events = sio_revents(s->hdl, &pfd);
499
	if (!(events & POLLOUT))
500
		return 0;
501
502
	return s->par.bufsz - (s->wpos - s->realpos);
503
}
504
505
static PaError
506
BlockingWaitEmpty( PaStream *stream )
507
{
508
	PaSndioStream *s = (PaSndioStream *)stream;
509
510
	/*
511
	 * drain playback buffers; sndio always does it in background
512
	 * and there is no way to wait for completion
513
	 */
514
	DPR("BlockingWaitEmpty: s=%d, a=%d\n", s->stopped, s->active);
515
516
	return paNoError;
517
}
518
519
static PaError
520
StartStream(PaStream *stream)
521
{
522
	PaSndioStream *s = (PaSndioStream *)stream;
523
	unsigned primes, wblksz;
524
	int err;
525
526
	DPR("StartStream: s=%d, a=%d\n", s->stopped, s->active);
527
528
	if (!s->stopped) {
529
		DPR("StartStream: already started\n");
530
		return paNoError;
531
	}
532
	s->stopped = 0;
533
	s->active = 1;
534
	s->realpos = 0;
535
	s->wpos = 0;
536
	s->rpos = 0;
537
	PaUtil_ResetBufferProcessor(&s->bufproc);
538
	if (!sio_start(s->hdl))
539
		return paUnanticipatedHostError;
540
541
	/*
542
	 * send a complete buffer of silence
543
	 */
544
	if (s->mode & SIO_PLAY) {
545
		wblksz = s->par.round * s->par.pchan * s->par.bps;
546
		memset(s->wbuf, 0, wblksz);
547
		for (primes = s->par.bufsz / s->par.round; primes > 0; primes--)
548
			s->wpos += sio_write(s->hdl, s->wbuf, wblksz);
549
	}
550
	if (s->base.streamCallback) {
551
		err = pthread_create(&s->thread, NULL, sndioThread, s);
552
		if (err) {
553
			DPR("SndioStartStream: couldn't create thread\n");
554
			return paUnanticipatedHostError;
555
		}
556
		DPR("StartStream: started...\n");
557
	}
558
	return paNoError;
559
}
560
561
static PaError
562
StopStream(PaStream *stream)
563
{
564
	PaSndioStream *s = (PaSndioStream *)stream;
565
	void *ret;
566
	int err;
567
568
	DPR("StopStream: s=%d, a=%d\n", s->stopped, s->active);
569
570
	if (s->stopped) {
571
		DPR("StartStream: already started\n");
572
		return paNoError;
573
	}
574
	s->stopped = 1;
575
	if (s->base.streamCallback) {
576
		err = pthread_join(s->thread, &ret);
577
		if (err) {
578
			DPR("SndioStop: couldn't join thread\n");
579
			return paUnanticipatedHostError;
580
		}
581
	}
582
	if (!sio_stop(s->hdl))
583
		return paUnanticipatedHostError;
584
	return paNoError;
585
}
586
587
static PaError
588
CloseStream(PaStream *stream)
589
{
590
	PaSndioStream *s = (PaSndioStream *)stream;
591
592
	DPR("CloseStream:\n");
593
594
	if (!s->stopped)
595
		StopStream(stream);
596
597
	if (s->mode & SIO_REC)
598
		free(s->rbuf);
599
	if (s->mode & SIO_PLAY)
600
		free(s->wbuf);
601
	sio_close(s->hdl);
602
        PaUtil_TerminateStreamRepresentation(&s->base);
603
	PaUtil_TerminateBufferProcessor(&s->bufproc);
604
	PaUtil_FreeMemory(s);
605
	return paNoError;
606
}
607
608
static PaError
609
AbortStream(PaStream *stream)
610
{
611
	DPR("AbortStream:\n");
612
613
	return StopStream(stream);
614
}
615
616
static PaError
617
IsStreamStopped(PaStream *stream)
618
{
619
	PaSndioStream *s = (PaSndioStream *)stream;
620
621
	//DPR("IsStreamStopped: s=%d, a=%d\n", s->stopped, s->active);
622
623
	return s->stopped;
624
}
625
626
static PaError
627
IsStreamActive(PaStream *stream)
628
{
629
	PaSndioStream *s = (PaSndioStream *)stream;
630
631
	//DPR("IsStreamActive: s=%d, a=%d\n", s->stopped, s->active);
632
633
	return s->active;
634
}
635
636
static PaTime
637
GetStreamTime(PaStream *stream)
638
{
639
	PaSndioStream *s = (PaSndioStream *)stream;
640
641
	return (double)s->realpos / s->base.streamInfo.sampleRate;
642
}
643
644
static PaError
645
IsFormatSupported(struct PaUtilHostApiRepresentation *hostApi,
646
    const PaStreamParameters *inputPar,
647
    const PaStreamParameters *outputPar,
648
    double sampleRate)
649
{
650
	return paFormatIsSupported;
651
}
652
653
static void
654
Terminate(struct PaUtilHostApiRepresentation *hostApi)
655
{
656
	PaSndioHostApiRepresentation *sndioHostApi;
657
	sndioHostApi = (PaSndioHostApiRepresentation *)hostApi;
658
	free(sndioHostApi->audiodevices);
659
	PaUtil_FreeMemory(hostApi);
660
}
661
662
static void
663
InitDeviceInfo(PaDeviceInfo *info, PaHostApiIndex hostApiIndex, const char *name)
664
{
665
	info->structVersion = 2;
666
	info->name = name;
667
	info->hostApi = hostApiIndex;
668
	info->maxInputChannels = 128;
669
	info->maxOutputChannels = 128;
670
	info->defaultLowInputLatency = 0.01;
671
	info->defaultLowOutputLatency = 0.01;
672
	info->defaultHighInputLatency = 0.5;
673
	info->defaultHighOutputLatency = 0.5;
674
	info->defaultSampleRate = 48000;
675
}
676
677
PaError
678
PaSndio_Initialize(PaUtilHostApiRepresentation **hostApi, PaHostApiIndex hostApiIndex)
679
{
680
	PaSndioHostApiRepresentation *sndioHostApi;
681
	PaDeviceInfo *info;
682
	struct sio_hdl *hdl;
683
	char *audiodevices;
684
	char *device;
685
	size_t deviceCount;
686
687
	DPR("PaSndio_Initialize: initializing...\n");
688
689
	/* unusable APIs should return paNoError and a NULL hostApi */
690
	*hostApi = NULL;
691
692
	sndioHostApi = PaUtil_AllocateMemory(sizeof(PaSndioHostApiRepresentation));
693
	if (sndioHostApi == NULL)
694
		return paNoError;
695
696
	// Add default device
697
	info = &sndioHostApi->device_info[0];
698
	InitDeviceInfo(info, hostApiIndex, SIO_DEVANY);
699
	sndioHostApi->infos[0] = info;
700
	deviceCount = 1;
701
702
	// Add additional devices as specified in the PA_SNDIO_AUDIODEVICES
703
	// environment variable as a colon separated list
704
	sndioHostApi->audiodevices = NULL;
705
	audiodevices = getenv("PA_SNDIO_AUDIODEVICES");
706
	if (audiodevices != NULL) {
707
		sndioHostApi->audiodevices = strdup(audiodevices);
708
		if (sndioHostApi->audiodevices == NULL)
709
			return paNoError;
710
711
		audiodevices = sndioHostApi->audiodevices;
712
		while ((device = strsep(&audiodevices, ":")) != NULL &&
713
			deviceCount < PA_SNDIO_AUDIODEVICES_MAX) {
714
			if (*device == '\0')
715
				continue;
716
			info = &sndioHostApi->device_info[deviceCount];
717
			InitDeviceInfo(info, hostApiIndex, device);
718
			sndioHostApi->infos[deviceCount] = info;
719
			deviceCount++;
720
		}
721
	}
722
723
	*hostApi = &sndioHostApi->base;
724
	(*hostApi)->info.structVersion = 1;
725
	(*hostApi)->info.type = paSndio;
726
	(*hostApi)->info.name = "sndio";
727
	(*hostApi)->info.deviceCount = deviceCount;
728
	(*hostApi)->info.defaultInputDevice = 0;
729
	(*hostApi)->info.defaultOutputDevice = 0;
730
	(*hostApi)->deviceInfos = sndioHostApi->infos;
731
	(*hostApi)->Terminate = Terminate;
732
	(*hostApi)->OpenStream = OpenStream;
733
	(*hostApi)->IsFormatSupported = IsFormatSupported;
734
	
735
	PaUtil_InitializeStreamInterface(&sndioHostApi->blocking,
736
	    CloseStream,
737
	    StartStream,
738
	    StopStream,
739
	    AbortStream,
740
	    IsStreamStopped,
741
	    IsStreamActive,
742
	    GetStreamTime,
743
	    PaUtil_DummyGetCpuLoad,
744
	    BlockingReadStream,
745
	    BlockingWriteStream,
746
	    BlockingGetStreamReadAvailable,
747
	    BlockingGetStreamWriteAvailable);
748
749
	PaUtil_InitializeStreamInterface(&sndioHostApi->callback,
750
	    CloseStream,
751
	    StartStream,
752
	    StopStream,
753
	    AbortStream,
754
	    IsStreamStopped,
755
	    IsStreamActive,
756
	    GetStreamTime,
757
	    PaUtil_DummyGetCpuLoad,
758
	    PaUtil_DummyRead,
759
	    PaUtil_DummyWrite,
760
	    PaUtil_DummyGetReadAvailable,
761
	    PaUtil_DummyGetWriteAvailable);
762
763
	DPR("PaSndio_Initialize: done\n");
764
	return paNoError;
765
}
(-)a/audio/portaudio/files/pa_unix_oss.h (-52 lines)
Removed Link Here
1
#ifndef PA_UNIX_OSS_H
2
#define PA_UNIX_OSS_H
3
4
/*
5
 * $Id: portaudio.patch,v 1.10 2009-06-30 04:52:59 llucius Exp $
6
 * PortAudio Portable Real-Time Audio Library
7
 * OSS-specific extensions
8
 *
9
 * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
10
 *
11
 * Permission is hereby granted, free of charge, to any person obtaining
12
 * a copy of this software and associated documentation files
13
 * (the "Software"), to deal in the Software without restriction,
14
 * including without limitation the rights to use, copy, modify, merge,
15
 * publish, distribute, sublicense, and/or sell copies of the Software,
16
 * and to permit persons to whom the Software is furnished to do so,
17
 * subject to the following conditions:
18
 *
19
 * The above copyright notice and this permission notice shall be
20
 * included in all copies or substantial portions of the Software.
21
 *
22
 * Any person wishing to distribute modifications to the Software is
23
 * requested to send the modifications to the original developer so that
24
 * they can be incorporated into the canonical version.
25
 *
26
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
29
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
30
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
31
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33
 *
34
 */
35
36
/** @file
37
 * OSS-specific PortAudio API extension header file.
38
 */
39
40
#ifdef __cplusplus
41
extern "C" {
42
#endif
43
44
const char *PaOSS_GetStreamInputDevice( PaStream *s );
45
46
const char *PaOSS_GetStreamOutputDevice( PaStream *s );
47
48
#ifdef __cplusplus
49
}
50
#endif
51
52
#endif
(-)b/audio/portaudio/files/patch-CMakeLists.txt (+35 lines)
Added Link Here
1
--- CMakeLists.txt.orig	2024-03-08 23:13:37 UTC
2
+++ CMakeLists.txt
3
@@ -349,6 +349,7 @@ elseif(UNIX)
4
         target_link_libraries(PortAudio PRIVATE "${ALSA_LIBRARIES}")
5
         set(PKGCONFIG_REQUIRES_PRIVATE "${PKGCONFIG_REQUIRES_PRIVATE} alsa")
6
       endif()
7
+      target_include_directories(PortAudio PRIVATE ${ALSA_INCLUDE_DIRS})
8
     endif()
9
 
10
     # OSS is intentionally off by default to avoid confusing users of PortAudio
11
@@ -393,11 +394,12 @@ elseif(UNIX)
12
     pkg_check_modules(SNDIO sndio)
13
     cmake_dependent_option(PA_USE_SNDIO "Enable support for sndio" ON SNDIO_FOUND OFF)
14
     if(PA_USE_SNDIO)
15
-      target_link_libraries(PortAudio PRIVATE "${SNDIO_LIBRARIES}")
16
+      target_link_libraries(PortAudio PRIVATE "${SNDIO_LINK_LIBRARIES}")
17
       target_sources(PortAudio PRIVATE src/hostapi/sndio/pa_sndio.c)
18
       target_compile_definitions(PortAudio PUBLIC PA_USE_SNDIO=1)
19
       set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -DPA_USE_SNDIO=1")
20
       set(PKGCONFIG_REQUIRES_PRIVATE "${PKGCONFIG_REQUIRES_PRIVATE} sndio")
21
+      target_include_directories(PortAudio PRIVATE ${SNDIO_INCLUDE_DIRS})
22
     endif()
23
   endif()
24
 endif()
25
@@ -418,8 +420,8 @@ target_sources(PortAudio PRIVATE ${PORTAUDIO_PUBLIC_HE
26
 include(CMakePackageConfigHelpers)
27
 
28
 if(NOT CMAKE_FRAMEWORK)
29
-  install(FILES README.md DESTINATION "${CMAKE_INSTALL_DOCDIR}/portaudio")
30
-  install(FILES LICENSE.txt DESTINATION "${CMAKE_INSTALL_DOCDIR}/portaudio")
31
+  install(FILES README.md DESTINATION "${CMAKE_INSTALL_DOCDIR}")
32
+  install(FILES LICENSE.txt DESTINATION "${CMAKE_INSTALL_DOCDIR}")
33
 
34
   configure_file(cmake/portaudio-2.0.pc.in "${CMAKE_CURRENT_BINARY_DIR}/portaudio-2.0.pc" @ONLY)
35
   install(FILES "${CMAKE_CURRENT_BINARY_DIR}/portaudio-2.0.pc"
(-)a/audio/portaudio/files/patch-Makefile.in (-11 lines)
Removed Link Here
1
$OpenBSD: patch-Makefile_in,v 1.4 2013/03/12 00:59:50 brad Exp $
2
--- Makefile.in.orig	2016-06-22 08:28:31 UTC
3
+++ Makefile.in
4
@@ -146,6 +146,7 @@ SRC_DIRS = \
5
 	src/hostapi/dsound \
6
 	src/hostapi/jack \
7
 	src/hostapi/oss \
8
+	src/hostapi/sndio \
9
 	src/hostapi/wasapi \
10
 	src/hostapi/wdmks \
11
 	src/hostapi/wmme \
(-)a/audio/portaudio/files/patch-configure.in (-47 lines)
Removed Link Here
1
$OpenBSD: patch-configure_in,v 1.4 2014/09/13 04:56:28 bentley Exp $
2
--- configure.in.orig	2016-06-22 08:28:31 UTC
3
+++ configure.in
4
@@ -24,6 +24,10 @@ AC_ARG_WITH(alsa,
5
             AS_HELP_STRING([--with-alsa], [Enable support for ALSA @<:@autodetect@:>@]),
6
             [with_alsa=$withval])
7
 
8
+AC_ARG_WITH(sndio,
9
+            AS_HELP_STRING([--with-sndio], [Enable support for sndio @<:@autodetect@:>@]),
10
+            [with_sndio=$withval])
11
+
12
 AC_ARG_WITH(jack,
13
             AS_HELP_STRING([--with-jack], [Enable support for JACK @<:@autodetect@:>@]),
14
             [with_jack=$withval])
15
@@ -120,6 +124,10 @@ have_alsa=no
16
 if test "x$with_alsa" != "xno"; then
17
     AC_CHECK_LIB(asound, snd_pcm_open, have_alsa=yes, have_alsa=no)
18
 fi
19
+have_sndio=no
20
+if test "x$with_sndio" != "xno"; then
21
+    AC_CHECK_LIB(sndio, sio_open, have_sndio=yes, have_sndio=no)
22
+fi
23
 have_asihpi=no
24
 if test "x$with_asihpi" != "xno"; then
25
     AC_CHECK_LIB(hpi, HPI_SubSysCreate, have_asihpi=yes, have_asihpi=no, -lm)
26
@@ -397,6 +405,13 @@ case "${host_os}" in
27
            AC_DEFINE(PA_USE_ALSA,1)
28
         fi
29
 
30
+        if [[ "$have_sndio" = "yes" -a "$with_sndio" != "no" ]] ; then
31
+           DLL_LIBS="$DLL_LIBS -lsndio"
32
+           LIBS="$LIBS -lsndio"
33
+           OTHER_OBJS="$OTHER_OBJS src/hostapi/sndio/pa_sndio.o"
34
+           AC_DEFINE(PA_USE_SNDIO,1)
35
+        fi
36
+
37
         if [[ "$have_jack" = "yes" ] && [ "$with_jack" != "no" ]] ; then
38
            DLL_LIBS="$DLL_LIBS $JACK_LIBS"
39
            CFLAGS="$CFLAGS $JACK_CFLAGS"
40
@@ -500,6 +515,7 @@ case "$target_os" in
41
         ;;
42
      *)
43
 	AC_MSG_RESULT([
44
+  Sndio ....................... $have_sndio
45
   OSS ......................... $have_oss
46
   JACK ........................ $have_jack
47
 ])
(-)a/audio/portaudio/files/patch-include_portaudio.h (-29 lines)
Removed Link Here
1
$OpenBSD: patch-include_portaudio_h,v 1.2 2013/03/12 00:59:50 brad Exp $
2
--- include/portaudio.h.orig	2018-07-17 06:55:08 UTC
3
+++ include/portaudio.h
4
@@ -236,7 +236,8 @@ typedef enum PaHostApiTypeId
5
     paWDMKS=11,
6
     paJACK=12,
7
     paWASAPI=13,
8
-    paAudioScienceHPI=14
9
+    paAudioScienceHPI=14,
10
+    paSndio=15
11
 } PaHostApiTypeId;
12
 
13
 
14
@@ -1144,6 +1145,15 @@ signed long Pa_GetStreamReadAvailable( PaStream* strea
15
  error is encountered.
16
 */
17
 signed long Pa_GetStreamWriteAvailable( PaStream* stream );
18
+
19
+
20
+/** Retrieve the host type handling an open stream.
21
+
22
+ @return Returns a non-negative value representing the host API type
23
+ handling an open stream or, a PaErrorCode (which are always negative)
24
+ if PortAudio is not initialized or an error is encountered.
25
+*/
26
+PaHostApiTypeId Pa_GetStreamHostApiType( PaStream* stream );
27
 
28
 
29
 /* Miscellaneous utilities */
(-)a/audio/portaudio/files/patch-src_common_pa__front.c (-47 lines)
Removed Link Here
1
--- src/common/pa_front.c.orig	2018-07-17 06:44:39 UTC
2
+++ src/common/pa_front.c
3
@@ -1216,8 +1216,10 @@ PaError Pa_OpenStream( PaStream** stream,
4
                                   hostApiInputParametersPtr, hostApiOutputParametersPtr,
5
                                   sampleRate, framesPerBuffer, streamFlags, streamCallback, userData );
6
 
7
-    if( result == paNoError )
8
+    if( result == paNoError ) {
9
         AddOpenStream( *stream );
10
+        PA_STREAM_REP(*stream)->hostApiType = hostApi->info.type;
11
+    }
12
 
13
 
14
     PA_LOGAPI(("Pa_OpenStream returned:\n" ));
15
@@ -1729,6 +1731,32 @@ signed long Pa_GetStreamWriteAvailable( PaStream* stre
16
     return result;
17
 }
18
 
19
+PaHostApiTypeId Pa_GetStreamHostApiType( PaStream* stream )
20
+{
21
+    PaError error = PaUtil_ValidateStreamPointer( stream );
22
+    PaHostApiTypeId result;
23
+
24
+#ifdef PA_LOG_API_CALLS
25
+    PaUtil_DebugPrint("Pa_GetStreamHostApiType called:\n" );
26
+    PaUtil_DebugPrint("\tPaStream* stream: 0x%p\n", stream );
27
+#endif
28
+
29
+    if( error == paNoError )
30
+    {
31
+        result = PA_STREAM_REP(stream)->hostApiType;
32
+    }
33
+    else
34
+    {
35
+        result = (PaHostApiTypeId) error;
36
+    }
37
+
38
+#ifdef PA_LOG_API_CALLS
39
+    PaUtil_DebugPrint("Pa_GetStreamHostApiType returned:\n" );
40
+    PaUtil_DebugPrint("\tPaError: %d ( %s )\n\n", result, Pa_GetErrorText( result ) );
41
+#endif
42
+
43
+    return result;
44
+}
45
 
46
 PaError Pa_GetSampleSize( PaSampleFormat format )
47
 {
(-)a/audio/portaudio/files/patch-src_common_pa__stream.c (-11 lines)
Removed Link Here
1
--- src/common/pa_stream.c.orig	2018-07-17 06:44:39 UTC
2
+++ src/common/pa_stream.c
3
@@ -93,6 +93,8 @@ void PaUtil_InitializeStreamRepresentation( PaUtilStre
4
     streamRepresentation->streamInfo.inputLatency = 0.;
5
     streamRepresentation->streamInfo.outputLatency = 0.;
6
     streamRepresentation->streamInfo.sampleRate = 0.;
7
+
8
+    streamRepresentation->hostApiType = 0;
9
 }
10
 
11
 
(-)a/audio/portaudio/files/patch-src_common_pa__stream.h (-10 lines)
Removed Link Here
1
--- src/common/pa_stream.h.orig	2018-07-17 06:44:39 UTC
2
+++ src/common/pa_stream.h
3
@@ -152,6 +152,7 @@ typedef struct PaUtilStreamRepresentation {
4
     PaStreamFinishedCallback *streamFinishedCallback;
5
     void *userData;
6
     PaStreamInfo streamInfo;
7
+    PaHostApiTypeId hostApiType;
8
 } PaUtilStreamRepresentation;
9
 
10
 
(-)b/audio/portaudio/files/patch-src_hostapi_alsa_pa__linux__alsa.c (+72 lines)
Added Link Here
1
--- src/hostapi/alsa/pa_linux_alsa.c.orig	2024-03-08 23:13:37 UTC
2
+++ src/hostapi/alsa/pa_linux_alsa.c
3
@@ -849,6 +849,7 @@ static PaError GropeDevice( snd_pcm_t* pcm, int isPlug
4
     double * defaultLowLatency, * defaultHighLatency, * defaultSampleRate =
5
         &devInfo->baseDeviceInfo.defaultSampleRate;
6
     double defaultSr = *defaultSampleRate;
7
+    int dir;
8
 
9
     assert( pcm );
10
 
11
@@ -889,10 +890,11 @@ static PaError GropeDevice( snd_pcm_t* pcm, int isPlug
12
     if( defaultSr < 0. )           /* Default sample rate not set */
13
     {
14
         unsigned int sampleRate = 44100;        /* Will contain approximate rate returned by alsa-lib */
15
+        dir = 0;
16
 
17
         /* Don't allow rate resampling when probing for the default rate (but ignore if this call fails) */
18
         alsa_snd_pcm_hw_params_set_rate_resample( pcm, hwParams, 0 );
19
-        if( alsa_snd_pcm_hw_params_set_rate_near( pcm, hwParams, &sampleRate, NULL ) < 0 )
20
+        if( alsa_snd_pcm_hw_params_set_rate_near( pcm, hwParams, &sampleRate, &dir ) < 0 )
21
         {
22
             result = paUnanticipatedHostError;
23
             goto error;
24
@@ -902,7 +904,7 @@ static PaError GropeDevice( snd_pcm_t* pcm, int isPlug
25
 
26
     ENSURE_( alsa_snd_pcm_hw_params_get_channels_min( hwParams, &minChans ), paUnanticipatedHostError );
27
     ENSURE_( alsa_snd_pcm_hw_params_get_channels_max( hwParams, &maxChans ), paUnanticipatedHostError );
28
-    const unsigned int kReasonableMaxChannels = 1024;
29
+    const unsigned int kReasonableMaxChannels = 10000;	/* alsa-lib-*?/src/pcm/pcm_plug.c snd_pcm_plug_hw_refine_cprepare */
30
     if( maxChans > kReasonableMaxChannels )
31
     {
32
         PA_DEBUG(( "%s: maxChans = %u, which is unreasonably high\n", __FUNCTION__, maxChans ));
33
@@ -938,18 +940,20 @@ static PaError GropeDevice( snd_pcm_t* pcm, int isPlug
34
     /* Try low latency values, (sometimes the buffer & period that result are larger) */
35
     alsaBufferFrames = 512;
36
     alsaPeriodFrames = 128;
37
+    dir = 0;
38
     ENSURE_( alsa_snd_pcm_hw_params_set_buffer_size_near( pcm, hwParams, &alsaBufferFrames ), paUnanticipatedHostError );
39
-    ENSURE_( alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, NULL ), paUnanticipatedHostError );
40
+    ENSURE_( alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir ), paUnanticipatedHostError );
41
     *defaultLowLatency = (double) (alsaBufferFrames - alsaPeriodFrames) / defaultSr;
42
 
43
     /* Base the high latency case on values four times larger */
44
     alsaBufferFrames = 2048;
45
     alsaPeriodFrames = 512;
46
+    dir = 0;
47
     /* Have to reset hwParams, to set new buffer size; need to also set sample rate again */
48
     ENSURE_( alsa_snd_pcm_hw_params_any( pcm, hwParams ), paUnanticipatedHostError );
49
     ENSURE_( SetApproximateSampleRate( pcm, hwParams, defaultSr ), paUnanticipatedHostError );
50
     ENSURE_( alsa_snd_pcm_hw_params_set_buffer_size_near( pcm, hwParams, &alsaBufferFrames ), paUnanticipatedHostError );
51
-    ENSURE_( alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, NULL ), paUnanticipatedHostError );
52
+    ENSURE_( alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir ), paUnanticipatedHostError );
53
     *defaultHighLatency = (double) (alsaBufferFrames - alsaPeriodFrames) / defaultSr;
54
 
55
     *minChannels = (int)minChans;
56
@@ -3234,13 +3238,15 @@ static int SetApproximateSampleRate( snd_pcm_t *pcm, s
57
 {
58
     PaError result = paNoError;
59
     unsigned int reqRate, setRate, deviation;
60
+    int dir;
61
 
62
     assert( pcm && hwParams );
63
 
64
     /* The Alsa sample rate is set by integer value; also the actual rate may differ */
65
     reqRate = setRate = (unsigned int) sampleRate;
66
+    dir = 0;
67
 
68
-    ENSURE_( alsa_snd_pcm_hw_params_set_rate_near( pcm, hwParams, &setRate, NULL ), paUnanticipatedHostError );
69
+    ENSURE_( alsa_snd_pcm_hw_params_set_rate_near( pcm, hwParams, &setRate, &dir ), paUnanticipatedHostError );
70
     /* The value actually set will be put in 'setRate' (may be way off); check the deviation as a proportion
71
      * of the requested-rate with reference to the max-deviate-ratio (larger values allow less deviation) */
72
     deviation = abs( (int)setRate - (int)reqRate );
(-)b/audio/portaudio/files/patch-src_hostapi_oss_pa__unix__oss.c (-45 / +15 lines)
Lines 1-48 Link Here
1
--- src/hostapi/oss/pa_unix_oss.c.orig	2019-03-01 03:09:23 UTC
1
--- src/hostapi/oss/pa_unix_oss.c.orig	2024-03-08 23:13:37 UTC
2
+++ src/hostapi/oss/pa_unix_oss.c
2
+++ src/hostapi/oss/pa_unix_oss.c
3
@@ -535,13 +535,13 @@ static PaError BuildDeviceList( PaOSSHostApiRepresenta
3
@@ -683,13 +683,13 @@ static PaError IsFormatSupported( struct PaUtilHostApi
4
      * add it to a linked list.
5
      * A: Set an arbitrary of 100 devices, should probably be a smarter way. */
6
 
4
 
7
-    for( i = 0; i < 100; i++ )
5
     if( inputChannelCount > 0 )
8
+    for( i = -1; i < 100; i++ )
9
     {
6
     {
10
        char deviceName[32];
7
-        result = PaUtil_DeviceIndexToHostApiDeviceIndex(&device, inputParameters->device, hostApi);
11
        PaDeviceInfo *deviceInfo;
8
+        result = PaUtil_DeviceIndexToHostApiDeviceIndex(&device, inputParameters->device + hostApi->privatePaFrontInfo.baseDeviceIndex, hostApi);
12
        int testResult;
9
         if (result != paNoError)
13
 
10
             return result;
14
-       if( i == 0 )
11
     }
15
+       if( i == -1 )
12
     else
16
           snprintf(deviceName, sizeof (deviceName), "%s", DEVICE_NAME_BASE);
13
     {
17
        else
14
-        result = PaUtil_DeviceIndexToHostApiDeviceIndex(&device, outputParameters->device, hostApi);
18
           snprintf(deviceName, sizeof (deviceName), "%s%d", DEVICE_NAME_BASE, i);
15
+        result = PaUtil_DeviceIndexToHostApiDeviceIndex(&device, outputParameters->device + hostApi->privatePaFrontInfo.baseDeviceIndex, hostApi);
19
@@ -2041,5 +2041,29 @@ static signed long GetStreamWriteAvailable( PaStream* 
16
         if (result != paNoError)
20
 error:
17
             return result;
21
     return result;
18
     }
22
 #endif
23
+}
24
+
25
+const char *PaOSS_GetStreamInputDevice( PaStream* s )
26
+{
27
+    PaOssStream *stream = (PaOssStream*)s;
28
+
29
+    if( stream->capture )
30
+    {
31
+      return stream->capture->devName;
32
+    }
33
+
34
+   return NULL;
35
+}
36
+
37
+const char *PaOSS_GetStreamOutputDevice( PaStream* s )
38
+{
39
+    PaOssStream *stream = (PaOssStream*)s;
40
+
41
+    if( stream->playback )
42
+    {
43
+      return stream->playback->devName;
44
+    }
45
+
46
+   return NULL;
47
 }
48
 
(-)b/audio/portaudio/files/patch-src_hostapi_pulseaudio_pa__linux__pulseaudio__cb.c (+19 lines)
Added Link Here
1
--- src/hostapi/pulseaudio/pa_linux_pulseaudio_cb.c.orig	2024-03-08 23:13:37 UTC
2
+++ src/hostapi/pulseaudio/pa_linux_pulseaudio_cb.c
3
@@ -569,9 +569,15 @@ PaError PaPulseAudio_CloseStreamCb( PaStream * s )
4
 
5
         if((stream->outputStream == NULL
6
            && stream->inputStream == NULL)
7
-           || pulseaudioError >= 5000 )
8
+           )
9
         {
10
             waitLoop = 1;
11
+PA_DEBUG(("PortAudio %s %d %s: pulseaudioError repeated %d.\n", __FILE__, __LINE__, __FUNCTION__, pulseaudioError));
12
+        }
13
+        if ( pulseaudioError >= 5000 )
14
+        {
15
+            waitLoop = 1;
16
+PA_DEBUG(("PortAudio %s %d %s: pulseaudioError reached %d.\n", __FILE__, __LINE__, __FUNCTION__, pulseaudioError));
17
         }
18
 
19
         pulseaudioError ++;
(-)a/audio/portaudio/files/patch-src_os_unix_pa__unix__hostapis.c (-26 lines)
Removed Link Here
1
$OpenBSD: patch-src_os_unix_pa_unix_hostapis_c,v 1.2 2013/03/12 00:59:50 brad Exp $
2
3
Difference to OpenBSD patch: PA_USE_SNDIO has been moved before
4
PA_USE_OSS, so that portaudio prefers the sndio output.
5
6
--- src/os/unix/pa_unix_hostapis.c.orig	2018-07-17 07:08:09 UTC
7
+++ src/os/unix/pa_unix_hostapis.c
8
@@ -44,6 +44,7 @@
9
 
10
 PaError PaJack_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index );
11
 PaError PaAlsa_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index );
12
+PaError PaSndio_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index );
13
 PaError PaOSS_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index );
14
 /* Added for IRIX, Pieter, oct 2, 2003: */
15
 PaError PaSGI_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index );
16
@@ -68,6 +69,10 @@ PaUtilHostApiInitializer *paHostApiInitializers[] =
17
 #endif
18
 
19
 #else   /* __linux__ */
20
+
21
+#ifdef PA_USE_SNDIO
22
+	PaSndio_Initialize,
23
+#endif
24
 
25
 #if PA_USE_OSS
26
         PaOSS_Initialize,
(-)b/audio/portaudio/pkg-plist (-27 / +30 lines)
Lines 1-4 Link Here
1
%%EXAMPLES%%bin/pa_devs
2
%%EXAMPLES%%bin/pa_fuzz
1
%%PATEST%%bin/pa_minlat
3
%%PATEST%%bin/pa_minlat
4
%%EXAMPLES%%bin/paex_ocean_shore
5
%%EXAMPLES%%bin/paex_pink
6
%%EXAMPLES%%bin/paex_read_write_wire
7
%%EXAMPLES%%bin/paex_record
8
%%EXAMPLES%%bin/paex_record_file
9
%%EXAMPLES%%bin/paex_saw
10
%%EXAMPLES%%bin/paex_sine
11
%%EXAMPLES%%bin/paex_sine_c++
12
%%EXAMPLES%%bin/paex_write_sine
13
%%EXAMPLES%%bin/paex_write_sine_nonint
2
%%PATEST%%bin/paqa_devs
14
%%PATEST%%bin/paqa_devs
3
%%PATEST%%bin/paqa_errs
15
%%PATEST%%bin/paqa_errs
4
%%PATEST%%bin/paqa_latency
16
%%PATEST%%bin/paqa_latency
Lines 6-12 Link Here
6
%%PATEST%%bin/patest_buffer
18
%%PATEST%%bin/patest_buffer
7
%%PATEST%%bin/patest_callbackstop
19
%%PATEST%%bin/patest_callbackstop
8
%%PATEST%%bin/patest_clip
20
%%PATEST%%bin/patest_clip
21
%%PATEST%%bin/patest_converters
9
%%PATEST%%bin/patest_dither
22
%%PATEST%%bin/patest_dither
23
%%PATEST%%bin/patest_enumerate_default_latency
10
%%PATEST%%bin/patest_hang
24
%%PATEST%%bin/patest_hang
11
%%PATEST%%bin/patest_in_overflow
25
%%PATEST%%bin/patest_in_overflow
12
%%PATEST%%bin/patest_latency
26
%%PATEST%%bin/patest_latency
Lines 18-23 Link Here
18
%%PATEST%%bin/patest_multi_sine
32
%%PATEST%%bin/patest_multi_sine
19
%%PATEST%%bin/patest_out_underflow
33
%%PATEST%%bin/patest_out_underflow
20
%%PATEST%%bin/patest_prime
34
%%PATEST%%bin/patest_prime
35
%%PATEST%%bin/patest_read_record
21
%%PATEST%%bin/patest_ringmix
36
%%PATEST%%bin/patest_ringmix
22
%%PATEST%%bin/patest_sine8
37
%%PATEST%%bin/patest_sine8
23
%%PATEST%%bin/patest_sine_channelmaps
38
%%PATEST%%bin/patest_sine_channelmaps
Lines 27-65 Link Here
27
%%PATEST%%bin/patest_start_stop
42
%%PATEST%%bin/patest_start_stop
28
%%PATEST%%bin/patest_stop
43
%%PATEST%%bin/patest_stop
29
%%PATEST%%bin/patest_stop_playout
44
%%PATEST%%bin/patest_stop_playout
45
%%PATEST%%bin/patest_suggested_vs_streaminfo_latency
46
%%PATEST%%bin/patest_sync
47
%%PATEST%%bin/patest_timing
30
%%PATEST%%bin/patest_toomanysines
48
%%PATEST%%bin/patest_toomanysines
31
%%PATEST%%bin/patest_two_rates
49
%%PATEST%%bin/patest_two_rates
32
%%PATEST%%bin/patest_underflow
50
%%PATEST%%bin/patest_underflow
51
%%PATEST%%bin/patest_unplug
33
%%PATEST%%bin/patest_wire
52
%%PATEST%%bin/patest_wire
53
%%PATEST%%bin/patest_write_stop
54
%%PATEST%%bin/patest_write_stop_hang_illegal
34
%%JACK%%include/pa_jack.h
55
%%JACK%%include/pa_jack.h
35
include/pa_unix_oss.h
56
%%ALSA%%include/pa_linux_alsa.h
36
include/portaudio.h
57
include/portaudio.h
37
include/portaudiocpp/AutoSystem.hxx
58
lib/cmake/portaudio/PortAudioConfig.cmake
38
include/portaudiocpp/BlockingStream.hxx
59
lib/cmake/portaudio/PortAudioConfigVersion.cmake
39
include/portaudiocpp/CFunCallbackStream.hxx
60
lib/cmake/portaudio/PortAudioTargets-%%CMAKE_BUILD_TYPE%%.cmake
40
include/portaudiocpp/CallbackInterface.hxx
61
lib/cmake/portaudio/PortAudioTargets.cmake
41
include/portaudiocpp/CallbackStream.hxx
62
%%JACK%%lib/cmake/portaudio/modules/FindJACK.cmake
42
include/portaudiocpp/CppFunCallbackStream.hxx
63
%%PULSEAUDIO%%lib/cmake/portaudio/modules/FindPulseAudio.cmake
43
include/portaudiocpp/Device.hxx
64
%%JACK%%lib/cmake/portaudio/modules/FindRegex.cmake
44
include/portaudiocpp/DirectionSpecificStreamParameters.hxx
45
include/portaudiocpp/Exception.hxx
46
include/portaudiocpp/HostApi.hxx
47
include/portaudiocpp/InterfaceCallbackStream.hxx
48
include/portaudiocpp/MemFunCallbackStream.hxx
49
include/portaudiocpp/PortAudioCpp.hxx
50
include/portaudiocpp/SampleDataFormat.hxx
51
include/portaudiocpp/Stream.hxx
52
include/portaudiocpp/StreamParameters.hxx
53
include/portaudiocpp/System.hxx
54
include/portaudiocpp/SystemDeviceIterator.hxx
55
include/portaudiocpp/SystemHostApiIterator.hxx
56
lib/libportaudio.a
57
lib/libportaudio.so
65
lib/libportaudio.so
66
lib/libportaudio.so.19.8
58
lib/libportaudio.so.2
67
lib/libportaudio.so.2
59
lib/libportaudio.so.2.0.0
60
lib/libportaudiocpp.a
61
lib/libportaudiocpp.so
62
lib/libportaudiocpp.so.0
63
lib/libportaudiocpp.so.0.0.12
64
libdata/pkgconfig/portaudio-2.0.pc
68
libdata/pkgconfig/portaudio-2.0.pc
65
libdata/pkgconfig/portaudiocpp.pc

Return to bug 259255