nikp123 / xava

X11 Audio Visualizer for ALSA
http://nikp123.github.io/xava
Other
129 stars 14 forks source link

Xava randomly quits working #26

Closed klandrith closed 3 years ago

klandrith commented 3 years ago

Randomly (usually after quite a while of no audio activity) xava quits working. I have to kill it and restart it in order for it to work properly. If music is going, it will work for hours on end without problem. Here is my setup.

Manjaro KDE (all current) -Plasma 5.19.5 -Qt 5.15.1 -Kernel 5.8.11-1

nikp123 commented 3 years ago

QT version is unrelated, but would you mind telling me what audio backend do you use?

nikp123 commented 3 years ago

It narrows down the bug search by quite a lot.

klandrith commented 3 years ago

PulseAudio. Thanks for the quick reply!

nikp123 commented 3 years ago

For how long do you have to wait in order to find this issue

klandrith commented 3 years ago

I have this is the audio section of my xava config file.

method = pulse source = auto

nikp123 commented 3 years ago

yes, but how long did you wait for the bug to happen?

klandrith commented 3 years ago

Well I mean I'm unsure of that because I never really pay attention. But I would say it happens after an hour or more of no audio activity. I recently setup a KVM Windows 10 virtual machine, and I have been switching back and forth quite a bit between it and my Linux desktop. Usually I notice the bug after I've been on the VM for awhile and switched back over to my main desktop. Audio output never has any problem between switching between the guest and host.

nikp123 commented 3 years ago

What audio setup are you using in your VM?

I think I know what's going on here: PulseAudio sink changes due to the VM and XAVA can't handle that.

nikp123 commented 3 years ago

tl;dr: QEMU likes to mess with PulseAudio

And XAVA ain't too happy about it...

klandrith commented 3 years ago

Makes sense, I was suspecting as much. I'm using PulseAudio for the VM. I wish I could just pass in my whole audio device, but it is non-resettable, so I can't do that. I will have to explore other audio options for the VM. Doesn't seem to be a problem on xava's end then, really.

BTW, Great piece of software. It is absolutely awesome. But, is there any way to improve the graphical performance of xava though? It uses a lot of GPU resources (I only have a Nvidia GT1030 on my host)? I know that question is unrelated...

nikp123 commented 3 years ago

@klandrith It is (to some extent) XAVA's fault, but the behaviour is basically non-standard, if you get what I'm saying ;)

Just I'm not sure if applications can detect a dead source.

Also can you share your QEMU audio params, it could help a lot.

nikp123 commented 3 years ago

Makes sense, I was suspecting as much. I'm using PulseAudio for the VM. I wish I could just pass in my whole audio device, but it is non-resettable, so I can't do that. I will have to explore other audio options for the VM. Doesn't seem to be a problem on xava's end then, really.

BTW, Great piece of software. It is absolutely awesome. But, is there any way to improve the graphical performance of xava though? It uses a lot of GPU resources (I only have a Nvidia GT1030 on my host)? I know that question is unrelated...

Try disabling OpenGL. I've already had like 3 issues, all NVIDIA related. It speaks for itself. You'll lose shadows, unfortunately.

klandrith commented 3 years ago

I gotcha.

This is all that I have in my audio section of my VM libvirt xml file when it comes to sound...

I just added an emulated sound device via the libvirt GUI. I am exploring other configurations right now. I could use scream for audio, but I'm not sure if that would suffer the same fate or not?

I'll try disabling OpenGL. I don't care for the shadows anyways as my desktop background is very dark and I can't see them anyways. lol.

nikp123 commented 3 years ago

Scream works well if you don't pin the CPU, then you get artifacting.

klandrith commented 3 years ago

Bummer, I am pinning my CPU cores...ugh.

klandrith commented 3 years ago

"sound model="ich9" address type="pci" domain="0x0000" bus="0x00" slot="0x1b" function="0x0"/ /sound"

Forgot to quote that...That's all I have in my XML file for audio.

nikp123 commented 3 years ago

Not the device in qemu, but how QEMU plays the audio itself.

To make it easier for you just share the entire thing, if you don't mind.

klandrith commented 3 years ago

`

win10 9a735831-13fd-4cfd-b50f-f86e1d06e368 33554432 33554432 20 hvm /usr/share/edk2-ovmf/x64/OVMF_CODE.fd /var/lib/libvirt/qemu/nvram/win10_VARS.fd destroy restart destroy /usr/bin/qemu-system-x86_64
` For audio on the guest I am using the audio on my 2080ti via displayport to my monitor. I haven't tried to output audio via my audio jacks, so I haven't really bothered on that end. I'm not sure my setup even works on that front. I am new to this KVM stuff, as I just got the VM up and running last week.
klandrith commented 3 years ago

Sorry that's a mess, not sure how to format it to keep the indents and such..

nikp123 commented 3 years ago

yeah, it doesn't reveal much.....

klandrith commented 3 years ago

What part of the qemu xml exactly are you looking for? Sorry for my lack of knowledge about this stuff. As I said, just got it going...My head is still spinning from the 100 or so guides I read last week, lol.

nikp123 commented 3 years ago

don't bother yourself with the details, it's mostly dev jargon anyway

the thing is I just need to be sure what the culprit is

nikp123 commented 3 years ago

For example, I booted up my KVM machine, and it works just fine now

a classical case of: "works on my machine"

klandrith commented 3 years ago

Yah, I gotcha. That was a classic line in my CS programming and algorithms 1 class. lol "ran on my machine..."

nikp123 commented 3 years ago

also can you try the following dumb hack (if it works):

change the starting <domain> tag into <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> before saving, also add:

  <qemu:commandline>
    <qemu:arg value='-audiodev'/>
    <qemu:arg value='pa,id=pa1,server=/run/user/1000/pulse/native'/>
 </qemu:commandline>

BEFORE the final </domain> tag.

nikp123 commented 3 years ago

this is just to replicate my audio setup, to see if there's something about QEMU that messes with it

nikp123 commented 3 years ago

oh wait nevermind you don't have to change the tag, it's already done for you

nikp123 commented 3 years ago

but just add the second part

klandrith commented 3 years ago

Yah, I gotcha. I tried that and I get an error in libvirt that it was unabled to connect to pulseaudio.

Error starting domain: internal error: qemu unexpectedly closed the monitor: pulseaudio: pa_context_connect() failed pulseaudio: Reason: Connection refused pulseaudio: Failed to initialize PA contextaudio: Could not init `pa' audio driver

klandrith commented 3 years ago

Nevermind, figured it out, need to change my user in qemu config file. I was(am) running a diff user to access my keyboard via evdev.

nikp123 commented 3 years ago

boom, you just found the problem by yourself.

That means that pulseaudio runs as root (or whatever different user) then, and xava gets rejected access to audio (for obvious reasons)

nikp123 commented 3 years ago

should error out then, should it?

nikp123 commented 3 years ago

:thonk:

nikp123 commented 3 years ago

But there's a workaround for this, it's just not device agnostic... (developer speak for it doesn't work when you plug in an another device) Use alsa instead. It's complicated to set up, but it avoids problems like these.

klandrith commented 3 years ago

Yah, I think we got it nailed down. Thanks for all the help! Now I'm just trying to get hda to work in libvirt. Libvirt is complaining that it can't find 'hda'.

Use alsa for xava?

nikp123 commented 3 years ago

Yes, but if you really sure about using it. It's difficult to set up.

nikp123 commented 3 years ago

Or instead, you can write a udev file that grants access to your keyboard using a certain group instead of a user.

klandrith commented 3 years ago

I got it working now. Everything is going fine. Just started up the VM, switched monitor inputs to VM, audio cutoff, switched back, audio resumed and xava was still working. So it seems to be resolved. Thanks again for all the help, even though this didn't turn out to be an issue with xava!

klandrith commented 3 years ago

If I still have an issue with xava cutting out again, I'll post back to this issue thread, but I think we've got it all figured out.

nikp123 commented 3 years ago

Yeah, I'm glad there are people testing out my code. Gives me motivation to work on the project.

Thanks for you input and happy visualizing (don't worry, you can always reopen this issue later on)

nikp123 commented 3 years ago

99-qemu-hw-users.rules.zip also here's that example udev file in case you need it @klandrith