sndio_driver.c:

- make it work with 24-bit formats (as with azalia and envy)
- use the correct member of struct sio_par for the buffer size
- check both poll(2) revents as well as calculated buffer positions
to know when we can read/write data
sun_driver.c:
- make it work with 24-bit formats (as with azalia and envy)
jackd/engine.c:
- don't spam error messages every time a client quits
add README.OpenBSD
This commit is contained in:
jakemsr 2009-12-09 10:15:08 +00:00
parent d90a9cddd6
commit 1d211a19db
6 changed files with 163 additions and 57 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.9 2009/03/13 23:06:14 jakemsr Exp $
# $OpenBSD: Makefile,v 1.10 2009/12/09 10:15:08 jakemsr Exp $
SHARED_ONLY = Yes
@ -6,7 +6,7 @@ COMMENT = low latency sound server
V = 0.116.1
DISTNAME = jack-audio-connection-kit-${V}
PKGNAME = jack-${V}p2
PKGNAME = jack-${V}p3
SHARED_LIBS += jack 0.0 # 0.28
SHARED_LIBS += jackserver 0.0 # 0.28
@ -66,4 +66,8 @@ post-patch:
cd ${WRKSRC} && AUTOMAKE_VERSION=${AUTOMAKE_VERSION} \
AUTOCONF_VERSION=${AUTOCONF_VERSION} autoconf
post-install:
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/jack
${INSTALL_DATA} ${FILESDIR}/README.OpenBSD ${PREFIX}/share/doc/jack
.include <bsd.port.mk>

View File

@ -0,0 +1,60 @@
In this package of jackd, the 'dummy', 'sun' and 'sndio' drivers are
supported. The 'dummy' driver is mostly useful for testing jackd itself.
The 'sun' driver uses the audio(4) subsystem. The 'sndio' driver uses
sndio(7). To start jackd with default driver parameters, use the
command 'jackd -d <driver>'.
By default, jackd runs in full-duplex mode with a relatively low
latency. This may not be exactly what you want, and it may not be
possible with all hardware. Therefore, some configuration options may
be necessary to effectively use jackd. The 'sun' and 'sndio' drivers
use mostly the same configuration options, which can be viewed with the
command 'jackd -d <driver> -h'. Below are some tips and caveats to
consider when using jackd on OpenBSD.
Some audio devices do not support full-duplex operation. If jackd
errors out on startup with a message about opening a full-duplex
device, this is likely the problem. If the device only supports
playback, then the driver needs to be configured to use 0 input
channels. For example 'jackd -d <driver> -i 0' starts jackd in
half-duplex play-only mode.
By default jackd uses 2 periods (blocks) of 1024 frames each. This
means there will be at most 2048 frames in the playback buffer. Some
slower or loaded machines may not be able to keep the playback buffer
from underrunning with these conditions. Jackd is designed to use 2
periods, so if underruns are observed, it is best to first increase
the period size with the driver's -p option. The period size should
be a power of two. The number of periods can be increased with the
-n option. For example, 'jackd -d <driver> -p 2048 -n 3'.
The 'sun' driver uses 48000 and the sndio driver uses 44100 Hz
sampling rates by default. Some devices may not support the default
sampe rate. Or it may be that most of the audio that will pass
through jackd is based on a different sample rate. Avoiding sample
rate conversion will use less CPU cycles and perserve audio quality.
The -r option can be used to change the sampling rate as in 'jackd -d
sun -r 44100'.
The realtime option -R is commonly used on other operating systems.
However, this option is inconsequential on OpenBSD.
The 'sun' driver reports xruns on stdout. The 'sndio' driver does
not. The 'sndio' driver is more likely to continue to be developed.
Unless you need xrun reporting, the 'sndio' driver is recommended.
It is possible to run jackd on top of aucat(1) with the 'sndio'
driver. However, there are some caveats. First, the aucat server
must be running at a higher than default scheduling priority.
aucat(1) has an example for doing this with renice(8). Secondly, it
is a very good idea to make sure the sample rates used for jackd and
aucat are the same. Third, period sizes in aucat and jackd must be
the same. Finally, jackd must be configured to use at least 4
periods. The following command sequence starts aucat and jackd such
that they can work together.
$ aucat -l -b 512 -z 256 -r 48000
$ sudo renice -10 `pgrep -x aucat`
$ jackd -d sndio -p 256 -n 4 -r 48000
There is no MIDI driver for OpenBSD in jackd.

View File

@ -244,8 +244,6 @@ sndio_driver_set_parameters (sndio_driver_t *driver)
unsigned int nperiods;
int mode = 0;
driver->sample_bytes = driver->bits / 8;
if (driver->capture_channels > 0)
mode |= SIO_REC;
@ -261,6 +259,12 @@ sndio_driver_set_parameters (sndio_driver_t *driver)
return -1;
}
if (driver->bits != 16 && driver->bits != 24 && driver->bits != 32)
{
jack_error("sndio_driver: invalid sample bits");
return -1;
}
sio_initpar(&par);
par.sig = 1;
par.bits = driver->bits;
@ -295,8 +299,9 @@ sndio_driver_set_parameters (sndio_driver_t *driver)
}
period_size = par.round;
nperiods = par.bufsz / par.round;
driver->buffer_fill = par.bufsz;
nperiods = par.appbufsz / par.round;
driver->buffer_fill = par.appbufsz;
driver->sample_bytes = par.bps;
if (period_size != 0 && !driver->ignorehwbuf &&
(period_size != driver->period_size ||
@ -403,16 +408,17 @@ sndio_driver_wait (sndio_driver_t *driver, int *status, float *iodelay)
driver->poll_next = 0;
}
snfds = sio_nfds(driver->hdl);
while (need_capture || need_playback)
{
events = revents = 0;
events = 0;
if (need_capture != 0)
events |= POLLIN;
if (need_playback != 0)
events |= POLLOUT;
snfds = sio_nfds(driver->hdl);
if (snfds != sio_pollfd(driver->hdl, &pfd, events)) {
jack_error("sndio_driver: sio_pollfd failed: %s@%i",
__FILE__, __LINE__);
@ -455,10 +461,12 @@ sndio_driver_wait (sndio_driver_t *driver, int *status, float *iodelay)
if (driver->realpos > driver->cappos)
used = driver->realpos - driver->cappos;
cap_avail = used;
if (cap_avail >= driver->period_size)
need_capture = 0;
if (cap_avail > driver->buffer_fill)
{
jack_error("sndio_driver: capture overrun");
}
jack_error("sndio_driver: capture xrun");
}
if (driver->playback_channels > 0)
@ -467,31 +475,12 @@ sndio_driver_wait (sndio_driver_t *driver, int *status, float *iodelay)
if (driver->playpos > driver->realpos)
used = driver->playpos - driver->realpos;
play_avail = driver->buffer_fill - used;
if (play_avail > driver->buffer_fill)
{
jack_error("sndio_driver: playback underrun");
}
}
if (driver->capture_channels > 0 &&
driver->playback_channels > 0)
{
if ((driver->realpos > 0 &&
(play_avail != driver->period_size ||
cap_avail != driver->period_size) &&
!(!play_avail && !cap_avail && !need_playback &&
need_capture)) ||
(driver->realpos == 0 &&
!play_avail && !cap_avail && need_playback &&
!need_capture))
{
jack_error("sndio_driver: out of sync: "
"rp=%lld pa=%lld ca=%lld np=%d nc=%d",
driver->realpos, play_avail, cap_avail,
need_playback, need_capture);
*status = -5;
return 0;
}
if (play_avail >= driver->period_size)
need_playback = 0;
if (play_avail > driver->buffer_fill)
jack_error("sndio_driver: playback xrun");
}
}
@ -579,14 +568,6 @@ copy_and_convert_in (jack_sample_t *dst, void *src,
}
break;
case 24:
scale = 1.0f / 0x7fffff;
for (dstidx = 0; dstidx < nframes; dstidx++)
{
dst[dstidx] = (jack_sample_t)
s32src[srcidx] * scale;
srcidx += chcount;
}
break;
case 32:
scale = 1.0f / 0x7fffffff;
for (dstidx = 0; dstidx < nframes; dstidx++)
@ -633,16 +614,6 @@ copy_and_convert_out (void *dst, jack_sample_t *src,
}
break;
case 24:
scale = 0x7fffff;
for (srcidx = 0; srcidx < nframes; srcidx++)
{
s32dst[dstidx] = (signed int)
(src[srcidx] >= 0.0f) ?
(src[srcidx] * scale + 0.5f) :
(src[srcidx] * scale - 0.5f);
dstidx += chcount;
}
break;
case 32:
scale = 0x7fffffff;
for (srcidx = 0; srcidx < nframes; srcidx++)

View File

@ -0,0 +1,55 @@
$OpenBSD: patch-drivers_sun_sun_driver_c,v 1.4 2009/12/09 10:15:08 jakemsr Exp $
--- drivers/sun/sun_driver.c.orig Wed Jul 2 23:47:34 2008
+++ drivers/sun/sun_driver.c Wed Dec 9 00:40:08 2009
@@ -468,14 +468,6 @@ copy_and_convert_in (jack_sample_t *dst, void *src,
}
break;
case 24:
- scale = 1.0f / 0x7fffff;
- for (dstidx = 0; dstidx < nframes; dstidx++)
- {
- dst[dstidx] = (jack_sample_t)
- s32src[srcidx] * scale;
- srcidx += chcount;
- }
- break;
case 32:
scale = 1.0f / 0x7fffffff;
for (dstidx = 0; dstidx < nframes; dstidx++)
@@ -522,16 +514,6 @@ copy_and_convert_out (void *dst, jack_sample_t *src,
}
break;
case 24:
- scale = 0x7fffff;
- for (srcidx = 0; srcidx < nframes; srcidx++)
- {
- s32dst[dstidx] = (signed int)
- (src[srcidx] >= 0.0f) ?
- (src[srcidx] * scale + 0.5f) :
- (src[srcidx] * scale - 0.5f);
- dstidx += chcount;
- }
- break;
case 32:
scale = 0x7fffffff;
for (srcidx = 0; srcidx < nframes; srcidx++)
@@ -771,7 +753,18 @@ sun_driver_set_parameters (sun_driver_t *driver)
driver->indevbuf = NULL;
driver->outdevbuf = NULL;
- driver->sample_bytes = driver->bits / 8;
+ switch (driver->bits) {
+ case 16:
+ driver->sample_bytes = 2;
+ break;
+ case 24:
+ case 32:
+ driver->sample_bytes = 4;
+ break;
+ default:
+ jack_error("sun_driver: invalid sample bits");
+ return -1;
+ }
if ((strcmp(indev, outdev) == 0) &&
((driver->capture_channels > 0) && (driver->playback_channels > 0)))

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-jackd_engine_c,v 1.6 2009/01/11 10:51:46 jakemsr Exp $
--- jackd/engine.c.orig Sun Jun 15 01:46:11 2008
+++ jackd/engine.c Wed Dec 31 14:51:46 2008
$OpenBSD: patch-jackd_engine_c,v 1.7 2009/12/09 10:15:08 jakemsr Exp $
--- jackd/engine.c.orig Tue Dec 2 08:29:23 2008
+++ jackd/engine.c Mon Dec 7 22:18:52 2009
@@ -1383,7 +1383,7 @@ handle_external_client_request (jack_engine_t *engine,
if ((r = read (client->request_fd, &req, sizeof (req)))
< (ssize_t) sizeof (req)) {
@ -10,3 +10,17 @@ $OpenBSD: patch-jackd_engine_c,v 1.6 2009/01/11 10:51:46 jakemsr Exp $
/* poll is implemented using
select (see the macosx/fakepoll
code). When the socket is closed
@@ -1561,9 +1561,13 @@ jack_server_thread (void *arg)
} else if (engine->pfd[i].revents & POLLIN) {
if (handle_external_client_request (engine, engine->pfd[i].fd)) {
+#if 0
jack_error ("could not handle external"
" client request");
jack_engine_signal_problems (engine);
+#else
+ ;
+#endif
}
}
}

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST,v 1.4 2009/01/11 10:51:46 jakemsr Exp $
@comment $OpenBSD: PLIST,v 1.5 2009/12/09 10:15:08 jakemsr Exp $
@bin bin/jack_alias
@bin bin/jack_connect
@bin bin/jack_disconnect
@ -49,3 +49,5 @@ lib/libjackserver.la
lib/pkgconfig/jack.pc
@man man/man1/jackd.1
@man man/man1/jackstart.1
share/doc/jack/
share/doc/jack/README.OpenBSD