Volume Frustration Running Multiple Instnaces of VLC on Ubuntu 23.04

*nix specific usage questions
frejos
New Cone
New Cone
Posts: 2
Joined: 21 Oct 2023 05:24

Volume Frustration Running Multiple Instnaces of VLC on Ubuntu 23.04

Postby frejos » 21 Oct 2023 06:43

Hello,

I'm trying to work around this behavior in Ubuntu 23.04. When running multiple instances of VLC each playing different content, the volume level (including mute state) resets to the last set volume/mute state from any running instance of VLC when ever the media advances to the next item in the playlist, or restarts if on a loop, (or newly started instances of VLC but this is okay).

I did have a work around that worked the way I wanted, but it relied on PulseAudio. Now that Ubuntu has changed to PipeWire it no longer works and I haven't been able to find any other workaround. I'm wondering if someone might be able to help or point me in the right direction.

Steps to Replicate
  1. Start VLC playing any content (Set to loop continuous)
  2. Start a second instance of VLC playing any content (Set to loop continuous)
  3. Change the volume of (or mute) the second instance
  4. Advance the first instance by clicking next track
  5. Observe the volume of the first instance is now the same as the second instance
Desired Behavior
Each instance of VLC should be able to control its own volume, advancing to the next item in the playlist or loop should maintain the volume set within this instance. Changing the volume in one instance should have no impact on the current or future state of the other instances.

PulseAudio Work Around
I found that PulseAudio was using the Application Name as the key to save and restore the volume settings. There was also an environment variable that by setting overwrites the Application Name used by PulseAudio, I did this before starting each instance using a unique value for each. This prevented each instance from affecting the others.

PULSE_PROP=[application.name=vlc_726263]

Help
I'm wondering if there is some configuration option I haven't been able to find yet or some other way to force VLC to isolate each instance or to ignore the system restore value, or some way to overwrite an instance of VLC to have a different namespace (App Name) than the others, or some configuration option for PipeWire that forces the behavior.

I did find a similar thread, however there was no solution. Thanks in advance for any assistance you might be able to give me.

Versions
VLC media player 3.0.18 Vetinari (revision 3.0.13-8-g41878ff4f2)
VLC version 3.0.18 Vetinari (3.0.13-8-g41878ff4f2)
Compiled by Ubuntu buildd for lunar on Ubuntu amd64 buildd (Jan 4 2023 16:50:08)
Compiler: gcc version 12.2.0 (Ubuntu 12.2.0-12ubuntu1)

Distributor ID: Ubuntu
Description: Ubuntu 23.04
Release: 23.04
Codename: lunar

Rémi Denis-Courmont
Developer
Developer
Posts: 15272
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Volume Frustration Running Multiple Instnaces of VLC on Ubuntu 23.04

Postby Rémi Denis-Courmont » 21 Oct 2023 08:41

VLC is using the PulseAudio interface fro audio output and audio session either way. To solve this, you need to configure or change your Pipewire session manager, e.g. WirePlumber. TBH, I doubt that anybody here can help much as this is really not a VLC question.

Or you can reinstall PulseAudio.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

frejos
New Cone
New Cone
Posts: 2
Joined: 21 Oct 2023 05:24

Re: Volume Frustration Running Multiple Instnaces of VLC on Ubuntu 23.04

Postby frejos » 22 Oct 2023 04:39

Thanks for the reply. I focused my efforts on WirePlumber as you suggested. I did manage to find the configuration and dig through it enough to put a hack in place that appears to be functioning as I want.

In case anyone else runs across this issue, here is a brief summary of how I hacked it.

Under Ubuntu 23.04 the WirePlumber effective configuration is stored under /usr/share/wireplumber
The stream restore settings are configured in /usr/share/wireplumber/main.lua.d/40-stream-defaults.lua which next layer down calls /usr/share/wireplumber/scripts/restore-stream.lua to do the actual saving and restoring of the state values, it is in this file that I changed the behavior. There is a findSuitableKey function that determines the key to use to save the state, it looks for the defined properties in the order they are specified stopping at the first one found. I added application.process.id as the first item in the list.

Code: Select all

function findSuitableKey(properties) local keys = { "application.process.id", "media.role", "application.id", "application.name", "media.name", "node.name", } ...
After rebooting, the volume state is restored within the VLC process (instance) but not shared between them.

Interestingly, changing the value of the restore-props property to false in /usr/share/wireplumber/main.lua.d/40-stream-defaults.lua causes VLC to restore the volume state to default on each media advancement (not even saving it within its own instance), which lead me down to the next level and configuring the state to be saved based on the PID.

The state is stored in a file ~/.local/state/wireplumber/restore-stream it is possible to verify that each process instance is stored separately after the change.

It should be possible to confine this approach only to VLC by checking the application.name property in the script and only applying this logic in that case, I will work on that approach if the above approach becomes disruptive.

Thanks for pointing me in the right direction.


Return to “VLC media player for Linux and friends Troubleshooting”

Who is online

Users browsing this forum: No registered users and 34 guests