USB Audio Interface JACK Xruns on Linux but not on Windows

Talk about your MIDI interfaces, microphones, keyboards...

Moderators: MattKingUSA, khz

vittopascu

USB Audio Interface JACK Xruns on Linux but not on Windows

Post by vittopascu »

Hello everyone,

This is actually the copy of a thread that I opened on the Linux Mint forum some time ago, but they invited me to join this forum to get better help, so I will replicate my original post here, and add some potentially useful info.

I wanted to produce some music on linux, so here are my specs:

OS: Linux Mint 19.1 Cinnamon 4.0.10
Kernel: 4.15.0-48-lowlatency
Processor: AMD FX-8350
Memory: 16GB
SSD: Samsung EVO 860
Graphics: NVIDIA GeForce GTX 760
Motherboard: Asrok 970M Pro3
Audio Interface: Steinberg-Yamaha UR22 (USB 2.0)
WIFI: TP-Link, Qualcomm Atheros AR93xx

I installed qjackctl and I set it up to 128-sample-per frame, 2 buffers, 48kHz.

When my audio interface is connected to USB 2.0 I get many many xruns while reproducing sound or recording. Connecting it to an USB 3.0 port helps a lot but I still get occasional audible xruns. I tried disabling wifi and even disconnecting all USB peripherals except for the mouse without success.

However I did the same experiment booting windows 10 on the same exact machine and same exact recording software and I can set asio drivers as low as 48 sample buffers without having audible dropouts, even when connected to USB 2.0.

So I installed the same Linux mint and kernel on an old lenovo W510, same audio interface, still on USB 2.0 port and I can set QJackctl all the way down to 64-samples-per-frame and 2 buffers without ever having xruns (neither audible nor measured by the software).

Here is the output of lsusb (at the moment the audio interface is connected to USB 2.0):

Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 010: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
Bus 001 Device 006: ID 046d:0825 Logitech, Inc. Webcam C270
Bus 001 Device 005: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 004: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 002: ID 1a40:0201 Terminus Technology Inc. FE 2.1 7-port Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 009 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 008 Device 002: ID 0499:1509 Yamaha Corp.
Bus 008 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Here is the output of cat /proc/interrupts with qjackctl up & running:

Code: Select all

            CPU0       CPU1       CPU2       CPU3       CPU4       CPU5       CPU6       CPU7       
   0:        121          0          0          0          0          0          0          0   IO-APIC    2-edge      timer
   8:          0          0          0          0          0          1          0          0   IO-APIC    8-edge      rtc0
   9:          7          0          0          0          0          0          0          0   IO-APIC    9-fasteoi   acpi
  14:     474623          0          0          0          0          0      69403          0   IO-APIC   14-edge      pata_atiixp
  15:          0          0          0          0          0          0          0          0   IO-APIC   15-edge      pata_atiixp
  16:     226425          0       1653          0     314042     673199       1474          0   IO-APIC   16-fasteoi   ath9k, snd_hda_intel:card0
  17:     808386          0      59914          0          0          0       3856          0   IO-APIC   17-fasteoi   ehci_hcd:usb1, ehci_hcd:usb2, ehci_hcd:usb3
  18:     180640     101854          0      31377      11552          0      81015          0   IO-APIC   18-fasteoi   ohci_hcd:usb4, ohci_hcd:usb5, ohci_hcd:usb6, ohci_hcd:usb7
  19:        601          0          0        111          0          0          0          0   IO-APIC   19-fasteoi   ahci[0000:00:11.0]
  27:    2670562          0          0          0         53          0          0     854355   PCI-MSI 1048576-edge      xhci_hcd
  28:          0          0          0          0          0          0          0          0   PCI-MSI 2621440-edge      enp5s0
  29:          0       2580          0          0          0          0          0          0   IO-APIC   21-fasteoi   snd_hda_intel:card1
  31:    3062302          0          0        419          0    1505711          0          0   PCI-MSI 524288-edge      nvidia
 NMI:         44         75        124         79        127         85        127         83   Non-maskable interrupts
 LOC:    4605934    2244637    4563741    2151393    4407764    2376807    4894042    2436888   Local timer interrupts
 SPU:          0          0          0          0          0          0          0          0   Spurious interrupts
 PMI:         44         75        124         79        127         85        127         83   Performance monitoring interrupts
 IWI:    4146696    1791447    3029008    2154402    2183476    1939071    3224444    2257501   IRQ work interrupts
 RTR:          0          0          0          0          0          0          0          0   APIC ICR read retries
 RES:    7195741    4476425    8251162    4911949    6730785    3220325    8400639    4115789   Rescheduling interrupts
 CAL:     313001     271695     301671     266011     299536     263109     300447     257948   Function call interrupts
 TLB:     258640     211832     264661     222807     263107     216754     260344     212262   TLB shootdowns
 TRM:          0          0          0          0          0          0          0          0   Thermal event interrupts
 THR:          0          0          0          0          0          0          0          0   Threshold APIC interrupts
 DFR:          0          0          0          0          0          0          0          0   Deferred Error APIC interrupts
 MCE:          0          0          0          0          0          0          0          0   Machine check exceptions
 MCP:        120        118        118        118        118        118        118        118   Machine check polls
 HYP:          0          0          0          0          0          0          0          0   Hypervisor callback interrupts
 ERR:       3699
 MIS:          0
 PIN:          0          0          0          0          0          0          0          0   Posted-interrupt notification event
 NPI:          0          0          0          0          0          0          0          0   Nested posted-interrupt event
 PIW:          0          0          0          0          0          0          0          0   Posted-interrupt wakeup event


Any idea of what may cause the problem on my specific machine, and in particular, why the problem does not appear on windows with the same exact machine?

Thank you all very much
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by merlyn »

Is this :

Bus 001 Device 010: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC

your soundcard? There is a lot on USB bus 001. So swapping to USB 3 improves the situation because the soundcard has a bus to itself.
User avatar
Linuxmusician01
Established Member
Posts: 1524
Joined: Mon Feb 23, 2015 2:38 pm
Location: Holland
Has thanked: 756 times
Been thanked: 137 times

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by Linuxmusician01 »

Do you use a USB hub?
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by merlyn »

I see the soundcard now :

Bus 008 Device 002: ID 0499:1509 Yamaha Corp.

Using

Code: Select all

lsusb|sort
would make it a bit easier to read.

What is a bit weird is that usb8 doesn't appear in /proc/interrupts :

Code: Select all

 ohci_hcd:usb4, ohci_hcd:usb5, ohci_hcd:usb6, ohci_hcd:usb7
ehci is USB 2.0, ohci is USB 1.1 and xhci is USB 3.0, so thre's a USB 2.0 missing from /proc/interrupts -- the one the soundcard is plugged into.

Or the problem may be Nvidia drivers. What drivers are you using?
vittopascu

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by vittopascu »

merlyn wrote:I see the soundcard now :

Bus 008 Device 002: ID 0499:1509 Yamaha Corp.

Using

Code: Select all

lsusb|sort
would make it a bit easier to read.

What is a bit weird is that usb8 doesn't appear in /proc/interrupts :

Code: Select all

 ohci_hcd:usb4, ohci_hcd:usb5, ohci_hcd:usb6, ohci_hcd:usb7
ehci is USB 2.0, ohci is USB 1.1 and xhci is USB 3.0, so thre's a USB 2.0 missing from /proc/interrupts -- the one the soundcard is plugged into.

Or the problem may be Nvidia drivers. What drivers are you using?
Using Nvidia drivers for my graphics indeed.
vittopascu

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by vittopascu »

Linuxmusician01 wrote:Do you use a USB hub?
No I am plugging straight into the PC back-panel. But then again, there might still be a hub in between...
Jack Winter
Established Member
Posts: 381
Joined: Sun May 28, 2017 3:52 pm

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by Jack Winter »

Do you have the possibility to try with an onboard intel GPU?

IME, nvidia with the lowlatency kernel has quite a lot of delay in the kernel thread scheduling.

Also make sure that you set the priorities right for your soundcard (usb hub) interrupt and audio threads (so that they don't get interrupted by other threads running).
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by merlyn »

vittopascu wrote:Using Nvidia drivers for my graphics indeed.
You could be using 'nouveau' or Nvidia proprietary drivers. I have found the proprietary drivers better with a low-latency kernel.
User avatar
Linuxmusician01
Established Member
Posts: 1524
Joined: Mon Feb 23, 2015 2:38 pm
Location: Holland
Has thanked: 756 times
Been thanked: 137 times

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by Linuxmusician01 »

I read here that this device needs drivers for Windows and MacOS. If something needs drivers for MacOS then it's probably not class compliant.

I read here in the Steinberg forum that for the URM28M (same as your URM22??) you must turn on class compliancy in some way. Quote from that forum topic (post from 11 feb 2019):
Turn on the device while holding down OUTPUT button C, and keep pressing the OUTPUT C button until an INPUT meter/OUTPUT meter flashes.The UR28M enters Class Compliant mode for Apple iPad connectivity. While in the Class Compliant mode, the power button flashes several times by pressing the power button. To turn off the Class Compliant mode, turn on the power while holding down OUTPUT button C again.
Maybe that'll help. If not in that same Steinberg forum topic is a lot written about compiling a driver etc. Maybe that'll help. However, somebody says on 2 dec 2018 that it works in Ubuntu 18.04. Do you hear pops and tics? Maybe those xruns are not as bad as you might think...

Good luck! :)
vittopascu

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by vittopascu »

Jack Winter wrote:Do you have the possibility to try with an onboard intel GPU?

IME, nvidia with the lowlatency kernel has quite a lot of delay in the kernel thread scheduling.

Also make sure that you set the priorities right for your soundcard (usb hub) interrupt and audio threads (so that they don't get interrupted by other threads running).
Sadly I am running on AMD so no integrated graphics... I could get my hands on some old AMD graphics card if necessary though.

Would you be so kind to guide me through the process of setting the priorities? I am a complete incompetent with these things...
Jack Winter
Established Member
Posts: 381
Joined: Sun May 28, 2017 3:52 pm

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by Jack Winter »

Setting the priority of the interrupt is probably easiest done by an utility called rtirq. This is what most people use. I'm a little bit loath at going into details as it's a long discussion if you get into the details of it all.

The basic idea is to configure the system so that the interrupt for the usb hub that the soundcard is connected to has a very high priority let's say at 95, then run JACK or your applications audio threads at a lower priority, say at 80. Like this when there is audio work to be done, that takes precedence over graphics, disk i/o, etc.

I'm pretty sure it's been extensively discussed on this board and also elsewhere on the net :)

But do give me a holler if you run into problems..
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by merlyn »

Before you tweak rtirq we should probably check the basics.

Do you have threadirqs loaded?

Code: Select all

grep threadirqs /proc/cmdline
Is your user in the audio group?

Code: Select all

groups
What does /etc/security/limits.conf look like?

Code: Select all

cat /etc/security/limits.conf
vittopascu

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by vittopascu »

merlyn wrote:Before you tweak rtirq we should probably check the basics.

Do you have threadirqs loaded?

Code: Select all

grep threadirqs /proc/cmdline
Is your user in the audio group?

Code: Select all

groups
What does /etc/security/limits.conf look like?

Code: Select all

cat /etc/security/limits.conf
The first command outputs nothing.

I am in group audio, I just verified that.

Here is the output of the third command:

# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
#
#Where:
#<domain> can be:
# - a user name
# - a group name, with @group syntax
# - the wildcard *, for default entry
# - the wildcard %, can be also used with %group syntax,
# for maxlogin limit
# - NOTE: group and wildcard limits are not applied to root.
# To apply a limit to the root user, <domain> must be
# the literal username root.
#
#<type> can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#<item> can be one of the following:
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open files
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit (KB)
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to values: [-20, 19]
# - rtprio - max realtime priority
# - chroot - change root to directory (Debian-specific)
#
#<domain> <type> <item> <value>
#

#* soft core 0
#root hard core 100000
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#ftp - chroot /ftp
#@student - maxlogins 4

# End of file
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by merlyn »

If the first command outputs nothing threadirqs isn't loaded.

To load it edit /etc/default/grub with sudo. Add to this line :

Code: Select all

GRUB_CMDLINE_LINUX="threadirqs"
Now regenerate grub.cfg :

Code: Select all

sudo update-grub
You'll need to reboot before that takes effect. Before you do that edit limits.conf. Add :

Code: Select all

@audio - rtprio 99
@audio - memlock unlimited
Now reboot. You might see an improvement with those changes. We can tweak rtirq next.
vittopascu

Re: USB Audio Interface JACK Xruns on Linux but not on Windows

Post by vittopascu »

Hello,

SO this evening I had a spike in determination and I did some intense debugging.

First of all I followed the steps suggested by Merlyn
merlyn wrote:If the first command outputs nothing threadirqs isn't loaded.

To load it edit /etc/default/grub with sudo. Add to this line :

Code: Select all

GRUB_CMDLINE_LINUX="threadirqs"
Now regenerate grub.cfg :

Code: Select all

sudo update-grub
You'll need to reboot before that takes effect. Before you do that edit limits.conf. Add :

Code: Select all

@audio - rtprio 99
@audio - memlock unlimited
Now reboot. You might see an improvement with those changes. We can tweak rtirq next.
I can now see that threadirq is running, but still no change.

I followed every single instruction in this link https://wiki.linuxaudio.org/wiki/system ... ime_kernel and had my system diagnosed with the realtimeconfigquickscan as suggested at the top of the page, which is a fantastic little tool. Still no change.

Now I have the situation where I get an xrun exactly every exactly 50 seconds, even with wifi disabled. What could the cause be? Is there a way to diagnose what could be interfering at such regular intervals?
Post Reply