switch-on-port-available: Switch from HDMI to analog; but not the other way around

If you have headphones plugged in and plug in HDMI; you want sound
to stay on headphones.
If you have HDMI plugged in and you plug in headphones; you want sound
to switch to headphones.

Hence we need to take priority into account as well when determining
whether to switch to a new profile or not.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=93903
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
David Henningsson 2016-01-29 20:33:22 +01:00
parent fa2b0b4aad
commit f6e1ac2dd2

View file

@ -29,7 +29,7 @@
#include "module-switch-on-port-available-symdef.h"
static bool profile_good_for_output(pa_card_profile *profile) {
static bool profile_good_for_output(pa_card_profile *profile, unsigned prio) {
pa_sink *sink;
uint32_t idx;
@ -49,7 +49,7 @@ static bool profile_good_for_output(pa_card_profile *profile) {
if (!sink->active_port)
continue;
if (sink->active_port->available != PA_AVAILABLE_NO)
if ((sink->active_port->available != PA_AVAILABLE_NO) && (sink->active_port->priority >= prio))
return false;
}
@ -88,7 +88,7 @@ static int try_to_switch_profile(pa_device_port *port) {
switch (port->direction) {
case PA_DIRECTION_OUTPUT:
name = profile->output_name;
good = profile_good_for_output(profile);
good = profile_good_for_output(profile, port->priority);
break;
case PA_DIRECTION_INPUT: