I have a mini-HP PC with Kubuntu 18.04 installed, It has some crappy built-in speakers and HDMI ports. I want all my audio to always go through the active HDMI port, but for some reason, with some applications, PulseAudio ALWAYS wants to put the audio through the built-in speakers.

Index 0 is the default:

$ pacmd list-sinks | grep -e 'name:' -e 'index:'
  * index: 0
        name: <alsa_output.pci-0000_0a_00.1.hdmi-stereo-extra1>
    index: 1
        name: <alsa_output.pci-0000_0a_00.6.analog-stereo>

But when I run certain applications:

$ pactl list short sinks
0       alsa_output.pci-0000_0a_00.1.hdmi-stereo-extra1 module-alsa-card.c      s16le 2ch 48000Hz       SUSPENDED
1       alsa_output.pci-0000_0a_00.6.analog-stereo      module-alsa-card.c      s16le 2ch 44100Hz       RUNNING

And I can't change it!

$ pacmd list-sink-inputs | grep available -A 1
1 sink input(s) available.
    index: 7
$ pacmd move-sink-input 7 0
Moved failed.
$ pactl move-sink-input 7 0
Failure: Invalid argument

How can I get more information about the failure? Neither of these error messages provide any useful information.


Partial answer:

Pulseaudio keeps a database for all applications which sink they were connected to, and on startup restores this connection instead of using the default sink. The default sink is only used for "new" applications.

I don't know why your move-sink-input failed. Can you move it with pavucontrol?


Looking at the github repository of MonoGame finds OpenAL code. Googling for "OpenAL pulseaudio" shows that the defaults for OpenAL forbid moving of sinks, but creating a ~/.alsoftrc file with contents


allow-moves = true

allows that. I haven't tested it myself.


As for restoring the remembered sink on startup, the .alsoftrc list of options doesn't showing anything applicable.

On the Pulseaudio side, module-stream-restore handles restoring of stream sources/sinks. It saves these in a GDBM database file, so you could look at this database with GDBM tools. AFAIK the application name given to Pulseaudio is used (but better double check), but there's also a complicated system with roles which I don't quite understand.

So one would need to debug the interaction of this with OpenAL: Possibly OpenAL doesn't specify an application name; possibly OpenAL overrides what module-stream-restore does and just picks the default sink, possibly something else. Looking at the OpenAL source code should help.

The workaround of course is to write a small wrapper script which starts the OpenAL application, and then does the move-sink. Might be faster to do.

  • No, pavucontrol also fails to move the sink. – Erik Jun 15 '19 at 5:37
  • Curious. Can you give details which applications behave like this? Enough details I can reproduce it on my system? – dirkt Jun 15 '19 at 8:12
  • They're both games that I've written using MonoGame. One of them is Thornbridge Saga: wizard.vermiliontower.com/devel/thornbridge_saga – Erik Jun 15 '19 at 15:23
  • So guess: Something in the audio code of MonoGame or the .NET libraries is preventing Pulseaudio from moving the sinks. – dirkt Jun 15 '19 at 16:14
  • Hmm I'll give that a shot on Monday and see how it works – Erik Jun 16 '19 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.