Jack error cannot use real time scheduling

JACK Audio Connection Kit | How do I configure my linux system to allow JACK to use realtime scheduling?

Realtime (RT) scheduling is a feature of all Linux operating systems that
enables an application to meet timing deadlines more reliably. Almost all
Linux distributions consider RT scheduling to be a potential source of system
abuse, and so access to it is limited to varying degrees. As mentioned in the
FAQ, it is very important to understand that
you do NOT need an “RT kernel” to use RT scheduling
(this is a very common misconception.)

JACK requires real time (RT) scheduling privileges for reliable, dropout-free
operation. Modern versions of JACK request RT scheduling by default, though it
can be disabled with the -r option. Older versions require the -R option to
request RT scheduling. If your system is not setup correctly, then JACK will
print a message like when it tries to run with RT scheduling (it will appear
in the messages window of QJackctl if you use that to start JACK):

cannot use real-time scheduling (FIFO at priority 10) ... (1: Operation not permitted)

Some distributions configure everything so that any user can use RT scheduling
with absolutely no work at all. This is great, when it happens. However, many
if not most Linux distributions do not allow applications run by ordinary
users to request RT scheduling by default. Some distributions’ JACK packages
will configure things more or less correctly for you, but in almost every
case, some work is required.

Distributions that are known to get this completely right include:

  • AVLinux
  • 64Studio These distributions have JACK packages that will
    create and configure a group with the required priviledges for
    RT scheduling, but will not add you to that group.
  • Debian Squeeze
  • Fedora 13 and later
  • Ubuntu Studio
  • Ubuntu — However, the user needs to be added to “audio” group.

Ultimately, the only way to find out if your system is configured properly is
to run JACK with RT scheduling and see if it works.

This may not work!

If you follow all these steps carefully and they do not work, you should
review the information over here
and consider whether this may apply to your system.

Systems using PAM

PAM (Pluggable Authentication Modules) are used by almost all modern Linux
distributions nowadays to handle various tasks related to granting a user
permission to do something (e.g. to login). If your system has PAM, it will
also have a file called /etc/security/limits.conf and/or a directory called
`/etc/security/limits.d.

You need to carry out 3 steps to be able to run JACK with RT scheduling. In
what follows, several references are made to the “audio” group. If this
group name already exists, pick a different name and use it instead of
“audio” when following the rest of these instructions. The actual name of
the group is completely irrelevant.

1. Editing the configuration file

If your system has no directory called /etc/security/limits.d then you will
need to edit /etc/security/limits.conf. If /etc/security/limits.d does
exist on your machine, then you will need to create and edit a file called
/etc/security/limits.d/audio.conf. The file must contain (at least)
the following two lines:

@audio   -  rtprio     95
@audio   -  memlock    unlimited

Contrary to a lot of misinformation on the web, there is no reason to include
a line here that provides enhanced “niceness” control, which is completely
irrelevant for realtime scheduling and low latency audio applications.

2. Creating an “audio” group

As the super-user (“root”) run the following commands from a terminal window:

groupadd audio
usermod -a -G audio yourUserID

You should substitute your actual user id or “login” for “yourUserID”.

If you prefer, you can carry out these two steps using the graphical tools
that are available under the “System Adminstration” section of your desktop’s
main menu, but this text-based method is faster and much easier to explain.

If you are using a distribution that has already created the group and
configured the “limits” file, you will need to determine the name of the group
(it is likely called “audio” or “jackuser”) and then you can just add yourself
to the group with this command (run as the superuser inside a terminal
window):

usermod -a -G theGroupName yourUserId

substituting the real names for theGroupName and yourUserId

3. Logout and back in

None of the changes you have made above will have any effect until you logout
and back in. If that does not work, try rebooting. In either case, you do not need to reinstall any software.

Hi,

Tl;dr: with a straightforward jack2 install jackd itself gets RT prio fine but generates permissions errors when I set pulseaudio bridge’s RT prio; Jack1’s jackd successfully sets the bridge’s RT prio, and doesn’t generate these errors. Seems like a jack2 bug? Details below.

I’m using the distro’s jackd2 giving me jackdmp 1.9.12

I start jackd with exec /usr/bin/jackd -R -P 95 -u -t 5000000 -d alsa -d hw:USB -p 64 -n 2 -r 48000 and it reports: JACK server starting in realtime mode with priority 95 with no further problems.

Then I start /usr/bin/pulseaudio --high-priority --realtime --verbose --exit-idle-time=85000 --file=./pr.pa -n (pr.pa is essentially a copy of the pulse bridge script used by cadence) and it complains:

I: [pulseaudio] module-jack-source.c: JACK thread starting up.
I: [pulseaudio] core-util.c: Successfully enabled SCHED_RR scheduling for thread, with priority 91.
I: [jack-source] core-util.c: Successfully enabled SCHED_RR scheduling for thread, with priority 87.
I: [pulseaudio] module-jack-source.c: JACK thread starting up.
I: [pulseaudio] core-util.c: Successfully enabled SCHED_RR scheduling for thread, with priority 91.
W: [pulseaudio] module-jack-source.c: JACK error >Cannot use real-time scheduling (RR/90)(1: Operation not permitted)<
W: [pulseaudio] module-jack-source.c: JACK error >JackClient::AcquireSelfRealTime error<
I: [pulseaudio] module-jack-source.c: JACK thread starting up.
I: [pulseaudio] core-util.c: Successfully enabled SCHED_RR scheduling for thread, with priority 91.
I: [pulseaudio] module-jack-source.c: Connecting PulseAudio JACK Source:front-left to system:capture_1

(I verified that an error is really being returned from jack causing the bolded JACK errors above, at https://github.com/jackaudio/jack2/blob/master/posix/JackPosixThread.cpp#L237)

If I then kill everything, do apt-get install libjack0, changing nothing else, and run the same commands it works without error. I checked the RT prio is actually set and it’s not just an ignored error, by looking at htop (RT prios bolded) :

4719 user -92 -11 581M 171M 145M S 25 0:03.47 /usr/bin/pulseaudio —high-priority —realtime —verbose —exit-idle-time=85000 —file=./pr.pa -n

4683 user -96 0 213M 63556 45108 S 1.3 0.2 0:04.74 /usr/bin/jackd -R -P 95 -u -t 5000000 -d alsa -d hw:USB -p 64 -n 2 -r 48000 `

The pulseaudio output is:

I: [pulseaudio] module-jack-source.c: JACK thread starting up.
I: [pulseaudio] core-util.c: Successfully enabled SCHED_RR scheduling for thread, with priority 91.
I: [jack-source] core-util.c: Successfully enabled SCHED_RR scheduling for thread, with priority 87.
I: [pulseaudio] module-jack-source.c: JACK thread starting up.
I: [pulseaudio] core-util.c: Successfully enabled SCHED_RR scheduling for thread, with priority 91.
I:

uname -a is

Linux monstro 4.15.0-041500-lowlatency #201802011154 SMP PREEMPT Thu Feb 1 11:58:07 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

So, since jackd1 and its lib don’t give me this error and just swapping to jackd2 does give me the error, it looks like a bug in jackd2. Is this correct?

Every once in a while I cannot start Ardour. It seems that the problem is real-time scheduling.

I have it configured as suggested in https://wiki.linuxaudio.org/wiki/system_configuration and it usually works fine. To fix when the problem happens, I usually have to reboot the computer, but then all works fine. It would be very nice if I could fix the problem without rebooting, or even better, find out what is causing it.

For more details, when I start Ardour I get:

Session «/home/finotti/Recordings/GTR_test (snapshot GTR_test)» did not load successfully.

Here is the what the terminal says:

Code: Select all

$ ardour5
bind txt domain [gtk2_ardour5] to /usr/share/ardour5/locale
Ardour5.12.0 (built using 1:5.12.0-1 and GCC version 7.2.0)
ardour: [INFO]: Your system is configured to limit Ardour to only 1048576 open files
ardour: [INFO]: Loading system configuration file /etc/ardour5/system_config
ardour: [INFO]: Loading user configuration file /home/finotti/.config/ardour5/config
ardour: [INFO]: CPU vendor: GenuineIntel
ardour: [INFO]: AVX-capable processor
ardour: [INFO]: CPU brand: Intel(R) Core(TM) i7-4771 CPU @ 3.50GHz
ardour: [INFO]: Using SSE optimized routines
ardour: [INFO]: Loading default ui configuration file /etc/ardour5/default_ui_config
ardour: [INFO]: Loading user ui configuration file /home/finotti/.config/ardour5/ui_config
Color shuttle bg not found
ardour: [INFO]: Loading color file /usr/share/ardour5/themes/dark-ardour.colors
ardour: [INFO]: Loading ui configuration file /etc/ardour5/clearlooks.rc
ardour: [INFO]: Loading ui configuration file /etc/ardour5/clearlooks.rc
Found 4 along /home/finotti/.config/ardour5/templates:/usr/share/ardour5/templates
run dialog
Error opening file /usr/local/lib/lv2/lsp-plugins-lv2-1.0.23-x86_64/manifest.ttl (No such file or directory)
lilv_world_load_file(): error: Error loading file `file:///usr/local/lib/lv2/lsp-plugins-lv2-1.0.23-x86_64/manifest.ttl'
lilv_world_load_bundle(): error: Error reading file:///usr/local/lib/lv2/lsp-plugins-lv2-1.0.23-x86_64/manifest.ttl
Scanning folders for bundled LV2s: /usr/lib/ardour5/LV2
Error opening file /usr/local/lib/lv2/lsp-plugins-lv2-1.0.23-x86_64/manifest.ttl (No such file or directory)
lilv_world_load_file(): error: Error loading file `file:///usr/local/lib/lv2/lsp-plugins-lv2-1.0.23-x86_64/manifest.ttl'
lilv_world_load_bundle(): error: Error reading file:///usr/local/lib/lv2/lsp-plugins-lv2-1.0.23-x86_64/manifest.ttl
Set cursor set to default
Editor didn't find Editor/start-range in editor
Editor didn't find Editor/finish-range in editor
Editor didn't find Editor/jump-backward-to-mark in editor
Editor didn't find Region/split-region in editor
Editor didn't find Editor/jump-forward-to-mark in editor
Editor didn't find Editor/add-location-from-playhead in editor
Editor didn't find Editor/alternate-add-location-from-playhead in editor
Editor didn't find Editor/start-punch-range in editor
Editor didn't find Editor/finish-punch-range in editor
Editor didn't find Editor/addExistingAudioFiles in editor
Editor didn't find Editor/remove-location-from-playhead in editor
Editor didn't find Editor/alternate-remove-location-from-playhead in editor
Editor didn't find Editor/alternate-jump-backward-to-mark in editor
Editor didn't find Editor/alt-finish-range in editor
Editor didn't find Editor/alternate-jump-forward-to-mark in editor
Editor didn't find Editor/alt-start-range in editor
Editor didn't find Editor/nudge-next-forward in editor
Editor didn't find Editor/nudge-next-backward in editor
Editor didn't find Editor/start-loop-range in editor
Editor didn't find Editor/finish-loop-range in editor
Editor didn't find Editor/nudge-playhead-backward in editor
Editor didn't find Editor/nudge-playhead-forward in editor
Editor didn't find Editor/playhead-backward-to-grid in editor
Editor didn't find Editor/playhead-forward-to-grid in editor
Editor didn't find Editor/start-range in editor
Editor didn't find Editor/finish-range in editor
Editor didn't find Editor/jump-backward-to-mark in editor
Editor didn't find Region/split-region in editor
Editor didn't find Editor/jump-forward-to-mark in editor
Editor didn't find Editor/add-location-from-playhead in editor
Editor didn't find Editor/alternate-add-location-from-playhead in editor
Editor didn't find Editor/start-punch-range in editor
Editor didn't find Editor/finish-punch-range in editor
Editor didn't find Editor/addExistingAudioFiles in editor
Editor didn't find Editor/remove-location-from-playhead in editor
Editor didn't find Editor/alternate-remove-location-from-playhead in editor
Editor didn't find Editor/alternate-jump-backward-to-mark in editor
Editor didn't find Editor/alt-finish-range in editor
Editor didn't find Editor/alternate-jump-forward-to-mark in editor
Editor didn't find Editor/alt-start-range in editor
Editor didn't find Editor/nudge-next-forward in editor
Editor didn't find Editor/nudge-next-backward in editor
Editor didn't find Editor/start-loop-range in editor
Editor didn't find Editor/finish-loop-range in editor
Editor didn't find Editor/nudge-playhead-backward in editor
Editor didn't find Editor/nudge-playhead-forward in editor
Editor didn't find Editor/playhead-backward-to-grid in editor
Editor didn't find Editor/playhead-forward-to-grid in editor

Errors/Messages:
ERROR: JACK: Cannot use real-time scheduling (RR/5)(1: Operation not permitted)
ERROR: JACK: JackClient::AcquireSelfRealTime error
WARNING: Ignoring LV2 plugin "AT1" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "Big Meter" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "BLS1" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "REV1 (Ambisonic)" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "REV1 (Stereo)" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "ZynAlienWah" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "ZynChorus" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "ZynDistortion" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "ZynDynamicFilter" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "ZynEcho" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "ZynPhaser" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "ZynReverb" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring LV2 plugin "Vex" because its buffer-size requirements cannot be satisfied.
WARNING: Ignoring duplicate Linux VST plugin simpverb
Ignoring duplicate Linux VST plugin fx_hallreverb
Ignoring duplicate Linux VST plugin fx_saturation
Ignored VST plugin which is newer than cache: '/usr/lib/vst/LinuxSampler.so' (cache: '/home/finotti/.cache/ardour5/vst/779437eebce16d89fce50a63d4e7f17a299e12cd.fsi64')
INFO: Re-Scan Plugins (Preferences > Plugins) to update the cache, also make sure your system-time is set correctly.
WARNING: Ignored VST plugin which is newer than cache: '/usr/lib/vst/StereoSourceSeparation.so' (cache: '/home/finotti/.cache/ardour5/vst/20b5110195eb041270ee0df7782ac95a86653816.fsi64')
INFO: Re-Scan Plugins (Preferences > Plugins) to update the cache, also make sure your system-time is set correctly.
WARNING: Ignored VST plugin which is newer than cache: '/usr/lib/vst/vex.so' (cache: '/home/finotti/.cache/ardour5/vst/c812ed63c2097db4c2e5962a9a9702137367b438.fsi64')
INFO: Re-Scan Plugins (Preferences > Plugins) to update the cache, also make sure your system-time is set correctly.
WARNING: Ignored VST plugin which is newer than cache: '/usr/lib/vst/JuceDemoPlugin.so' (cache: '/home/finotti/.cache/ardour5/vst/b609394c8632eaa690a22f8ba207bfacbd1bf10f.fsi64')
INFO: Re-Scan Plugins (Preferences > Plugins) to update the cache, also make sure your system-time is set correctly.
WARNING: Ignoring duplicate Linux VST plugin MaPitchshift
Ignored VST plugin which is newer than cache: '/usr/lib/vst/ReFine.so' (cache: '/home/finotti/.cache/ardour5/vst/15687fde822c90fe46b52107f62a13e91f59359e.fsi64')
INFO: Re-Scan Plugins (Preferences > Plugins) to update the cache, also make sure your system-time is set correctly.
WARNING: Ignoring duplicate Linux VST plugin MaFreeverb
Ignored VST plugin which is newer than cache: '/usr/lib/vst/Luftikus.so' (cache: '/home/finotti/.cache/ardour5/vst/44d52479222c8a8505ad38081c5865420850eb68.fsi64')
INFO: Re-Scan Plugins (Preferences > Plugins) to update the cache, also make sure your system-time is set correctly.
WARNING: Ignored VST plugin which is newer than cache: '/usr/lib/vst/HiReSam.so' (cache: '/home/finotti/.cache/ardour5/vst/e0da839d53bcb4a41455649a59602577c80031ea.fsi64')
INFO: Re-Scan Plugins (Preferences > Plugins) to update the cache, also make sure your system-time is set correctly.
WARNING: Ignoring duplicate Linux VST plugin MaGigaverb
Video-monitor 'xjadeo' was not found. Please install http://xjadeo.sf.net/ (a custom path to xjadeo can be specified by setting the XJREMOTE environment variable. It should point to an application compatible with xjadeo's remote-control interface 'xjremote').

see also http://manual.ardour.org/video-timeline/setup/

Install the 'ardour-video-timeline' Debian package!

INFO: Loading bindings from /home/finotti/.config/ardour5/ardour.keys
Loading menus from /etc/ardour5/ardour.menus
ERROR: JACK: Cannot create thread res = 1

run dialog
Cannot get session parameters.

I think the relevant parts are:

Code: Select all

ERROR: JACK: Cannot use real-time scheduling (RR/5)(1: Operation not permitted)
ERROR: JACK: JackClient::AcquireSelfRealTime error

The system is running Debian Sid (up to date) with KXStudio, although Ardour is from Debian (as it’s newer):

Code: Select all

$ apt policy ardour
ardour:
  Installed: 1:5.12.0-1
  Candidate: 1:5.12.0-1
  Version table:
 *** 1:5.12.0-1 500
        500 http://httpredir.debian.org/debian sid/main amd64 Packages
        100 /var/lib/dpkg/status
     1:5.11.4-1kxstudio1v5 500
        500 http://kxstudio.linuxaudio.org/repo gcc5/free amd64 Packages
     1:5.11.4-1kxstudio1 500
        500 http://kxstudio.linuxaudio.org/repo stable/free amd64 Packages

But it also happened with KXStudio’s version before and I don’t think that Ardour is the problem.

The interface is a Focusrite 2i2 2nd generation. Here is more info on the system:

Code: Select all

$ inxi -A -v3
System:    Host: debian Kernel: 4.13.0-7.slh.1-aptosid-amd64 x86_64 bits: 64 gcc: 7.2.1
           Desktop: KDE Plasma 5.10.5 Distro: aptosid 2013-01 Ἑσπερίδες - kde-full - (201305050307)
Machine:   Device: desktop System: ASUS product: All Series serial: N/A
           Mobo: ASUSTeK model: Z87-PRO v: Rev 1.xx serial: N/A
           UEFI: American Megatrends v: 2103 date: 08/18/2014
CPU:       Quad core Intel Core i7-4771 (-HT-MCP-) arch: Haswell rev.3 cache: 8192 KB
           flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 27981
           clock speeds: max: 3900 MHz 1: 3497 MHz 2: 3497 MHz 3: 3497 MHz 4: 3497 MHz 5: 3497 MHz 6: 3497 MHz
           7: 3497 MHz 8: 3497 MHz
Graphics:  Card: Intel Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller bus-ID: 00:02.0
           Display Server: x11 (X.Org 1.19.5 ) driver: intel Resolution: 1280x1024@75.02hz, 1920x1080@60.00hz
           OpenGL: renderer: Mesa DRI Intel Haswell Desktop version: 4.5 Mesa 17.2.3 Direct Render: Yes
Audio:     Card-1 Intel 8 Series/C220 Series High Definition Audio Controller bus-ID: 00:1b.0
           Card-2 Intel Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller bus-ID: 00:03.0
           Card-3 C-Media CMI8788 [Oxygen HD Audio] driver: snd_oxygen port: d000 bus-ID: 05:04.0                                    
           Card-4 Logitech QuickCam Communicate STX driver: USB Audio usb-ID: 001-005                                                
           Card-5 Focusrite-Novation driver: USB Audio usb-ID: 001-008                                                               
           Sound: Advanced Linux Sound Architecture v: k4.13.0-7.slh.1-aptosid-amd64                                                 
Network:   Card: Intel Ethernet Connection I217-V driver: e1000e v: 3.2.6-k port: f080 bus-ID: 00:19.0                               
           IF: eth0 state: up speed: 100 Mbps duplex: full mac: e0:3f:49:a3:4c:a6                                                    
Drives:    HDD Total Size: 9257.9GB (54.3% used)                                                                                     
           ID-1: model: WDC_WD10EALS                                                                                                 
           ID-2: model: Samsung_SSD_840                                                                                              
           ID-3: model: WDC_WD20EARX                                                                                                 
           ID-4: model: WDC_WD20EARX                                                                                                 
           ID-5: model: WDC_WD40EZRX                                                                                                 
Info:      Processes: 349 Uptime: 1 day Memory: 4906.9/15925.3MB Init: systemd runlevel: 5 Gcc sys: 7.2.0                            
           Client: Shell (bash 4.4.121) inxi: 2.3.40

Any ideas or suggestions? Even a way to fix it without rebooting would be great!

Thanks!

This article describes the setup of a playing sound with JACK (JACK Audio Connection Kit).

JACK is a sound server for professional audio production, that provides low-latency communication for applications that implement the JACK API (like mpv).

Tip
JACK is designed to work with only one active audio interface (sound card), because of technical reasons needed to guarantee audio quality, latency, and synchronization. Remember, JACK is designed for studio quality work, not for ease of use. If more, or different, inputs and outputs are needed, use a different audio interface. It may be possible to get multiple interfaces working at the same time with JACK, but it is not trivial, and results may vary.

Note
When the JACK daemon is running, usual system sound may no longer be output. To restore sound there are several options[1], such as configuring applications to output to JACK, using a second soundcard, or bridging.

Installation

JACK uses ALSA for accessing the sound card hardware, be sure ALSA is working.

There are two implementations of the JACK API, both implementations are considered equivalent. JACK2 is usually the one to go for, JACK 1 is no longer under active development.

JACK is the original implementation, it uses a C API and has built-in Linux MIDI integration. JACK2 is a re-implementation in C++ that has support for multiprocessing and D-Bus, while MIDI support is handled by ALSA. Visit what are the differences between JACK 1 and JACK2 for an in-depth comparison.

USE flags

USE flags for
media-sound/jack2

Jackdmp jack implemention for multi-processor machine

alsa Add support for media-libs/alsa-lib (Advanced Linux Sound Architecture)
classic Enable building of jackd
dbus Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc)
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
ieee1394 Enable FireWire/iLink IEEE1394 support (dv, camera, …)
libsamplerate Build with support for converting sample rates using libsamplerate
metadata Enable metadata API
opus Enable Opus audio codec support
pam Add basic realtime configuration via sys-auth/realtime-base
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking
tools Pull basic tools (e.g. jack_lsp/connect) from media-sound/jack-example-tools

Emerge

Emerge the sound server:

root #emerge --ask media-sound/jack2

Warning
JACK2 will successfully compile with LTO enabled, but incoming connections will suffer a segmentation fault, fail to see ports, or fail to connect to open ports. Be sure to compile without LTO for a functional experience.

The JACK 1 package is media-sound/jack-audio-connection-kit (link provides a list of JACK 1 USE flags).

Global JACK USE flag

The global jack USE flag enables support for JACK in other packages, so they can submit sound to a JACK server:

The euse command is part of app-portage/gentoolkit.

After setting this, be sure to update the system so the changes take effect:

root #emerge --ask --changed-use --deep @world

Additional software

There is a JACK configuration and control software package media-sound/cadence:

root #emerge --ask media-sound/cadence

Another alternative is media-sound/qjackctl:

root #emerge --ask media-sound/qjackctl

See the article on music production for software to use with JACK.

The JACK website has a page on sofware that uses JACK.

Configuration

Sound server

All users that need JACK should be in the audio group:

root #usermod -a -G audio $USERNAME

JACK can be configured using the jack_control utility. A basic configuration script for JACK could look like:

CODE A basic configuration

jack_control start
jack_control ds alsa
jack_control dps device hw:2,0
jack_control dps rate 48000
jack_control dps nperiods 2
jack_control dps period 64

To determine the appropriate playback device (instead of hw:2,0):

Bridging

JACK can route sound which was sent to other sound systems like PulseAudio[2] and ALSA through itself.

PulseAudio

To use PulseAudio’s JACK module media-sound/pulseaudio needs to have the jack USE flag enabled.

In order to route all audio from PulseAudio to JACK, the JACK sink needs to be configured:

user $pactl load-module module-jack-sink channels=2

user $pactl load-module module-jack-source

user $pacmd set-default-sink jack_out

PulseAudio will recognize that JACK started and will bridge its audio to JACK.

Troubleshooting

«Cannot use real-time scheduling» error

Some applications may show a permission error when trying to connect to Jack, for example:

CODE Error message

ERROR: JACK: Cannot create thread res = 1
ERROR: JACK: JackClient::AcquireSelfRealTime error
ERROR: JACK: Cannot use real-time scheduling (RR/5) (1: Operation not permitted)

Adding the current user to the realtime group should solve this:

root #usermod -a -G realtime $USERNAME

Log out and log back in to apply group change.

See also

  • ALSA — describes the setup of a sound card with ALSA (Advanced Linux Sound Architecture).
  • PipeWire — low-latency, graph-based, processing engine and server, for interfacing with audio and video devices.
  • PulseAudio — a multi-platform, open source, sound server that provides a number of features on top of the low-level audio interface ALSA

References

  1. https://jackaudio.org/faq/pulseaudio_and_jack.html
  2. https://jackaudio.org/faq/pulseaudio_and_jack.html

Так. Чем больше я читаю про гарантии «реального времени» в планировщике ядра, тем меньше понимаю.

Вот у нас есть настройка

/proc/sys/kernel/sched_rt_runtime_us

. Если я правильно понимаю, она задаёт количество микросекунд, на которое приложения реального времени могут занять процессор в один период планирования (или -1, если мы разрешаем им занять всё время). Так как период планирования равен одной секунде:

$ cat /proc/sys/kernel/sched_rt_period_us
1000000
а в

/proc/sys/kernel/sched_rt_runtime_us

по умолчанию число 950000, каждую секунду задачи реального времени могут занять 0,95 с.

Дальше приложения могут с помощью системного вызова sched_setscheduler задавать себе приоритет, в том числе приоритет реального времени — числом от 1 до 99, которое означает долю времени ЦП, гарантируемого приложению.

Я (очень бегло) посмотрел исходники, похоже, в JACK именно это и происходит.

Здесь, насколько я понимаю, POSIX-версия реализации тредов в JACK пытается получить приоритет реального времени с помощью вызова функции

pthread_setschedparam()

: https://github.com/jackaudio/jack2/blob/0ee218826b299a95f937b7c88f10af56534d6cbd/posix/JackPosixThread.cpp#L244
Здесь pthreads зовут функцию

__sched_setscheduler()

из glibc: https://code.woboq.org/userspace/glibc/nptl/pthread_setschedparam.c.html#56
Реализацию этого дела в glibc для Linux я сходу не нашёл (здесь только заглушка, а как подставляется реализация для конкретной платформы, я не понимаю), но нет оснований полагать, что там что-то кроме системного вызова

sched_setscheduler

.

Пока всё понятно. Довольно логичная и простая система.

Но! Дальше на сцене появляются опция CONFIG_RT_GROUP_SCHED, Леннарт Поттеринг и cgroups — и всё безнадёжно запутывается.

Эта опция включена в стандартном альтовом ядре:

sudo cat /boot/config-5.4.31-std-def-alt1 | grep CONFIG_RT_GROUP_SCHED
CONFIG_RT_GROUP_SCHED=y

Если она включена, запуск приложений реального времени от непривилегированного пользователя становится невозможен, пока они не включены в некую группу, которой выделены ресурсы ЦП:

By default all bandwidth is assigned to the root group and new groups get the
period from /proc/sys/kernel/sched_rt_period_us and a run time of 0. If you
want to assign bandwidth to another group, reduce the root group’s bandwidth
and assign some or all of the difference to another group.

Realtime group scheduling means you have to assign a portion of total CPU
bandwidth to the group before it will accept realtime tasks. Therefore you will
not be able to run realtime tasks as any user other than root until you have
done that, even if the user has the rights to run processes with realtime
priority!

В апреле 2008 Леннарт просит включить

CONFIG_RT_GROUP_SCHED

в ядре Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=442959 в надежде, что PulseAudio от этого станет работать лучше (уже смешно).

Но! В июне 2015 всё тот же Леннарт просит выключить

CONFIG_RT_GROUP_SCHED

в ядре Fedora!

И вот теперь у меня вопросы.

  • Зачем в std-def включена опция CONFIG_RT_GROUP_SCHED?
  • Как включивший эту опцию человек предлагает запускать от непривилегированного пользователя приложения, нуждающиеся в режиме реального времени (например, jackd)?
  • Можно ли, не меняя конфиг ядра std-def, сделать jackd работоспособным «из коробки»?

Люди, принимающие такие решения, вообще заглядывают на этот форум?

Понравилась статья? Поделить с друзьями:
  • J540 ауди ошибка
  • J4220 ошибка kyocera
  • Iveco eurocargo ошибка vcm
  • J4201 kyocera ошибка
  • Iveco eurocargo ошибка met