Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Reset stream-restore database on stream switching #42

Closed
Districtfine opened this issue Dec 20, 2016 · 7 comments
Closed

Reset stream-restore database on stream switching #42

Districtfine opened this issue Dec 20, 2016 · 7 comments

Comments

@Districtfine
Copy link

For example, if I have my default device set as my speaker then I change the default device to headphones, all sounds currently playing will switch to headphones. But if I launch a program, its audio will play from the speakers, until I open the sound switcher and select headphones for a second time.

@crazymaster
Copy link
Contributor

I can reproduce it. Is there anything I can do to help?

@yktoo
Copy link
Owner

yktoo commented Sep 8, 2017

Okay I can confirm this one. However that's the way the PulseAudio daemon maps streams, and this indicator is not affecting that.

At the same time, the standard Sound Panel in Gnome Control Center does switch the default sink/source in such a way that any stream appearing after that is mapped to the default.

I'll investigate how the Sound Panel handles it once I've got enough time.

@deadmd
Copy link

deadmd commented Mar 23, 2019

I use 2.2.0 in Linux Mint 19.1. Problem is actual.

@breunigs
Copy link

breunigs commented Jun 2, 2019

This happens for me when restore_device is true, which is the default. Disabling it makes re-appearing streams go to the newly selected output:

# /etc/pulse/default.pa
load-module module-stream-restore restore_device=false

The line already exists, so you just need to add restore_device=false.

@breunigs
Copy link

breunigs commented Jun 2, 2019

The docs actually explain how the gnome sound switcher works – it simply edits the database for all streams to the newly selected device: https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/DefaultDevice/

I took a look my file (tdbdump ~/.config/pulse/*stream-volumes.tdb) and it seems this is the format:
https://sources.debian.org/src/pulseaudio/12.2-4/src/modules/module-stream-restore.c/?hl=2474#L998-L1008 with these prefixes:
https://github.com/pulseaudio/pulseaudio/blob/master/src/pulsecore/tagstruct.h#L41-L61
However, I can't quite match my local entries to how I believe the code reads them, so I must've a misunderstanding somewhere.

@yktoo
Copy link
Owner

yktoo commented Jun 15, 2019

Thanks @breunigs, it looks indeed that it "works as designed":

Whenever a new stream appears, PulseAudio's stream-restore module checks if the same stream has been seen before, and if it is, then the stream is connected to the same sink or source that was used previously. There is a concept of a "fallback" device, which is used if the stream has not been seen before.

For those who happen to dislike the way PulseAudio works, the same page lists four possible solutions:

  1. use Gnome Volume Control,
  2. use pavucontrol,
  3. delete the file containing stream-volumes in its name in the ~/.pulse directory and restart PulseAudio, or
  4. set restore_device=false like in the comment above.

If I have time, I'll try to mimic Gnome's behaviour (not sure what "modifying the stream-restore database" entails exactly).

@yktoo yktoo changed the title Inactive sources do not get switched Reset stream-restore database on stream switching Jun 15, 2019
@yktoo
Copy link
Owner

yktoo commented May 13, 2022

Considering the alternatives (especially the persistent fix of editing PA config, item 4 above), this item is closed.

@yktoo yktoo closed this as completed May 13, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

5 participants