Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jackdbus unexpectedly stopped working while jackd works with same settings #903

Open
spencermp opened this issue Dec 2, 2022 · 6 comments
Labels

Comments

@spencermp
Copy link

Describe the bug

I've been using jack since the start of 2022, and it's worked nearly flawlessly through cadence and jackdbus. Recently it's started to xrun on the same settings I've been using since I first set it up.

There are two ways to avoid the xruns: run jackdbus with a very high period and 4 nperiods OR use jackd with -p 128 and -n 3

Environment

  • JACK Version: jackdmp version 1.9.21 tmpdir /dev/shm protocol 9
  • Operating System: Gentoo Linux
  • Installation: Emerge build with alsa, classic, dbus, libsamplerate, opus, pam, and tools

Steps To Reproduce

While I use this bash script, I got the values from what I used in cadence and the output of jack_control dp

#!/bin/sh
# A simple script to setup jack2

pidof jackdbus >/dev/null || \
    jack_control start       # start jack, only if jack is not running,
jack_control eps driver alsa # and link to alsa

jack_control dps rate 48000  # low latency, mobo (non-usb) audio
jack_control dps nperiods 3  #
jack_control dps period 128 #

jack_control dps inchannels 1          # input (microphone)
jack_control dps capture hw:Device,0   #
jack_control dps outchannels 2         # output (headphones)
jack_control dps playback hw:Generic,0 #

jack_control stop  # quickly restart jack to save the new settings
sleep 2            #
jack_control start #

Expected vs. actual behavior

Expected: jackdbus should work with the same settings as jackd

Actual: I get constant and grating xruns.

emerge --info jack2

Xrun:

Thu Dec  1 20:47:33 2022: Jack: **** alsa_pcm: xrun of at least 0.005 msecs
Thu Dec  1 20:47:33 2022: Jack: Repreparing capture
Thu Dec  1 20:47:33 2022: Jack: Repreparing playback
Thu Dec  1 20:47:33 2022: Jack: ALSA XRun wait_status = 0
Thu Dec  1 20:47:33 2022: Jack: JackRequest::Notification
Thu Dec  1 20:47:33 2022: Jack: JackEngine::ClientNotify: no callback for notification = 3
Thu Dec  1 20:47:33 2022: Jack: JackEngine::ClientNotify: no callback for notification = 3
Thu Dec  1 20:47:33 2022: Jack: JackClient::ClientNotify ref = 2 name = dbusapi notify = 3
Thu Dec  1 20:47:33 2022: Jack: JackClient::kXRunCallback
Thu Dec  1 20:47:33 2022: Jack: JackEngine::ClientNotify: no callback for notification = 3 

jack_control dp

--- get driver parameters (type:isset:default:value)
              device: ALSA device name (str:notset:hw:0:hw:0)
             capture: Provide capture ports.  Optionally set device (str:set:none:hw:Device,0)
            playback: Provide playback ports.  Optionally set device (str:set:none:hw:Generic,0)
                rate: Sample rate (uint:set:48000:48000)
              period: Frames per period (uint:set:1024:2048)
            nperiods: Number of periods of playback latency (uint:set:2:2)
               hwmon: Hardware monitoring, if available (bool:notset:False:False)
             hwmeter: Hardware metering, if available (bool:notset:False:False)
              duplex: Provide both capture and playback ports (bool:notset:True:True)
            softmode: Soft-mode, no xrun handling (bool:notset:False:False)
             monitor: Provide monitor ports for the output (bool:notset:False:False)
              dither: Dithering mode (char:notset:n:n)
          inchannels: Number of capture channels (defaults to hardware max) (uint:set:0:1)
         outchannels: Number of playback channels (defaults to hardware max) (uint:set:0:2)
              shorts: Try 16-bit samples before 32-bit (bool:notset:False:False)
       input-latency: Extra input latency (frames) (uint:notset:0:0)
      output-latency: Extra output latency (frames) (uint:notset:0:0)
         midi-driver: ALSA MIDI driver (str:notset:none:none) 

jack_control ep

--- get engine parameters (type:isset:default:value)
              driver: Driver to use (str:set:dummy:alsa)
                name: Server name to use. (str:notset:default:default)
            realtime: Whether to use realtime mode. (bool:notset:True:True)
   realtime-priority: Scheduler priority when running in realtime mode. (sint:notset:10:10)
           temporary: Exit once all clients have closed their connections. (bool:notset:False:False)
             verbose: Verbose mode. (bool:notset:False:False)
      client-timeout: Client timeout limit in milliseconds. (sint:notset:0:0)
        clock-source: Clocksource type : c(ycle) | h(pet) | s(ystem). (uint:notset:0:0)
            port-max: Maximum number of ports. (uint:notset:2048:2048)
    replace-registry: Replace shared memory registry. (bool:notset:False:False)
                sync: Use server synchronous mode. (bool:notset:False:False)
   self-connect-mode: Self connect mode. (char:notset: : )
       slave-drivers: Slave drivers to use (str:notset::) 
@spencermp spencermp added the bug label Dec 2, 2022
@stefantalpalaru
Copy link

Same distro, same version, this time with an auditd log showing Jack2 deleting its own files in "/dev/shm", even though it keeps running:

QjackCtl log:

13:56:06.220 /usr/bin/jackd -S -dalsa -dhw:Generic -r48000 -p256 -n4 -Xseq
13:56:06.223 JACK was started with PID=1131.
jack_get_descriptor : dll
jack_get_descriptor returns null for 'jack_intime.so'
jack_get_descriptor : dll
jack_get_descriptor returns null for 'jack_inprocess.so'
jack_get_descriptor : dll
jack_get_descriptor returns null for 'jack_internal_metro.so'
jackdmp 1.9.21
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2022 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
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
creating alsa driver ... hw:Generic|hw:Generic|256|4|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 256 frames (5.3 ms), buffer = 4 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 4 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 4 periods for playback

terminal output:

Cannot open shm segment (Invalid argument)
Map shared memory segments exception
JackShmReadWritePtr1::~JackShmReadWritePtr1 - Init not done for 7, skipping unlock

auditd log:

type=PATH msg=audit(1670594284.433:333): item=0 name="/dev/shm/" inode=1 dev=00:28 mode=041777 ouid=0 ogid=0 rdev=00:00 nametype=PARENT cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0OUID="root" OGID="root"
type=PATH msg=audit(1670594284.433:333): item=1 name="/dev/shm/jack_control_client_1000_0" inode=9306 dev=00:28 mode=0140755 ouid=1000 ogid=1000 rdev=00:00 nametype=CREATE cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0OUID="stefan" OGID="stefan"
type=PROCTITLE msg=audit(1670594284.433:333): proctitle=6A61636B5F636F6E74726F6C5F636C69656E74006570
type=SYSCALL msg=audit(1670594284.433:334): arch=c000003e syscall=257 success=yes exit=32 a0=ffffff9c a1=7fb750925ed0 a2=a0042 a3=1ff items=2 ppid=1109 pid=27299 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=3 comm="jackd" exe="/usr/bin/jackd" key=(null)ARCH=x86_64 SYSCALL=openat AUID="stefan" UID="stefan" GID="stefan" EUID="stefan" SUID="stefan" FSUID="stefan" EGID="stefan" SGID="stefan" FSGID="stefan"
type=CWD msg=audit(1670594284.433:334): cwd="/home/stefan"
type=PATH msg=audit(1670594284.433:334): item=0 name="/dev/shm/" inode=1 dev=00:28 mode=041777 ouid=0 ogid=0 rdev=00:00 nametype=PARENT cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0OUID="root" OGID="root"
type=PATH msg=audit(1670594284.433:334): item=1 name="/dev/shm/jack_sem.1000_default_control_client" inode=9307 dev=00:28 mode=0100755 ouid=1000 ogid=1000 rdev=00:00 nametype=CREATE cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0OUID="stefan" OGID="stefan"
type=PROCTITLE msg=audit(1670594284.433:334): proctitle=2F7573722F62696E2F6A61636B64002D53002D64616C7361002D6468773A47656E65726963002D723438303030002D70323536002D6E34002D58736571
type=SYSCALL msg=audit(1670594284.433:335): arch=c000003e syscall=257 success=yes exit=34 a0=ffffff9c a1=7fb750925cd0 a2=a0042 a3=1b6 items=2 ppid=1109 pid=27299 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=3 comm="jackd" exe="/usr/bin/jackd" key=(null)ARCH=x86_64 SYSCALL=openat AUID="stefan" UID="stefan" GID="stefan" EUID="stefan" SUID="stefan" FSUID="stefan" EGID="stefan" SGID="stefan" FSGID="stefan"
type=CWD msg=audit(1670594284.433:335): cwd="/home/stefan"
type=PATH msg=audit(1670594284.433:335): item=0 name="/dev/shm/" inode=1 dev=00:28 mode=041777 ouid=0 ogid=0 rdev=00:00 nametype=PARENT cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0OUID="root" OGID="root"
type=PATH msg=audit(1670594284.433:335): item=1 name="/dev/shm/jack-1000-7" inode=9308 dev=00:28 mode=0100644 ouid=1000 ogid=1000 rdev=00:00 nametype=CREATE cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0OUID="stefan" OGID="stefan"
type=PROCTITLE msg=audit(1670594284.433:335): proctitle=2F7573722F62696E2F6A61636B64002D53002D64616C7361002D6468773A47656E65726963002D723438303030002D70323536002D6E34002D58736571
type=SYSCALL msg=audit(1670594284.433:336): arch=c000003e syscall=87 success=yes exit=0 a0=556f98bcd30c a1=2 a2=2 a3=4022 items=2 ppid=13641 pid=22998 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=pts12 ses=3 comm="jack_control_cl" exe="/usr/bin/jack_control_client" key=(null)ARCH=x86_64 SYSCALL=unlink AUID="stefan" UID="stefan" GID="stefan" EUID="stefan" SUID="stefan" FSUID="stefan" EGID="stefan" SGID="stefan" FSGID="stefan"
type=CWD msg=audit(1670594284.433:336): cwd="/home/stefan"
type=PATH msg=audit(1670594284.433:336): item=0 name="/dev/shm/" inode=1 dev=00:28 mode=041777 ouid=0 ogid=0 rdev=00:00 nametype=PARENT cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0OUID="root" OGID="root"
type=PATH msg=audit(1670594284.433:336): item=1 name="/dev/shm/jack_control_client_1000_0" inode=9306 dev=00:28 mode=0140755 ouid=1000 ogid=1000 rdev=00:00 nametype=DELETE cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0OUID="stefan" OGID="stefan"
type=SYSCALL msg=audit(1670594284.433:337): arch=c000003e syscall=257 success=yes exit=34 a0=ffffff9c a1=7fb750925e00 a2=a0002 a3=0 items=1 ppid=1109 pid=27299 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=3 comm="jackd" exe="/usr/bin/jackd" key=(null)ARCH=x86_64 SYSCALL=openat AUID="stefan" UID="stefan" GID="stefan" EUID="stefan" SUID="stefan" FSUID="stefan" EGID="stefan" SGID="stefan" FSGID="stefan"
type=PROCTITLE msg=audit(1670594284.433:336): proctitle=6A61636B5F636F6E74726F6C5F636C69656E74006570
type=CWD msg=audit(1670594284.433:337): cwd="/home/stefan"

@nedko
Copy link
Contributor

nedko commented Dec 21, 2022

@stefantalpalaru how this audit log relates to the original report? Despite its name, jack_control_client is part of https://github.com/jackaudio/jack-example-tools now and has nothing to do with the jack control api used by jackdbus and jackd for configuring jack server. OTOH "Cannot open shm segment (Invalid argument)" indicates that your setup probably has some other, unrelated to the original report, issue.

@nedko
Copy link
Contributor

nedko commented Dec 21, 2022

@spencermp emerge --info indicates jack2 version 1.9.19, while you report it against version 1.9.21. Please clarify whether the issue you are experiencing is regression against 1.9.19 or not. It may be insightful to verify the xrun against kernel versions too.

Please consider linking a gentoo bugtracker issue with more info on the issue. If newer jack2 is not stable actually, then it is gentoo stabilization issue too.

As a side note, your emerge --info output indicates that you use installed with both classic and dbus use flags. Keep in mind that was never supported upstream and is discouraged in general. I see how it simplifies jackd vs jackdbus comparison tests.

@stefantalpalaru
Copy link

how this audit log relates to the original report?

It shows a mechanism through which jackd unexpectedly stops working.

Despite its name, jack_control_client is part of https://github.com/jackaudio/jack-example-tools now and has nothing to do with the jack control api used by jackdbus and jackd for configuring jack server.

Must be started by QJackCtl, because none of my pre/post scripts use it. Anyway, it deletes the very important unix domain socket, while the Jack server keeps running.

OTOH "Cannot open shm segment (Invalid argument)" indicates that your setup probably has some other, unrelated to the original report, issue.

No, that's just what Jack clients do when they cannot connect to that socket.

As a side note, your emerge --info output indicates that you use installed with both classic and dbus use flags. Keep in mind that was never supported upstream and is discouraged in general.

That might be it. My problems went away after disabling the "dbus" USE flag.

@spencermp
Copy link
Author

@spencermp emerge --info indicates jack2 version 1.9.19, while you report it against version 1.9.21. Please clarify whether the issue you are experiencing is regression against 1.9.19 or not. It may be insightful to verify the xrun against kernel versions too.

Sorry about this, I had tried to update to jack 1.9.21 while writing up this bug report to see if it was an error with 1.9.19 in particular but no change there.

As a side note, your emerge --info output indicates that you use installed with both classic and dbus use flags. Keep in mind that was never supported upstream and is discouraged in general. I see how it simplifies jackd vs jackdbus comparison tests.

I enabled classic once jack_control / jackdbus started to have issues so that I could continue to use my audio, but just (as of writing this post) tested again disabling classic and the issues still persist on jackdbus.

Please consider linking a gentoo bugtracker issue with more info on the issue. If newer jack2 is not stable actually, then it is gentoo stabilization issue too.

Besides jack itself, I think the only things that would add latency here might be dbus itself or somehow the pam realtime module being messed up. I doubt either of these are the case, becasue ulimit -a shows everything being right and I've re-emerged the entire jack2 dependency tree (over 300 packages).

@nedko
Copy link
Contributor

nedko commented Jan 4, 2023

It may be worth to compare jackd versions built with and without support for audio device reservation (over dbus).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants