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

Have to restart pipewire after login to get goxlr to work #123

Open
wutscher opened this issue Sep 3, 2023 · 11 comments
Open

Have to restart pipewire after login to get goxlr to work #123

wutscher opened this issue Sep 3, 2023 · 11 comments

Comments

@wutscher
Copy link

wutscher commented Sep 3, 2023

Every time i log in i have to restart pipewire with systemctl --user restart pipewire to get the devices to function properly. It would be nice to have an automated or built in solution for this.

OS: Arch linux (kernel 6.4.12-arch1-1)
Utility Version: 0.12.6
GoXLR Type: Mini
audio: pipewire with wireplumber

@FrostyCoolSlug
Copy link
Member

This one is unfortunately a tricky problem to solve, as it's likely more of a pipewire issue than a utility issue.

The GoXLR when it's 'freshly' powered on requires a proprietory USB command to be sent to it to activate the interface and it's channels.

So what happens is the following:

  1. The ALSA usb-audio driver picks up the GoXLR and loads it
  2. The utility starts, it detatches the usb-audio driver (taking it away from ALSA) and takes control of the device
  3. The utility sends the initialisation packets to get the GoXLR started
  4. The utility will then issue a USB Reset command for the device.
  5. The kernel will detatch and reattach the device, the ALSA usb-audio driver picks up the GoXLR and loads it.

From there everything functions normally.

My best guess is that pipewire is tripping up between 1 and 2, it starts loading the card profile and the card is yanked away before it's fully setup, to the point where even after the reset at 4/5 it's not able to pick the card up again.

The best I can really do to attempt to mitigate this would be to add a brief pause before initialisation, and hope that pipewire can get everything ready to handle the impending reset. There's also the possible option of adding the initialisation into the usb-audio driver as a device quirk, which would remove the need for the utility to do any of that, but that's a somewhat more difficult proposition.

@FrostyCoolSlug
Copy link
Member

So I've spent some time testing this, and it seems the actual issue is occurring between 3 and 4..

During the teardown after the initialisation packets are handled, I release the interface and reset the device, from what I can tell, during the nanoseconds between the two commands ALSA / pipewire try a re-grab on the device, and the reset is breaking it.

From testing, I learned that I can keep hold of the interface until the reset is completed, then when I release it gets handed back to ALSA clean, and pipewire seems to pick it up correctly.

Could you grab the relevant artifact from the bottom of this test build, install it, and test it for me please? Let me know if the behaviour is better.

Thanks!

@wutscher
Copy link
Author

wutscher commented Sep 4, 2023

I've just tried out the patched version, but the behavior stayed the same. I tested it 4 times to make sure but the behavior is consistent.
Steps i took:

  • I disabled autostart for my installed version
  • installed the patched version
  • enabled autostart for the patched version
  • shut down my pc (this does not happen on restart, probably because it stays powered on)
  • started my pc
    I also checked if the correct binary was running, and it was.
    If you need anything else from me, please let me know.

@StephanDaaboul
Copy link

Hello, I am also having the same issue in Debian 12 and I have to manually restart pipewire and open the web app for the devices to get initialized and usable by any audio application. Are there any logs or information I could share to help find the issue?

@FrostyCoolSlug
Copy link
Member

Might be worth looking at the pipewire logs (I'm not entirely sure how to get them), and see if there's a reason it's not reattaching the device, I don't think there's anything more on the util side I can do.

@wutscher
Copy link
Author

wutscher commented Oct 1, 2023

I just checked my pipewire logs using journalctl --user -b -u pipewire and found these entries in the time between boot and me restarting pipewire. They don't mean much to me, but maybe you can see something here

Oct 01 16:48:03 archinator systemd[1174]: Started PipeWire Multimedia Service.
Oct 01 16:48:05 archinator pipewire[1509]: [0:04:42.321662928] [1509] ERROR IPAModule ipa_module.cpp:172 Symbol ipaModuleInfo not found
Oct 01 16:48:05 archinator pipewire[1509]: [0:04:42.321674217] [1509] ERROR IPAModule ipa_module.cpp:292 v4l2-compat.so: IPA module has no valid info
Oct 01 16:48:05 archinator pipewire[1509]: [0:04:42.321700985] [1509]  INFO Camera camera_manager.cpp:284 libcamera v0.1.0
Oct 01 16:48:05 archinator pipewire[1509]: spa.alsa: '_ucm0001.goxlr_stereo_out:GoXLRMini,0,2,3': playback open failed: No such device
Oct 01 16:48:05 archinator pipewire[1509]: ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for GoXLRMini
Oct 01 16:48:05 archinator pipewire[1509]: mod.adapter: 0x55954277c490: can't get format: No such device
Oct 01 16:48:05 archinator pipewire[1509]: mod.adapter: usage: node.name=<string>
Oct 01 16:48:05 archinator pipewire[1509]: ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for GoXLRMini
Oct 01 16:48:05 archinator pipewire[1509]: spa.alsa: '_ucm0001.goxlr_stereo_out:GoXLRMini,0,0,1': playback open failed: No such device
Oct 01 16:48:05 archinator pipewire[1509]: mod.adapter: 0x559542793210: can't get format: No such device
Oct 01 16:48:05 archinator pipewire[1509]: mod.adapter: usage: node.name=<string>
Oct 01 16:48:05 archinator pipewire[1509]: ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for GoXLRMini
Oct 01 16:48:05 archinator pipewire[1509]: spa.alsa: '_ucm0001.goxlr_stereo_in:GoXLRMini,0,4,5': capture open failed: No such device
Oct 01 16:48:05 archinator pipewire[1509]: mod.adapter: 0x559542793210: can't get format: No such device
Oct 01 16:48:05 archinator pipewire[1509]: mod.adapter: usage: node.name=<string>
Oct 01 16:48:05 archinator pipewire[1509]: ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for GoXLRMini
Oct 01 16:48:05 archinator pipewire[1509]: spa.alsa: '_ucm0001.goxlr_stereo_in:GoXLRMini,0,2,3': capture open failed: No such device
Oct 01 16:48:05 archinator pipewire[1509]: mod.adapter: 0x559542793210: can't get format: No such device
Oct 01 16:48:05 archinator pipewire[1509]: mod.adapter: usage: node.name=<string>
Oct 01 16:48:05 archinator pipewire[1509]: ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for GoXLRMini
Oct 01 16:48:05 archinator pipewire[1509]: spa.alsa: '_ucm0001.goxlr_stereo_in:GoXLRMini,0,0,1': capture open failed: No such device
Oct 01 16:48:05 archinator pipewire[1509]: mod.adapter: 0x559542793210: can't get format: No such device
Oct 01 16:48:05 archinator pipewire[1509]: mod.adapter: usage: node.name=<string>

@FrostyCoolSlug
Copy link
Member

Thanks, yeah this seems to indicate what I expected, pipewire isn't handling the disappearance and reappearance of the device properly, by the time it gets to loading the UCM profile, the device is already gone, and it' not retrying when the device reappears.

I'm honestly not entirely sure the best way to solve this, outside of submitting a kernel patch to make the detach unnecessary.

I'll do some testing and see what I can come up with.

Thanks.

@FrostyCoolSlug
Copy link
Member

FrostyCoolSlug commented Oct 22, 2023

I've opened an issue with the ALSA devs Here as to the best way to approach this. I ask that you please don't comment specifically on that issue unless you have some additional information until some feedback has been provided.

The probability is that we're going to need to create a bug report with the Pipewire devs to deal with this scenario correctly, there's no real reason why it shouldn't automatically 'fix' itself when the USB reset happens, and the logs imply it's not correctly dropping then reestablishing the device correctly, but this is a tricky thing to fix.

@FrostyCoolSlug
Copy link
Member

As a separate thing, could I ask that you open an issue on the pipewire bug tracker for this? As hard as I try, I'm unable to reproduce the issue on my install (Pipewire 0.3.83, Kernel 6.5.5-1-MANJARO), the device always comes back without fail for me even when power cycled.

@FrostyCoolSlug
Copy link
Member

One thing which might work as a solution, given that the majority of these problems occur due to the mini being powered on during system boot, I could introduce a systemd service which runs the goxlr-initialiser binary as root prior to the desktop environment being launched. This should get the GoXLR into a 'working' state in advance of pipewire and the utility starting up...

Thinking about this more, it might be possible to handle it directly on device hotplug via udev and systemd, so it doesn't reach the ALSA level until the initialisation stage has been handled..

Is anyone here on this thread happy to help with some testing?

@wutscher
Copy link
Author

I'd be happy to help. Just need some instructions on what to do.

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

No branches or pull requests

3 participants