jack2 icon indicating copy to clipboard operation
jack2 copied to clipboard

[solved] Raspberry Pi 4 (snd_bcm2835) does not play nice with jack

Open nettings opened this issue 4 years ago • 12 comments

After many years of not bothering I wanted to try the built-in sound of the RPi4 again... Playing something through the ALSA driver sounds indeed quite nice and pleasant. This works:

medianet@mn-basic:/local/data/Benjamin Britten/Works for String Orchestra (Nimbus) FS WRITABLE $ mpv *
Playing: 01-Benjamin Britten-Variations on a Theme of Frank Bridge, Op.10 - i. Introduction & Theme.flac
 (+) Audio --aid=1 (flac 2ch 44100Hz)
<..>
AO: [alsa] 44100Hz stereo 2ch s16
A: 00:00:15 / 00:01:55 (13%)

Sound is flawless. Now when I start jackd with a wide range of parameter combinations, I either get a stuck server that will spit an error message after the first client connects, or funky digital artefacts. I used jackd -R -d alsa -d hw:0 [-S] -r [44100|48000] -p [1024|2048|4096] -n [2|3]

I guess this is due to some feature missing in the ALSA implementation that jack relies on - many years ago, it used to be mmap, but that has been fixed, I think.

The funny thing is my workaround: start jackd with the dummy backend (/usr/bin/jackd -R -t 4500 -P 40 -ddummy -P 2 -C 0 -r48000 -p1024) and use /usr/bin/zita-j2a -d hw:0 -c 2 -L -r 44100 -p 4096 -n 3. Stable and flawless sound. Now what is going on here?

nettings avatar Dec 27 '20 23:12 nettings

Here is a typical log of jackd getting stuck when I try jack_lsp -c:

medianet@mn-basic:/local/data/Benjamin Britten/Works for String Orchestra (Nimbus) FS WRITABLE $ DBUS_SESSION_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket jackd -c system -v -dalsa -dhw:0 -P -o 2 -S 24 -r48000  -p4096 -n2 &
[1] 3385
jackdmp 1.9.12
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2017 Filipe Coelho.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
medianet@mn-basic:/local/data/Benjamin Britten/Works for String Orchestra (Nimbus) FS WRITABLE $ JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Jack: JackPosixThread::StartImp : create non RT thread
Jack: JackPosixThread::ThreadHandler : start
Jack: playback device hw:0
Jack: capture device hw:0
Jack: apparent rate = 48000
Jack: frames per period = 4096
Jack: JackDriver::Open capture_driver_name = hw:0
Jack: JackDriver::Open playback_driver_name = hw:0
Jack: Check protocol client = 8 server = 8
Jack: JackEngine::ClientInternalOpen: name = system
Jack: JackEngine::AllocateRefNum ref = 0
Jack: JackLinuxFutex::Allocate name = jack_sem.1001_default_system val = 0
Jack: JackEngine::NotifyAddClient: name = system
Jack: JackGraphManager::SetBufferSize size = 4096
Jack: JackConnectionManager::DirectConnect first: ref1 = 0 ref2 = 0
Jack: JackGraphManager::ConnectRefNum cur_index = 0 ref1 = 0 ref2 = 0
Jack: JackDriver::SetupDriverSync driver sem in flush mode
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:0|-|4096|2|48000|0|2|nomon|swmeter|-|16bit
configuring for 48000Hz, period = 4096 frames (85.3 ms), buffer = 2 periods
ALSA: final selected sample format for playback: 16bit little-endian
ALSA: use 2 periods for playback
Jack: JackSocketServerChannel::Open
Jack: JackServerSocket::Bind : addr.sun_path /dev/shm/jack_default_1001_0
Jack: JackSocketServerChannel::BuildPoolTable size = 1
Jack: JackEngine::Open
Jack: JackClientSocket::Connect : addr.sun_path /dev/shm/jack_default_1001_0
Jack: JackEngine::ClientInternalOpen: name = freewheel
Jack: JackEngine::AllocateRefNum ref = 1
Jack: JackLinuxFutex::Allocate name = jack_sem.1001_default_freewheel val = 0
Jack: JackEngine::NotifyAddClient: name = freewheel
Jack: JackDriver::ClientNotify ref = 1 driver = system name = freewheel notify = 0
Jack: JackDriver::ClientNotify ref = 0 driver = freewheel name = system notify = 0
Jack: JackConnectionManager::DirectConnect first: ref1 = 1 ref2 = 1
Jack: JackGraphManager::ConnectRefNum cur_index = 0 ref1 = 1 ref2 = 1
Jack: JackDriver::SetupDriverSync driver sem in flush mode
Jack: JackGraphManager::SetBufferSize size = 4096
Jack: JackAlsaDriver::Attach fBufferSize 4096 fSampleRate 48000
Jack: JackEngine::PortRegister ref = 0 name = system:playback_1 type = 32 bit float mono audio flags = 21 buffer_size = 4096
Jack: JackGraphManager::AllocatePortAux port_index = 1 name = system:playback_1 type = 32 bit float mono audio
Jack: JackConnectionManager::AddInputPort ref = 0 port = 1
Jack: JackEngine::ClientNotify: no callback for notification = 9
Jack: JackEngine::ClientNotify: no callback for notification = 9
Jack: JackAlsaDriver::Attach fPlaybackPortList[i] 1 
Jack: JackEngine::PortRegister ref = 0 name = system:playback_2 type = 32 bit float mono audio flags = 21 buffer_size = 4096
Jack: JackGraphManager::AllocatePortAux port_index = 2 name = system:playback_2 type = 32 bit float mono audio
Jack: JackConnectionManager::AddInputPort ref = 0 port = 2
Jack: JackEngine::ClientNotify: no callback for notification = 9
Jack: JackEngine::ClientNotify: no callback for notification = 9
Jack: JackAlsaDriver::Attach fPlaybackPortList[i] 2 
Jack: Clock source : system clock via clock_gettime
Jack: JackServer::Start
Jack: JackThreadedDriver::Start
Jack: JackPosixThread::StartImp : create non RT thread
Jack: JackPosixThread::ThreadHandler : start
Jack: JackThreadedDriver::Init real-time
Jack: JackPosixThread::AcquireRealTimeImp priority = 10
Jack: JackPosixThread::StartImp : create non RT thread
Jack: JackPosixThread::ThreadHandler : start
Jack: JackSocketServerChannel::ClientCreate socket
Jack: JackSocketServerChannel::BuildPoolTable size = 2
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 1 fd = 10

medianet@mn-basic:/local/data/Benjamin Britten/Works for String Orchestra (Nimbus) FS WRITABLE $ 
medianet@mn-basic:/local/data/Benjamin Britten/Works for String Orchestra (Nimbus) FS WRITABLE $ 
medianet@mn-basic:/local/data/Benjamin Britten/Works for String Orchestra (Nimbus) FS WRITABLE $ jack_lsp -c
Jack: JackSocketServerChannel::Execute : fPollTable i = 1 fd = 10
Jack: JackSocketServerChannel::ClientCreate socket
Jack: JackSocketServerChannel::BuildPoolTable size = 3
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 1 fd = 10
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 2 fd = 11
Jack: JackSocketServerChannel::Execute : fPollTable i = 1 fd = 10
Jack: JackSocketServerChannel::Execute : fPollTable i = 2 fd = 11
Jack: JackSocketServerChannel::Execute : poll client error err = Success
Jack: JackSocketServerChannel::ClientKill ref = -1 fd = 11
Jack: Client was not opened : probably correspond to server_check
Jack: JackClientSocket::Close
Jack: JackSocketServerChannel::ClientCreate socket
Jack: JackSocketServerChannel::BuildPoolTable size = 3
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 1 fd = 10
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 2 fd = 11
Jack: JackSocketServerChannel::Execute : fPollTable i = 1 fd = 10
Jack: JackSocketServerChannel::Execute : fPollTable i = 2 fd = 11
Jack: JackRequest::ClientCheck
Jack: Check protocol client = 8 server = 8
Jack: JackRequest::ClientOpen
Jack: JackEngine::ClientExternalOpen: uuid = 0, name = lsp
Jack: JackEngine::AllocateRefNum ref = 2
Jack: JackLinuxFutex::Allocate name = jack_sem.1001_default_lsp val = 0
Jack: JackSocketNotifyChannel::Open name = lsp
Jack: JackClientSocket::Connect : addr.sun_path /dev/shm/jack_lsp_1001_0
Jack: JackShmMem::new index = 2 attached = b6fb4000 size = 432 
Jack: JackExternalClient::Open name = lsp index = 2 base = b6fb4000
Jack: JackPosixProcessSync::TimedWait time out = 5000000
JackPosixProcessSync::LockedTimedWait error usec = 5000000 err = Connection timed out
Jack: JackPosixProcessSync::TimedWait finished delta = 5000684.0
Driver is not running
Jack: JackExternalClient::Close
Jack: JackSocketNotifyChannel::Close
Jack: JackClientSocket::Close
Jack: JackShmMem::delete size = 0 index = 2
Cannot read socket fd = 5 err = Success
CheckRes error
JackSocketClientChannel read fail
Cannot create new client
Cannot open lsp client
JackShmReadWritePtr1::~JackShmReadWritePtr1 - Init not done for -1, skipping unlock
Jack: JackSocketServerChannel::Execute : fPollTable i = 1 fd = 10
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
jack_client_open() failed, status = 0x21
Jack: JackSocketServerChannel::Execute : fPollTable i = 2 fd = 11
Jack: JackSocketServerChannel::Execute : poll client error err = Success
Jack: JackSocketServerChannel::ClientKill ref = -1 fd = 11
Jack: Client was not opened : probably correspond to server_check
Jack: JackClientSocket::Close
Jack: JackSocketServerChannel::BuildPoolTable size = 2
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 1 fd = 10

nettings avatar Dec 27 '20 23:12 nettings

1.9.12 is very old now, please see if you can try with a newer version. there has been quite some ARM/aarch64-beneficial/related changes in jack2 since then.

falkTX avatar Dec 27 '20 23:12 falkTX

Agreed. The reason I'm using it is that's still the version shipped with the most recent RaspiOS. And for the record, with other interfaces (USB or the hifiberry I²S HATs), jack has always performed reliably, even this ancient version. So I wasn't expecting it to be a jack issue rather than a driver feature, but since few people use jack on the Pi, I thought this would be my best bet at getting a hint.

But you're right, I'm building it from source now and will report back. If things get resolved, I'll ask the package maintainer to roll an update...

nettings avatar Dec 28 '20 13:12 nettings

Similar behaviour with the latest head, except it now also segfaults:

medianet@mn-basic:/medianet/custom_builds/jack2 FS WRITABLE $ JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Jack: JackPosixThread::StartImp : create non RT thread
Jack: JackPosixThread::ThreadHandler : start
Jack: playback device hw:0
Jack: capture device hw:0
Jack: apparent rate = 48000
Jack: frames per period = 4096
Jack: JackDriver::Open capture_driver_name = hw:0
Jack: JackDriver::Open playback_driver_name = hw:0
Jack: Check protocol client = 8 server = 8
Jack: JackEngine::ClientInternalOpen: name = system
Jack: JackEngine::AllocateRefNum ref = 0
Jack: JackLinuxFutex::Allocate name = jack_sem.1001_default_system val = 0
Jack: JackEngine::NotifyAddClient: name = system
Jack: JackGraphManager::SetBufferSize size = 4096
Jack: JackConnectionManager::DirectConnect first: ref1 = 0 ref2 = 0
Jack: JackGraphManager::ConnectRefNum cur_index = 0 ref1 = 0 ref2 = 0
Jack: JackDriver::SetupDriverSync driver sem in flush mode
creating alsa driver ... hw:0|-|4096|2|48000|0|2|nomon|swmeter|-|16bit
configuring for 48000Hz, period = 4096 frames (85.3 ms), buffer = 2 periods
ALSA: final selected sample format for playback: 16bit little-endian
ALSA: use 2 periods for playback
Jack: JackSocketServerChannel::Open
Jack: JackServerSocket::Bind : addr.sun_path /dev/shm/jack_default_1001_0
Jack: JackSocketServerChannel::BuildPoolTable size = 1
Jack: JackEngine::Open
Jack: JackClientSocket::Connect : addr.sun_path /dev/shm/jack_default_1001_0
Jack: JackEngine::ClientInternalOpen: name = freewheel
Jack: JackEngine::AllocateRefNum ref = 1
Jack: JackLinuxFutex::Allocate name = jack_sem.1001_default_freewheel val = 0
Jack: JackEngine::NotifyAddClient: name = freewheel
Jack: JackDriver::ClientNotify ref = 1 driver = system name = freewheel notify = 0
Jack: JackDriver::ClientNotify ref = 0 driver = freewheel name = system notify = 0
Jack: JackConnectionManager::DirectConnect first: ref1 = 1 ref2 = 1
Jack: JackGraphManager::ConnectRefNum cur_index = 0 ref1 = 1 ref2 = 1
Jack: JackDriver::SetupDriverSync driver sem in flush mode
Jack: JackGraphManager::SetBufferSize size = 4096
Jack: JackAlsaDriver::Attach fBufferSize 4096 fSampleRate 48000
Jack: JackEngine::PortRegister ref = 0 name = system:playback_1 type = 32 bit float mono audio flags = 21 buffer_size = 4096
Jack: JackGraphManager::AllocatePortAux port_index = 1 name = system:playback_1 type = 32 bit float mono audio
Jack: JackConnectionManager::AddInputPort ref = 0 port = 1
Jack: JackEngine::ClientNotify: no callback for notification = 9
Jack: JackEngine::ClientNotify: no callback for notification = 9
Jack: JackAlsaDriver::Attach fPlaybackPortList[i] 1 
Jack: JackEngine::PortRegister ref = 0 name = system:playback_2 type = 32 bit float mono audio flags = 21 buffer_size = 4096
Jack: JackGraphManager::AllocatePortAux port_index = 2 name = system:playback_2 type = 32 bit float mono audio
Jack: JackConnectionManager::AddInputPort ref = 0 port = 2
Jack: JackEngine::ClientNotify: no callback for notification = 9
Jack: JackEngine::ClientNotify: no callback for notification = 9
Jack: JackAlsaDriver::Attach fPlaybackPortList[i] 2 
Jack: Clock source : system clock via clock_gettime
Jack: JackServer::Start
Jack: JackThreadedDriver::Start
Jack: JackPosixThread::StartImp : create non RT thread
Jack: JackPosixThread::ThreadHandler : start
Jack: JackThreadedDriver::Init real-time
Jack: JackPosixThread::AcquireRealTimeImp priority = 10
Jack: JackPosixThread::StartImp : create non RT thread
Jack: JackPosixThread::ThreadHandler : start
Jack: JackSocketServerChannel::ClientCreate socket
Jack: JackSocketServerChannel::BuildPoolTable size = 2
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 1 fd = 9

medianet@mn-basic:/medianet/custom_builds/jack2 FS WRITABLE $ 
medianet@mn-basic:/medianet/custom_builds/jack2 FS WRITABLE $ 
medianet@mn-basic:/medianet/custom_builds/jack2 FS WRITABLE $ jack_lsp -c
Jack: JackSocketServerChannel::ClientCreate socket
Jack: JackSocketServerChannel::BuildPoolTable size = 3
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 1 fd = 9
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 2 fd = 10
Jack: JackSocketServerChannel::Execute : poll client error err = Success
Jack: JackSocketServerChannel::ClientKill ref = -1 fd = 10
Jack: Client was not opened : probably correspond to server_check
Jack: JackClientSocket::Close
Jack: JackSocketServerChannel::BuildPoolTable size = 2
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 1 fd = 9
Jack: JackSocketServerChannel::ClientCreate socket
Jack: JackSocketServerChannel::BuildPoolTable size = 3
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 1 fd = 9
Jack: JackSocketServerChannel::BuildPoolTable fSocketTable i = 2 fd = 10
Jack: JackRequest::ClientCheck
Jack: Check protocol client = 8 server = 8
Jack: JackRequest::ClientOpen
Cannot read socket fd = 3 err = No such file or directory
CheckRes error
Could not read result type = 23
Cannot open lsp client
JackShmReadWritePtr1::~JackShmReadWritePtr1 - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Error: cannot connect to JACK, jack_client_open() failed, status = 0x21
[1]+  Segmentation fault      DBUS_SESSION_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket jackd -c system -v -dalsa -dhw:0 -P -o 2 -S 24 -r48000 -p4096 -n2
medianet@mn-basic:/medianet/custom_builds/jack2 FS WRITABLE $ 

I'llt try and get a backtrace next. Btw. there were a few compiler warnings, I posted them below in case you haven't seen them yet.

jackd-compiler-warnings.txt

nettings avatar Dec 28 '20 13:12 nettings

For the record, yes, I'm reasonably sure everything got linked correctly and there are no old libs lying around:

medianet@mn-basic:/medianet/custom_builds/jack2 FS WRITABLE $ ldd /usr/bin/jackd
	linux-vdso.so.1 (0xbecea000)
	/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0xb6f03000)
	libjackserver.so.0 => /lib/libjackserver.so.0 (0xb6e14000)
	libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6dea000)
	librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0xb6dd3000)
	libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6dc0000)
	libstdc++.so.6 => /lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6c79000)
	libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6bf7000)
	libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6bca000)
	libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6a7c000)
	/lib/ld-linux-armhf.so.3 (0xb6f18000)
medianet@mn-basic:/medianet/custom_builds/jack2 FS WRITABLE $ la /lib/*jack*
lrwxrwxrwx 1 root root      19 Dec 28 13:25 /lib/libjacknet.so -> libjacknet.so.0.1.0
lrwxrwxrwx 1 root root      19 Dec 28 13:25 /lib/libjacknet.so.0 -> libjacknet.so.0.1.0
-rwxr-xr-x 1 root root  170288 Dec 28 13:07 /lib/libjacknet.so.0.1.0
lrwxrwxrwx 1 root root      22 Dec 28 13:25 /lib/libjackserver.so -> libjackserver.so.0.1.0
lrwxrwxrwx 1 root root      22 Dec 28 13:25 /lib/libjackserver.so.0 -> libjackserver.so.0.1.0
-rwxr-xr-x 1 root root 1252068 Dec 28 13:11 /lib/libjackserver.so.0.1.0
lrwxrwxrwx 1 root root      16 Dec 28 13:25 /lib/libjack.so -> libjack.so.0.1.0
lrwxrwxrwx 1 root root      16 Dec 28 13:25 /lib/libjack.so.0 -> libjack.so.0.1.0
-rwxr-xr-x 1 root root  528592 Dec 28 13:10 /lib/libjack.so.0.1.0

/lib/jack:
total 1000
drwxr-xr-x  2 root root   4096 Dec 28 13:25 .
drwxr-xr-x 73 root root   4096 Dec 28 13:25 ..
-rwxr-xr-x  1 root root  65928 Dec 28 13:11 audioadapter.so
-rwxr-xr-x  1 root root   7728 Dec 28 13:11 inprocess.so
-rwxr-xr-x  1 root root 171804 Dec 28 13:12 jack_alsarawmidi.so
-rwxr-xr-x  1 root root 168732 Dec 28 13:11 jack_alsa.so
-rwxr-xr-x  1 root root  41992 Dec 28 13:11 jack_dummy.so
-rwxr-xr-x  1 root root  41244 Dec 28 13:11 jack_loopback.so
-rwxr-xr-x  1 root root 103872 Dec 28 13:11 jack_netone.so
-rwxr-xr-x  1 root root  97204 Dec 28 13:11 jack_net.so
-rwxr-xr-x  1 root root  68432 Dec 28 13:11 jack_proxy.so
-rwxr-xr-x  1 root root  61892 Dec 28 13:11 netadapter.so
-rwxr-xr-x  1 root root 140016 Dec 28 13:11 netmanager.so
-rwxr-xr-x  1 root root  19864 Dec 28 13:11 profiler.so

nettings avatar Dec 28 '20 13:12 nettings

It looks like the ALSA driver of the PWM device on the Pi4 has some weird properties. Here are the hardware parameters as reported by aplay --dump-hw-params for a known-good Hifiberry DACpro XLR:

medianet@sparckjones:~ $ aplay --dump-hw-params /usr/share/sounds/alsa/Noise.wav 
Playing WAVE '/usr/share/sounds/alsa/Noise.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
HW Params of device "default":
--------------------
ACCESS:  MMAP_INTERLEAVED MMAP_NONINTERLEAVED MMAP_COMPLEX RW_INTERLEAVED RW_NONINTERLEAVED
FORMAT:  S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE MU_LAW A_LAW IMA_ADPCM S20_LE S20_BE U20_LE U20_BE S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE
SUBFORMAT:  STD
SAMPLE_BITS: [4 64]
FRAME_BITS: [4 640000]
CHANNELS: [1 10000]
RATE: [4000 4294967295)
PERIOD_TIME: (83 8192000]
PERIOD_SIZE: (0 4294967295)
PERIOD_BYTES: (0 4294967295)
PERIODS: (0 4294967295]
BUFFER_TIME: [1 4294967295]
BUFFER_SIZE: [1 4294967294]
BUFFER_BYTES: [1 4294967295]
TICK_TIME: ALL
--------------------

And here are the hardware parameters of the BCM2711 PCM driver:

medianet@mn-basic:~ FS WRITABLE $ aplay --dump-hw-params /usr/share/sounds/alsa/Front_Center.wav 
Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
HW Params of device "default":
--------------------
ACCESS:  MMAP_INTERLEAVED MMAP_NONINTERLEAVED MMAP_COMPLEX RW_INTERLEAVED RW_NONINTERLEAVED
FORMAT:  S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE MU_LAW A_LAW IMA_ADPCM S20_LE S20_BE U20_LE U20_BE S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE
SUBFORMAT:  STD
SAMPLE_BITS: [4 64]
FRAME_BITS: [4 640000]
CHANNELS: [1 10000]
RATE: [4000 4294967295]
PERIOD_TIME: [10000 16384000]
PERIOD_SIZE: [40 4294967295]
PERIOD_BYTES: [20 4294967295]
PERIODS: (0 107374183)
BUFFER_TIME: [1 4294967295]
BUFFER_SIZE: [1 4294967294]
BUFFER_BYTES: [1 4294967295]
TICK_TIME: ALL
--------------------

The differences are in the PERIOD.* fields. This seems to be consistent with the observation that the ALSA driver cannot be created for period sizes below 512 and -n below 3. But it does not explain why jackd is apparently entirely unable to use that driver, will jackd -d dummy with zita-j2a works, although at high latency and not very reliably.

nettings avatar Feb 25 '21 10:02 nettings

Hi, I am experiencing the exact same issue with archARM, after building Jack2 from source. Thanks a lot @nettings for the workaround, it is working for me too.

with these settings I get an almost passable latency jackd -R -P90 -ddummy -P2 -C0 -r48000 -p256 & zita-j2a -d hw:0 -c2 -L -r 48000 -p512 -n3 &

thibaudk avatar Mar 03 '21 20:03 thibaudk

The workaround has stopped working with the latest RaspiOS base image (kernel 5.10.17-v7+), on Pi 4 and Pi 3B+ :o(

nettings avatar Apr 15 '21 15:04 nettings

In case it's of any use. Setting the number of audio inputs to zero, for the alsa driver, makes the integrated sound to work fine in a Raspberry Pi 4b, jackd installed with apt. jackd ... -d alsa ... -i 0 -o 2. It's a TRRS AV plug, that might have something to do with the driver or jack, I have no idea.

smrg-lm avatar Dec 03 '21 16:12 smrg-lm

After some trial and error I've been able to get jack to work through the integrated audio on a Pi 3B+ using the plughw interface. I have to use a lower sample rate to avoid getting lots of xruns, but the latency is good and the quality difference isn't that noticeable to me. Seems like plughw might be needed to convert the endian-ness of the sample format.

/usr/bin/jackd --silent -R -d alsa -d plughw:Headphones -s -p 444 -n 3 -r 22050 -P -S

albedozero avatar Dec 03 '21 20:12 albedozero

Thanks guys for your input! I'm revisiting this issue on the new bullseye-based RaspiOS, and I find:

  • jackd will now start and run flawlessly on the hw:0 device, but the sound is severely distorted. The distortion sounds differently depending on the period size.
  • The distortion sounds like endianness or data alignment issues.
  • Period sizes and number of buffers are restricted somewhat. Forcing 16bit with the -S option lets me use -n > 2, and also larger period sizes.
  • The fix suggested by @albedozero works for me.
  • @smrg-lm hits the nail on the head. Apparently, even when you use -P to force playback-only mode and you force 16 bit with -s, jackd still gets the audio buffer alignment wrong. Forcing -i 0 -o 2 fixes the issue for me.

The current best quality/minimum-latency setting that works for me with the built-in headphones out is

JACK_NO_AUDIO_RESERVATION=1 jackd -R -P40 -d alsa -d hw:0 -P -S -p 1024 -n 2 -r 48000 -i 0 -o 2

Haven't measured it yet, but it sounds ok.

@falkTX , can you comment on the finding that we need to force -i 0 -o2 ? Is that an invalid assumption in the jackd alsa backend, or is the implementation of the RPi built-in audio driver to blame?

nettings avatar Dec 05 '21 12:12 nettings

Leaving this bug open for now in the hope that it might help others.

nettings avatar Dec 05 '21 12:12 nettings