As PulseAudio (amazingly) doesn't provide any simple query commands, I'm parsing the output from pacmd list-sinks to get the index of the active sink. However, I'm not sure what lines actually indicate which sink is active. I know that the index line has an asterisk in front of it if it's the default sink. That doesn't appear to be the same as the active sink, though. When I connect a bluetooth speaker, that's what all audio goes through, nevertheless, sink 0 is still marked as default. When audio is playing, the sink that is outputting it displays 'state: RUNNING'. But once playback stops, that goes back to SUSPENDED.

Is there any reliable way to find out what sink PulseAudio will use for audio?

  • Have you previously configured the bluetooth speaker as the sink for certain applications, using a tool such as pavucontrol? PulseAudio uses a module called stream-restore to "remember" some source-sink mappings, and this information isn't included in the output of pacmd list-sinks or ... dump. – JigglyNaga Oct 21 '19 at 12:16
  • There's nothing that keeps multiple application from streaming to multiple sinks at the same time. So how do you define "the" active sink? You can use the associated .monitor sources of each sink to find the current level, just like pavucontrol, if that's what you want. – dirkt Oct 21 '19 at 13:11
  • Thanks for the help! @dirkt I guess in that case my question would be how can I find out what sink or sinks PulseAudio is streaming to or will be streaming to once I start playback. However, I managed to find the solution for now by using list-sources instead of list-sinks. – InspectorMustache Oct 22 '19 at 8:53

It seems I need to gain a greater understanding of the PulseAudio nomenclature. Listing sources marks the bluetooth speaker correctly as default. And since sources and sinks apparently share the same index, I can pass the index number extracted from pacmd list-sources to pactl set-sink-volume to change volume. Because pactl set-source-volume does nothing. I can't really make sense of it but it does work.

  • Not sure if I understand you correctly, but: "Sources" are audio sources you can record from, "sinks" are audio sinks you can play sound to. I wouldn't be surprised if Bluetooth always has a source, even if you only have connected speakers, if the underlying protocol works this way. The "default" marking just means that when you start a new application without stream-restore info, the application will use this source (for recording) or sink (for playing) by default, unless it decides otherwise. So what you are doing seems to work by accident, but very likely isn't correct. – dirkt Oct 22 '19 at 9:44
  • Yeah, you are, of course, right. Guess, I really need to gain a greater understanding of the PulseAudio nomenclature. As it turned out, I had created a sink mapping or something similar earlier that I was unaware of. After clearing ~/.config/pulse, the Bluetooth speaker is correctly marked as default after connecting. So actually @JigglyNaga's initial comment was already pointing me in the right direction. Thank you both once more for your help. – InspectorMustache Oct 23 '19 at 11:12
  • To repeat: I advise very strongly against drawing any conclusion about current use of sinks from the information which sink is "default". You keep saying "the Bluetooth speaker is correctly marked as the default sink". Thinking about it this way is a mistake. There is no "correct" or "incorrect" marking of the default sink - it's just the sink that gets used by default for a new application that doesn't have information about sinks preferred in the past. – dirkt Oct 24 '19 at 8:02

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.