Skip to content

media-session: switch to the route when availability changed

When a user plugs in headphones, they expect to hear an audio through them. Currently, that usecase might or might not work with pipewire depending on the user's luck, because pipewire instead uses port priorities, and those apparently rarely have sane default values.

PulseAudio ignored priorities here, instead it made use of the port right away. This should better match user expectations (who plugged-in headphones and is expecting to hear sound), so let's do the same in pipewire.

Fixes: #1170 (closed)


The discussion on this change was here.

This is WIP because I've got two one questions here, and there's one TODO for INPUT vs OUTPUT which I'd like to resolve once questions are. I am completely new to Pipewire in particular and to audio terminology in general, so I figured it would be more efficient to just ask the questions.

  1. I've got an issue: while the change here works, as in, I see the headphones correctly chosen after plugged-in; however I am seeing a side-effect (or rather, not seeing the expected side-effect) which is that, after the headphones are chosen there's no sound from them. I'm probably missing something obvious here, any thoughts?
  2. The code in PulseAudio I'm trying to imitate is this one. It mentions some "availability group", and there's a large comment mentioning it needs to be checked… I assumed, this "group" is something PA-specific, but I'd like to make sure: is this "availability group" something we need to worry about in PW?

TODO:

  • no sound through headphones
  • (optional) are we interested in "availability groups" from PA, is it relevant for PW?
  • (optional) for INPUT, only switch (quoting the PA comment) "input ports without source and the input ports their source->active_port is part of a group of ports"
Edited by Konstantin Kharlamov

Merge request reports