Inconsistent Sound Volume Ubuntu 20.04

I upgraded from 18 to Ubuntu 20.04 a few days ago. I listen to music through Google Play Music's website which I load in Firefox. I noticed that now Ubuntu has app specific volumes (cool). Since I stream shows and movies through Firefox I decided to crank the Firefox volume to the max and then fine-tune the volume on the website and with the system's master volume. The problem is that the sound for Firefox keeps resetting. In fact, it seems to reset with every Google Play song. I go from being able to hear my music to hearing silence. Why does this happen and can it be stopped?

Volume Levels

For the moment, I'm leaving the Firefox volume to where it defaults and increasing the volume on the website.


Solution 1:

Try adding or changing flat-volumes=no setting in pulseaudio's daemon.conf:

The "daemon.conf" can be found in the following paths:

User definitions:

~/.config/pulse/daemon.conf

~/.config/pulse/daemon.conf.d/*.conf

System definitions:

/etc/pulse/daemon.conf

/etc/pulse/daemon.conf.d/*.conf

About flat-volumes:

pulse-daemon.conf(5)

flat-volumes Enable 'flat' volumes, i.e. where possible let the sink volume equal the maximum of the volumes of the inputs connected to it. Takes a boolean argument, defaults to yes.

Pulseaudio Arch Wiki

flat-volumes scales the device-volume with the volume of the "loudest" application. For example, raising the VoIP call volume will raise the hardware volume and adjust the music-player volume so it stays where it was, without having to lower the volume of the music-player manually. Defaults to yes upstream, but to no within Arch. Note: The default behavior upstream can sometimes be confusing and some applications, unaware of this feature, can set their volume to 100% at startup, potentially blowing your speakers or your ears. This is why Arch defaults to the classic (ALSA) behavior by setting this to no.

Solution 2:

I would like just elaborate more on what's written in the accepted answer.

Before I have changed anything, this was the behavior I have observed:

When I watch an mp4 video in Firefox, let it be embedded in a webpage, or opened from the disk via file:// protocol, and I use this video's HTML5 video controls to lower the volume, then I get something similar what you have on your screenshot: the Firefox tab's volume slider will "follow" what I did on the mp4 video's volume control. And then sometimes I get freshly opened tabs with the volume a little bit tuned down by default, or even, sometimes, muted completely.

Overall this can get a little frustrating sometimes, so I was eager to try out the new info.

In /etc/pulse/daemon.conf I have found the following line, as is:

; flat-volumes = no

Looks like it's commented out. So first, I uncommented it:

flat-volumes = no

Trying out Firefox, I did not seem to notice any difference to the previous behaviour.

Then I changed to:

flat-volumes = yes

After a reboot, there was a difference indeed, but an unwelcome one.

In this case the application's volume level gets tied to the master system volume level.

If the master volume is set to half, then in the gnome-control-center's Sound settings, the Firefox tab's volume will be displayed accordingly, also at half. In the sound settings, as long as I move the Firefox slider to softer than the master, the volume levels can be de-coupled; but if I move the Firefox tab's volume louder, as soon as it reaches the level the master is on, it starts to pull the master volume level with it. So when the Firefox slider reaches 100%, master will also.

(All this time the mp4 video's HTML5 volume control in the Firefox tab might stay at 100%. In other words, the mp4 vid's volume control now seems decoupled from the Firefox tab's, in the sound settings. In a way, I believe, this is what people are after; they are just unaware of the tradeoff.)

Now in a new experiment, I opened a video in Totem (the app now called Videos), and found that Totem's built-in volume slider was about two-thirds. So I pushed it up to 100%, and it took the master system volume level to 100% with it: in other words, I controlled the master system volume level from within the Totem UI (while I could have been unaware of it). Extremely bad idea; any other app emitting a sound at this point, could rip the speakers out (and your eardrums in).

So, I think, if you like your speakers and your eardrums, consider avoiding flat-volumes = yes.