wwmm / easyeffects

Limiter, compressor, convolver, equalizer and auto volume and many other plugins for PipeWire applications
GNU General Public License v3.0
6.42k stars 268 forks source link

Volume Control Behaviour #99

Closed hackel closed 6 years ago

hackel commented 6 years ago

One thing I've noticed with PulseEffects 3+ under Ubuntu 17.10 (Gnome Shell) is that, when I activate PE, it changes which output device my system volume control (hotkeys or the volume slider in the gnome-shell menu) responds to. Normally, it controls the "Built-in Audio Analogue Stereo" hardware device. When I enable PE, the volume control switches over to the "PulseEffects(apps)" virtual device, which is set at 100%. Changing this volume causes a very noticeable static sound each time, and there's no way to turn the volume up above 100%. In pavucontrol, I can see that "PulseEffects(apps)" is set as the "fallback" device. If I change this back to "Built-in Audio Analogue Stereo", then audio continues playing through PE, but my volume controls the hardware device as expected.

tanuk commented 6 years ago

This is a bug in PulseAudio, in module-device-manager. The reason why this doesn't happen on non-KDE systems is that module-device-manager is only loaded when using KDE (see /usr/bin/start-pulseaudio-x11).

When an application requests a specific device when creating a stream, module-device-manager will let the application use that device initially, but it doesn't remember that the stream had "special" routing that shouldn't be changed. There are many situations where module-device-manager will check the stream routing and move streams if their routing doesn't match what module-device-manager thinks the routing should be.

An extra bit of information should be added to the internal stream state: "this stream is routed according to the application's request". When that bit is set, module-device-manager should refrain from moving the stream. If the stream is moved for any reason (e.g. requested by user), then that bit should be cleared, since the initial routing isn't relevant any more.

barjac commented 6 years ago

I can confirm that with the relevant line removed from /usr/bin/start-pulseaudio-x11 it is now behaving the same in plasma5 as in Mate. Running as a service does fix the Stop/Start problem also.

barjac commented 6 years ago

@tanuk Is there an existing PA bug report for this? What is the next step to resolving this issue? I wonder why only KDE/Plasma feel it necessary to use module-device-manager?

tanuk commented 6 years ago

I submitted patches for fixing the PulseAudio bug: https://patchwork.freedesktop.org/series/34558/

I haven't tested the patches, can you do that?

The reason why KDE uses module-device-manager is that its UI for configuring audio device priorities depends on that module.

tanuk commented 6 years ago

I forgot that I should have rebased the patches on the 11.1 release. Here are the patches rebased: https://cgit.freedesktop.org/~tanuk/pulseaudio/log/?h=device-manager-fix

I'll also send the patches to @barjac like I did with the logging patch.

barjac commented 6 years ago

Brilliant, stupendous, fantastic! I rebuilt pulseaudio package with your new patches and also the extra_debugging (in case it was required). I removed the change I made to /usr/bin/start-pulseaudio-x11, updated the package on my system running plasma5 and it's all working perfectly - much kudos to you :) I also tested in Mate and see no regressions. I ran several audio generating apps simultaneously and all seems just perfect. @wwmm I checked that stopping and starting applications worked correctly, and it does when running in daemon mode with the GUI closed as you suggested. Happy day!

wwmm commented 6 years ago

Ok. I think that tanuk patches to module-device-manager and Georg patches to module-switch-on-connect fix the problems discussed in this issue. I will close it. Thank you for your help tanuk :-)

mikhailnov commented 6 years ago

What is the status of upstream changes in PulseAudio to properly handle the problem with virtual sinks and module-switch-on-connect?

wwmm commented 6 years ago

Pulseaudio git repository has the fixes for the modules module-switch-on-connect and module-device-manager:

https://github.com/pulseaudio/pulseaudio/commit/e083357b88c6360edc3d8fe8bb1109c7f190709a https://github.com/pulseaudio/pulseaudio/commit/d6a0dcc3a2a9e73a7664be9ad62d7fffd1f926de https://github.com/pulseaudio/pulseaudio/commit/3d698d17afa9a3b36defeb99def14c25c9031c2f

I imagine that the next Pulseaudio version will have them

mikhailnov commented 6 years ago

Thanks for the information.

mikhailnov commented 6 years ago

I confirm it's fixed in PulseAudio 12.0

If you want to try PulseAudio 12.0 instead of Ubuntu's 11.1, use ppa:mikhailnov/desktop1-dev

sudo add-apt-repository ppa:mikhailnov/desktop1-dev
sudo apt dist-upgrade

In this testing PPA: