Jack as root , user session cant access server

I created a jack sevice that runs with PiSound.
I dont know what I did wrong , my main user cant seem to use the jackd server. I remember from other times that I could fire up any app in my user like qjackctl , Catia or patchage, now I just cant for some reason
this is my service file :

[Unit]
Description=JACK2 Audio Server
#After=sound.target

[Service]
Environment=LV2_PATH=/home/sound/.lv2
Environment=JACK_NO_AUDIO_RESERVATION=1
LimitRTPRIO=infinity
LimitMEMLOCK=infinity
ExecStart=/usr/bin/jackd -t 2000 -R -P 95 -d alsa -d hw:pisound -r 48000 -p 128 -n 2 -X seq -s -S
Restart=always
RestartSec=1

[Install]
WantedBy=multi-user.target 

Ideally I would like to fire up qjackctl and be attached to this service, same for other apps
Anybody got any tips ?
the jack server is up and running but I noticed is created by root user

Add this line near Environment ones:

Environment=JACK_PROMISCUOUS_SERVER=jack

Also add this line to /etc/environment:

JACK_PROMISCUOUS_SERVER=jack

Then the Jack server should be shared.

(reboot after changing /etc/environment)

Thanks . Just tried this and still not working . Maybe is because the service is running as root user ?

● jack.service - JACK2 Audio Server
     Loaded: loaded (/lib/systemd/system/jack.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-05-03 09:18:49 BST; 7min ago
   Main PID: 448 (jackd)
      Tasks: 5 (limit: 8775)
        CPU: 15.405s
     CGroup: /system.slice/jack.service
             └─448 /usr/bin/jackd -t 2000 -R -P 95 -d alsa -d hw:pisound -r 48000 -p 128 -n 2 -X seq -s -S

May 03 09:18:51 patch jackd[448]: creating alsa driver ... hw:pisound|hw:pisound|128|2|48000|0|0|nomon|swmeter|soft-mod>
May 03 09:18:51 patch jackd[448]: configuring for 48000Hz, period = 128 frames (2.7 ms), buffer = 2 periods
May 03 09:18:51 patch jackd[448]: ALSA: final selected sample format for capture: 16bit little-endian
May 03 09:18:51 patch jackd[448]: ALSA: use 2 periods for capture
May 03 09:18:51 patch jackd[448]: ALSA: final selected sample format for playback: 16bit little-endian
May 03 09:18:51 patch jackd[448]: ALSA: use 2 periods for playback
May 03 09:18:51 patch jackd[448]: port created: Midi-Through:midi/playback_1
May 03 09:18:51 patch jackd[448]: port created: Midi-Through:midi/capture_1
May 03 09:18:51 patch jackd[448]: port created: pisound:midi/playback_1
May 03 09:18:51 patch jackd[448]: port created: pisound:midi/capture_1

When I open qjackctl from desktop for example , it doesnt hook to the jack server and if I start it from there (which is very wrong since its already running but just to see ) I get this output:

JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Allocate: can't check in named futex name = jack_sem.default_system err = Permission denied
Cannot allocate synchro
Cannot allocate internal client for driver
Cannot initialize driver
JackServer::Open failed with -1
Failed to open server
09:27:51.741 JACK was stopped
09:27:53.423 Could not connect to JACK server as client. - Overall operation failed. - Unable to connect to server. Please check the messages window for more info.
Cannot connect to server socket err = Permission denied
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock

Maybe I should add my sound user to sudoers or something similar ?
Thanks @Giedrius as always!

this is the services setup Im using , I forked the repo from micahvdm GitHub - CarloCattano/mod-PiSound: install script for moddevices software on Raspberry pi 4 aarch64 with PiSound hat

By doing your suggested modifications , mod-host and mod-ui also fail to access the jack server and exit

All of the services that want to access Jack should have the same environment variable set.

By the way, it’s been a while since I used qjackctl, but it looks like it’s meant to start its own server only, and can’t connect to an existing one? Try using Patchage instead.

1 Like

Thanks ! that did the trick.
And you are right about qjackctl .
Just compiled patchage from source but I get a blank screen and a similar error message as the other apps that try to interact with jack .This is so stressing , I cant figure out why this happends

JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Allocate: can't check in named futex name = jack_sem.default_system err = Permission denied
Cannot allocate synchro
Cannot allocate internal client for driver
Cannot initialize driver
JackServer::Open failed with -1
Failed to open server
Cannot connect to server socket err = Permission denied
Cannot connect to server request channel

Sometimes there can be conflicts with different Jack versions, there’s some ‘jackd2’ and ‘jack1’ which are incompatible with each other. If you have some libraries for both at the same time on your system, it may cause failures. If it’s a fresh install, it’s not likely though to have both.

Hm no , just got
jack-capture jackd jackd2
Quite a recent OS since I managed to break the older one I used to use, and was all set since ages . I forgot most of the steps that borught me there , but now I keep track of everything with gists so Im not in this situation again :slight_smile:

Try removing jackd, I think it’s conflicting with jackd2.

No still getting the same log message

Cannot connect to server socket err = Permission denied
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
qt.qpa.xcb: QXcbConnection: XCB error: 148 (Unknown), sequence: 192, resource id: 0, major code: 140 (Unknown), minor code: 20 

I will try to ask kxstudios about this . I find a lot of info but nothing particularly enlightening about this topic. Im pretty sure it has to do with running jack as root instead of as the main user. Other approaches Ive seen make even a jack user for this purpose but Im a bit lost honestly .

In the past I had it set so I could run mod software and on top of it run other applications and freely connect midi ins and outs as well as audio ports between apps and it was quite fun.

Ok , dont know if this is a good solution but in the end I just added this 2 lines to the services in order to run them from the specific user Im using :

User=sound
Group=audio

Now Im able to interact with jack server from my user session

or so I though , I don’t get inputs and outputs in mod UI , oh well…

I can manually route the audio , so no big deal .
Performance its really good with PiSound and 64bit Raspberry OS , 0 Xruns , CPU is happy

Just a bit warm 70ºC but could be cause I’ve set the cpu_scaling to performance.

Can live without INs and OUTs in the mod-ui for now , till I find a solution .
Compiled jackd2 from source since jackd2 from the apt its quite old according the the maintainer, but don’t know if this is related to the problems I was having

And its working now !

Can use the mod audio ins outs and midi ports as my user

1 Like