Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Pulseaudio randomly changes output device and volume

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
kerryhall
Posts: 275
Joined: 2008-08-19 11:06
Has thanked: 3 times

Pulseaudio randomly changes output device and volume

#1 Post by kerryhall »

I have two output devices: my bluetooth headset and my computer speakers.

The bluetooth buttons on the headset function, thanks to playerctl.

Sometimes I will pause playback, and then resume, using the buttons on the bluetooth headset. I simply press the play/pause button on the headset once to pause, wait a few minutes, then press the play/pause button on the headset again to resume playback.

When I resume playback, the output device, seemingly randomly, will select my computer speakers instead of the bluetooth headset.

An additional problem, sometimes, seemingly randomly, the volume for that playback will be set to zero.

How does something like this happen? If possible, I would like pulseaudio to: change no settings unless I use the GUI to change them! Seems like an odd thing to have to specify...I know of no other programs that decide to randomize their own settings.

klt
Posts: 13
Joined: 2022-08-29 10:59
Has thanked: 1 time

Re: Pulseaudio randomly changes output device and volume

#2 Post by klt »

Hi,
Pulseaudio has some modules, that can move streams between sinks, or can change volume.
Can please show your /etc/pulse/default.pa?

kerryhall
Posts: 275
Joined: 2008-08-19 11:06
Has thanked: 3 times

Re: Pulseaudio randomly changes output device and volume

#3 Post by kerryhall »

Code: Select all

#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)

.fail

### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties

### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available

### Load audio drivers statically
### (it's probably better to not load these drivers manually, but instead
### use module-udev-detect -- see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif

### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif

### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif

### Load several protocols
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix

### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#load-module module-native-protocol-tcp
#load-module module-zeroconf-publish

### Load the RTP receiver module (also configured via paprefs, see above)
#load-module module-rtp-recv

### Load the RTP sender module (also configured via paprefs, see above)
#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties="device.description='RTP Multicast Sink'"
#load-module module-rtp-send source=rtp.monitor

### Load additional modules from GSettings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists module-gsettings.so
.nofail
load-module module-gsettings
.fail
.endif


### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
load-module module-rescue-streams

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

### Honour intended role device property
load-module module-intended-roles

### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle

### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif

### Enable positioned event sounds
load-module module-position-event-sounds

### Cork music/video streams when a phone stream is active
load-module module-role-cork

### Modules to allow autoloading of filters (such as echo cancellation)
### on demand. module-filter-heuristics tries to determine what filters
### make sense, and module-filter-apply does the heavy-lifting of
### loading modules and rerouting streams.
load-module module-filter-heuristics
load-module module-filter-apply

### Make some devices default
#set-default-sink alsa_output.pci-0000_00_1b.0.analog-surround-51
#set-default-source input

kerryhall
Posts: 275
Joined: 2008-08-19 11:06
Has thanked: 3 times

Re: Pulseaudio randomly changes output device and volume

#4 Post by kerryhall »

Any ideas on this? When a new stream starts, I want it to be at 0dB.

Maybe once in 100 times I will change this manually, but if I do, I don't want me changing that one stream to affect the volume of any other stream, or of future streams, which is what currently seems to be happening.

klt
Posts: 13
Joined: 2022-08-29 10:59
Has thanked: 1 time

Re: Pulseaudio randomly changes output device and volume

#5 Post by klt »

Sorry, I forgot about this.
Try to comment the
load-module module-role-cork
line.
That module changes volume of stream tagged as media, when it detets something sounding tagged as "phone", like zoom, skype...
I'm not sure it's the cause of your problem, but my first try would be to get rid of that module.
Hope for the best...

kerryhall
Posts: 275
Joined: 2008-08-19 11:06
Has thanked: 3 times

Re: Pulseaudio randomly changes output device and volume

#6 Post by kerryhall »

No apology needed of course, just still trying to chip away at the multitude of problems here haha.

Thank you! I will try that and see :)

I also commented out "module-switch-on-port-available", as that is something that seems like it could change profiles / volume levels / other parameters which I do not want.

Trying to sum up my pulseaudio problems here. Every item listed is currently broken:
  • I never want any pulseaudio dropdown box or slider to change on its own.
  • I want my bluetooth headset to connect as A2DP 100% of the time.
  • Once every few months, I will select HSP/HFP manually for my bluetooth headset. When I'm done, I change it back to A2DP. I never want this to change on its own.
  • I want all audio streams to be set to 0 db. I never want these to change on their own. Once every few months, I will tweak a stream volume. I want that change to affect that stream and that stream only.
  • I would expect profile dropdown boxes to behave like any other application. Every now and then (seems like every few months or so) the dropdowns will close themselves while trying to select an item. (will try and record a video of this happening)
  • I would expect audio profiles to match what they now are manually set as in .ifexists/set-card-profile blocks at the end of /etc/pulse/default.pa. Nothing should change this! But when debugging the bluetooth profile issue, somehow the other audio profiles get randomized. (descriptive names are used, not indexes, as recommended)
Anyway, no worries :D just trying to debug and document what I can in case other people run into these issues.

User avatar
sunrat
Administrator
Administrator
Posts: 6412
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 462 times

Re: Pulseaudio randomly changes output device and volume

#7 Post by sunrat »

Taming PulseAudio is like herding cats sometimes. It mostly works OK for me but I keep switching HDMI profile to Off but it comes on again. No biggy, it doesn't overtake default output, but tricksy.
Another forum I watch has a dev who insists that any sound server on top of ALSA is a kludge and ALSA should have been sufficiently developed to do all audio functions. I agree with him. However he also says ALSA is so complex and poorly documented that it would be almost impossible.
Now we have PA, JACK, and ALSA which is what I use successfully, but now Pipewire wants to usurp the status quo and bring a whole new raft of problems. I have tried PW but it's not ready for primetime IMO.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

kerryhall
Posts: 275
Joined: 2008-08-19 11:06
Has thanked: 3 times

Re: Pulseaudio randomly changes output device and volume

#8 Post by kerryhall »

My early experiences with pulseaudio admittedly rubbed me a bit the wrong way (Ubuntu in 2008 I think it was). Over the years it has mostly worked well for me.

I don't really know anything about JACK or Pipewire, I'm certainly open to trying them.

I figure since PA has had so much development over the past 14 years, I might as well try and figure out and document what is needed to solve these last few bugs and get it working "perfectly". Especially if other users are having similar problems.

I'm a little bit baffled that there is no way to easily mark "default profile" in the ui, as I would have put that very early in the list of features (hand in hand with the concept of profiles in general).

Also, I get the idea of pacmd, ok it's cool to have a way to adjust the pulseaudio parameters on the command line, but my gods, shouldn't there be some way, some sort of checkbox, to easily say "don't change anything unless a human being manually adjusts some slider" ? :lol:

In any case, I hope I don't sound like I'm complaining, I just want to document the issues, solve them, and give everyone a better user experience :D

klt
Posts: 13
Joined: 2022-08-29 10:59
Has thanked: 1 time

Re: Pulseaudio randomly changes output device and volume

#9 Post by klt »

I have no real problem with Pulseadio, I succesfully use it, mostly with defaults, just thinkered with the configurations here&there.
Now I see, we have 2 topics with problems possibly both stem from a bluetooth thing?
Maybe we could get closer to what's the real cause of problems?
Edit /etc/pulse/dameon.conf amd set loglevel to debug.
Then look at syslog, maybe with tail -f, and whatch it, while you use your headset.
When the bad behavior occurs, which you don't like, take the log here from that time, or better from a second before maybe.
I found another mention of bluetooth policy:
Disable auto switching headset to HSP/HFP
When using a bluetooth headset that supports multiple profiles, some applications switch to HSP/HFP profile automatically. If this behaviour is undesired you can disable this by appending the auto_switch=false parameter to the bluetooth-policy module:

/etc/pulse/default.pa
load-module module-bluetooth-policy auto_switch=false
Anther thing came to my mind, wether you have some config in your ~/.config/pulse which may interfere with our experiments in /etc/pulse/default.pa?

gwhiz
Posts: 6
Joined: 2022-10-08 23:54

Re: Pulseaudio randomly changes output device and volume

#10 Post by gwhiz »

Yes, bluetooth may be the culprit. For example if you walk away from the computer and get out of coverage, that may signal to PA that it should switch to a different output.

kerryhall
Posts: 275
Joined: 2008-08-19 11:06
Has thanked: 3 times

Re: Pulseaudio randomly changes output device and volume

#11 Post by kerryhall »

No issues with connection. The headset is one foot away from the computer, it never disconnects. What will happen is I will pause playback, and if I wait too long, say five minutes, when I resume playback, the volume is turned all the way and the wrong output device is selected.

Let's start with the first issue: the volume sliders change randomly. (happens with or without bluetooth)

I will change log level to debug and see if I can find anything.

kerryhall
Posts: 275
Joined: 2008-08-19 11:06
Has thanked: 3 times

Re: Pulseaudio randomly changes output device and volume

#12 Post by kerryhall »

Ok here's something interesting.

I connect my bluetooth headset. It shows up in pulseaudio. I change an audio stream from the motherboard soundcard to the bluetooth headset. The volume of the motherboard soundcard for this stream was at 100%. I change it to bluetooth, it's now at 110%. I bring the slider down to 100%. I switch back to the motherboard soundcard. Volume slider is now at 91%. I bring it back up to 100%. I switch back to the bluetooth headset again. It's back to 110%.

How is this possible? This is crazy.

Nothing in syslog.

klt
Posts: 13
Joined: 2022-08-29 10:59
Has thanked: 1 time

Re: Pulseaudio randomly changes output device and volume

#13 Post by klt »

Can you look at /etc/pulse/daemon.conf?
And see, if you have "flat-volumes" enabled?
If it is enabled, or commented, change it to:
flat-volumes = no

If it was disabled, I'm out of ideas again...

Post Reply