module-switch-on-port-available: Don't switch profiles on uninitialized cards

This could cause the HDMI port to become the default on some systems
where analog output was available.

BugLink: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1256511
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=73375
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Fix switching between HDMI and headphones automatically

This patch removes the code from module-switch-on-port-available that
ensures that no profile switching will happen when a new port is available
if the previously active one is still available too, which is the case when
you have the computer permanently plugged to a TV through HDMI and then
plug headphones to listen to them.

Additionally, this patch also takes care of switching back to a valid
profile when unplugging that new hardware (e.g. headphones), and it
implements that by looking for the best possible port available in the
same card, even if it's in a different sink.

NOTE: this works on the BRIX because the both the analog and HDMI profiles
live in the same card, otherwise it would still not switch back to HDMI when
the currently active port becomes unavailable (e.g. unplugging the
headphones).