Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 09 Jun 2023 00:14:16 +0200
From:      Florian Walpen <dev@submerge.ch>
To:        multimedia@freebsd.org
Subject:   Upcoming JACK changes, new OSS API backend
Message-ID:  <2036330.x0N0T6uNKo@z800>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.

--nextPart2212280.sMrx5ctUpN
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"

Hi there,

to those interested in JACK audio server (audio/jack), I'm currently testing 
an overhauled OSS API backend for FreeBSD. I intend to merge that into the 
next JACK release (not planned yet). Here is some information in advance, and 
a chance to beta-test the backend before it hits the ports.

Main motivation for the new backend was to improve the situation for low 
latency requirements (live mixing and effects). Also to separate the OSS sync 
logic into a reusable library, for JACK audio adapters or another audio server 
in the future.


User Facing Changes:
====================
 - More robust operation with stable latencies +/- 1ms.
 - Avoid problems that may occur when the OSS buffer sizes are changed.
 - Low latency operation (4-6ms round-trip) on specific hardware.
 - The nperiod parameter is deprecated, always 1 (former default value).
 - Supposedly works with little-endian samples on big-endian systems.

Please note that for low latency you need a well tuned system (reliable 
timers) and the right hardware. So far I only know of the snd_hdspe driver 
which clocks in a round-trip-time of ~3ms at extreme settings, including DA -> 
AD conversion. Other PCI drivers may be worth a try, but USB interfaces always 
incurred a minimum latency of ~20ms in my tests which is not suitable for live 
processing.

On a side note, snd_hdspe may need some love - it splits the interface into 
18(!) 2-channel devices, which is fine for media consumption but somewhat 
impractical for audio work. Next project for me ;-)

I neither possess big-endian machines nor audio interfaces that take big-
endian samples, so I cannot test the last point. Glad to hear about any 
experience with mixed endianness.


Technical Changes:
==================
 - Use a new C++ header-only library for the OSS low level and sync logic.
 - Time based polling mechanism instead of poll() system calls.
 - Memory-map the OSS buffer where available, FreeBSD 13.2 and newer.
 - Fallback to read() / write() IO, FreeBSD prior to 13.2, virtual_oss.
 - Separate assist thread takes over when main JACK thread is busy.
 - Leaves the OSS buffer sizes untouched, which may cause troubles.
 - Applies an internal double buffer scheme instead.

Although memory mapped operation is possible on FreeBSD prior to 13.2, it is 
broken for many sample formats (non-power-of-2). The advantage of memory 
mapping is more about robustness than performance. And the time based polling 
is a requirement there, it doesn't work with poll().

The double buffer scheme and the assist thread decouple the internal buffer 
size (period) from the OSS buffer size. JACK should now cope much better with 
large periods against small OSS buffer sizes, and vice versa.


Beta Test:
==========
If you're interested enough to read up to this point, you may as well try it.
 - The attached patch can be applied to the ports tree with "git am".
 - Fetches from my github fork, not yet merged to the official JACK repo.
 - Same JACK version as before, but PORTREVISION is obviously off the mark.

Sources are fetched from here:
https://github.com/0EVSG/jack2/commits/freebsd_sosso

In case of regressions or otherwise unexpected encounters please send me the 
logs of the particular session. The logs can be found in
/var/log/jackd.log
or
~/.log/jack/jackdbus.log

Don't expect any miracles, if there's no regressions I'm already happy. 
And there's plenty of limiting factors in the FreeBSD audio landscape which 
JACK cannot solve.

Good luck!

Florian

--nextPart2212280.sMrx5ctUpN
Content-Disposition: attachment;
 filename="audio-jack-Beta-test-of-new-OSS-API-backend.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="x-UTF_8J";
 name="audio-jack-Beta-test-of-new-OSS-API-backend.patch"

>From 33eaf682b3a0d491be1d29bbbfc38768add263c8 Mon Sep 17 00:00:00 2001
From: Florian Walpen <dev@submerge.ch>
Date: Fri, 10 Feb 2023 21:22:42 +0100
Subject: [PATCH] audio/jack: Beta test of new OSS API backend.

For testing only, not meant to be merged into the official ports tree.
---
 audio/jack/Makefile    | 5 +++--
 audio/jack/distinfo    | 6 +++---
 audio/jack/pkg-message | 6 +++++-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/audio/jack/Makefile b/audio/jack/Makefile
index d15186344fd0..152a3a3bdaea 100644
--- a/audio/jack/Makefile
+++ b/audio/jack/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	jackit
 DISTVERSIONPREFIX=	v
 DISTVERSION=	1.9.22
-PORTREVISION=	1
+PORTREVISION=	140
 CATEGORIES=	audio
 
 MAINTAINER=	dev@submerge.ch
@@ -19,8 +19,9 @@ USE_LDCONFIG=	yes
 USE_RC_SUBR=	jackd
 
 USE_GITHUB=	yes
-GH_ACCOUNT=	jackaudio
+GH_ACCOUNT=	0EVSG
 GH_PROJECT=	jack2
+GH_TAGNAME=	da7fb3536aa6e422d0fceb311d83fa0321e35e4a
 
 CFLAGS+=	-fPIC
 CPPFLAGS+=	-I${LOCALBASE}/include
diff --git a/audio/jack/distinfo b/audio/jack/distinfo
index 4d372a443879..2ea3d8203ea3 100644
--- a/audio/jack/distinfo
+++ b/audio/jack/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1675342810
-SHA256 (jackaudio-jack2-v1.9.22_GH0.tar.gz) = 1e42b9fc4ad7db7befd414d45ab2f8a159c0b30fcd6eee452be662298766a849
-SIZE (jackaudio-jack2-v1.9.22_GH0.tar.gz) = 933448
+TIMESTAMP = 1685988794
+SHA256 (0EVSG-jack2-v1.9.22-da7fb3536aa6e422d0fceb311d83fa0321e35e4a_GH0.tar.gz) = b9794aabfc04e8358b72bf9c82afe0e09c0d12de1e83e12523d9e59fbee38bd7
+SIZE (0EVSG-jack2-v1.9.22-da7fb3536aa6e422d0fceb311d83fa0321e35e4a_GH0.tar.gz) = 947120
diff --git a/audio/jack/pkg-message b/audio/jack/pkg-message
index 2a94946d2d57..1dc2ec531a96 100644
--- a/audio/jack/pkg-message
+++ b/audio/jack/pkg-message
@@ -3,6 +3,10 @@ The new JACK server comes with a DBUS control interface:
 $ jack_control help
 $ jack_control ds oss
 $ jack_control dp
+$ jack_control dps rate 48000
+$ jack_control dps wordlength 16
+$ jack_control dps capture /dev/dsp0
+$ jack_control dps playback /dev/dsp0
 $ jack_control eps realtime False
 $ jack_control start
 
@@ -19,7 +23,7 @@ Note that only one JACK server can be run at a time. An /etc/rc.conf example:
 
 jackd_enable="YES"
 jackd_user="joe"
-jackd_rtprio="YES"
+jackd_rtprio="NO"
 jackd_args="-R -doss -r48000 -p1024 -n1 -w16 \
             --capture /dev/dsp0 --playback /dev/dsp0"
 
-- 
2.41.0


--nextPart2212280.sMrx5ctUpN--






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2036330.x0N0T6uNKo>