geoffreybennett/alsa-scarlett-gui

Game crashing due to PulseAudio channel mask error

Opened this issue · 3 comments

Confirmation

  • I confirm that I have read the FAQ.

Issue Category

Please select the category that best describes your issue:

  • Help Request

Linux Distribution and Version

  • Distribution: Arch
  • Version: rolling

Kernel Version

  • Kernel version: 6.8.8-arch1-1

Kernel Messages

❯ sudo dmesg | grep -C 5 -i focusrite
[    3.510230] usb 3-5: new full-speed USB device number 3 using xhci_hcd
[    3.570247] systemd[1]: bpf-lsm: LSM BPF program attached
[    3.645330] usb 1-2: New USB device found, idVendor=1235, idProduct=8215, bcdDevice= 6.6c
[    3.645334] usb 1-2: New USB device strings: Mfr=1, Product=3, SerialNumber=2
[    3.645336] usb 1-2: Product: Scarlett 18i20 USB
[    3.645337] usb 1-2: Manufacturer: Focusrite
[    3.645339] usb 1-2: SerialNumber: P9300TH0181184
[    3.666963] usb 3-5: config 1 has an invalid interface number: 2 but max is 1
[    3.666965] usb 3-5: config 1 has no interface number 1
[    3.678964] usb 3-5: New USB device found, idVendor=0b05, idProduct=18f3, bcdDevice= 1.00
[    3.678966] usb 3-5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
--
[    5.936440] hid-generic 0003:046D:4079.000A: input,hidraw8: USB HID v1.11 Keyboard [Logitech Wireless Mouse PID:4079] on usb-0000:07:00.1-1.1.1/input2:1
[    5.958605] iwlwifi 0000:05:00.0: Registered PHC clock: iwlwifi-PTP, with index: 1
[    6.410842] input: Logitech G Pro  as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:08.0/0000:07:00.1/usb1/1-1/1-1.1/1-1.1.1/1-1.1.1:1.2/0003:046D:C539.0006/0003:046D:4079.000A/input/input29
[    6.410994] logitech-hidpp-device 0003:046D:4079.000A: input,hidraw8: USB HID v1.11 Keyboard [Logitech G Pro ] on usb-0000:07:00.1-1.1.1/input2:1
[    8.534103] igb 0000:06:00.0 enp6s0: igb: enp6s0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX
[    8.837291] usb 1-2: Focusrite Scarlett Gen 3 Mixer Driver enabled (pid=0x8215); report any issues to https://github.com/geoffreybennett/scarlett-gen2/issues
[    8.838909] usb 1-2: Firmware version 1644
[    8.864151] usb 1-2: Quirk or no altset; falling back to MIDI 1.0
[    8.864421] usbcore: registered new interface driver snd-usb-audio
[   23.474150] systemd-journald[322]: /var/log/journal/67bdc304dca641c3b8f6e5621cd0d6d4/user-1000.journal: Journal file uses a different sequence number ID, rotating.
[   29.182212] [drm:drm_new_set_master] *ERROR* [nvidia-drm] [GPU ID 0x00000a00] Failed to grab modeset ownership

Focusrite Interface Series and Model

  • Series: Scarlett 3rd Gen
  • Model: 18i20

Audio System

  • PipeWire

Issue Description

I am very uninformed on Pulse, PipeWire, Wine, and even Arch Linux, so forgive me here, I know this is a stretch of an ask. When trying to play the game Snowrunner via Steam and Proton, the game's engine crashes when it first tries to play audio. The crash has errors like so:

❯ grep 'err.*pulse.*' steam-1465360.log
1756.040:0124:0128:err:pulse:pulse_spec_from_waveformat Invalid channel mask: 0/20 and 0(0)
1756.040:0124:0128:err:pulse:pulse_spec_from_waveformat Invalid format! Channel spec valid: 0, format: 5

Here's the full log file: steam-1465360.log

There's a few different errors going on. I'm curious if there is something I could configure or adjust in this spaghetti mess to help avoid crashes like this. I've had other games work just fine, using entirely different engines. This game crashes in its native crash dialog, so it does seem like something in the Wine side could be configured to better handle this situation.

I know none of these specifics are at fault of this repo, its code, or any of your work, again I know I'm asking for a lot here. I think a workaround from what I've dug up online is to have a virtual audio device instead of directly using the interface as-is.

Let me know if there's anything I can provide to help. If this is too far out of scope I'd gladly read some documentation to better understand how this all interchanges and what I can do to make it function properly without a workaround.

Actually if I spent another 10 minutes digging, I would've found my solution. It turns out you can disable the Wine Pulse driver with a launch parameter for the game:

WINEDLLOVERRIDES="winepulse.drv=" %command%

Everything is fine and dandy now. I'll close this out :)

And thanks for your work on this software, it's incredibly good!

Edit: This only works per-application, so I am still hunting for a final solution, but I suspect I'll find one eventually.

Hi @Woovie,

I think you're right that this is out of scope; looks like a bug in winepulse.drv I guess. I'm also guessing that it doesn't know what to do with a 20-channel soundcard. I found this code https://github.com/Jebaitedneko/wine-staging/blob/ea3e1cd017bf5a5a11eb64408f1a28c2fd618050/dlls/winepulse.drv/pulse.c which is related. It might not be exactly the code you're running, but those errors "Invalid channel mask" and "Invalid format" match up with your output above. As I read it, the code is assuming that your soundcard has between 1 and 8 channels. 1 = mono, 2 = stereo, 3 = stereo + lfe, 4 = surround, 5 = surround + lfe, etc. up to 8 = 5.1 surround + side L&R.

Besides fixing whatever code is actually broken, I can think of two ideas to workaround this issue (presuming my guess as to the cause is correct). One is to create a virtual 2-channel device. Please see this comment #115 (comment) where I describe how to create virtual PulseAudio output devices. If you can have Wine use that instead, that will hopefully fix the issue.

The other idea I had is to use a ALSA UCM profile to create a virtual 2-channel device. Please see https://github.com/geoffreybennett/alsa-ucm-conf/ which has files that go into /usr/share/alsa. The particular files you're need are ucm2/USB-Audio/USB-Audio.conf and ucm2/USB-Audio/Focusrite/*. Make a backup of your /usr/share/alsa directory, then try replacing those files with the ones from my repo. Then restart PulseAudio (or reboot), and you should have a virtual "Line Out 1-2" device available that goes only to PCM Out 1 & 2 (then you get to choose where those go with alsa-scarlett-gui).

I'll reopen this for now and hopefully you can try out those two ideas and report back if they work.

Regards,
Geoffrey.

Thanks so much! I forgot to update here, I ended up doing essentially what you suggested via pactl and pw-link. I guess Wine interfaces via pipewire-pulse?

pactl load-module module-null-sink media.class=Audio/Sink sink_name=too-many-ch
pactl set-default-sink too-many-ch
pw-link too-many-ch:monitor_FL alsa_output.usb-Focusrite_Scarlett_18i20_USB_P9300TH0181184-00.multichannel-output:playback_AUX0
pw-link too-many-ch:monitor_FR alsa_output.usb-Focusrite_Scarlett_18i20_USB_P9300TH0181184-00.multichannel-output:playback_AUX1

Once that was done, it routes great!

image

I also found a relevant issue with Wine and commented there https://bugs.winehq.org/show_bug.cgi?id=53799

I'll share this thread there as well so they can hopefully resolve the issue and prevent crashes.