switch-on-port-available: Fix switching away from unplugged headphones

Merged Tanu Kaskinen requested to merge tanuk/pulseaudio:fix-switching-to-speakers into master

Commit 323195e3 ("switch-on-port-available: Switch to headphones on unknown availability") broke switching from headphones to speakers when headphones are unplugged. switch_from_port() selects speakers, whose availability is unknown and availability group is unset, and then calls switch_to_port(). The new logic in switch_on_port() unintentionally blocked that switch.

This patch moves the problematic logic from switch_to_port() to port_available_hook_callback() where it doesn't interfere with switch_from_port().

Fixes: #1043 (closed)

Merge request reports