diff options
author | Tanu Kaskinen <tanuk@iki.fi> | 2016-03-04 15:23:27 +0200 |
---|---|---|
committer | Arun Raghavan <git@arunraghavan.net> | 2016-05-03 09:18:28 +0530 |
commit | fe4f96d56ee2e8818790b3d562a22d26192591c7 (patch) | |
tree | aa6ff6809e946be51af02f31450b3a068c11aa84 | |
parent | 4f7ade31a9f4eebdef241b69657c92a9fb31268c (diff) | |
download | pulseaudio-fe4f96d56ee2e8818790b3d562a22d26192591c7.tar.gz |
switch-on-port-available: unify input/output switching policy
I don't think there's any reason why the same logic that has
previously added to output profile switching shouldn't be used with
input too.
-rw-r--r-- | src/modules/module-switch-on-port-available.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c index 6f4c895bb..e5e1e9dce 100644 --- a/src/modules/module-switch-on-port-available.c +++ b/src/modules/module-switch-on-port-available.c @@ -56,7 +56,10 @@ static bool profile_good_for_output(pa_card_profile *profile, unsigned prio) { return true; } -static bool profile_good_for_input(pa_card_profile *profile) { +static bool profile_good_for_input(pa_card_profile *profile, unsigned prio) { + pa_source *source; + uint32_t idx; + pa_assert(profile); if (!pa_safe_streq(profile->card->active_profile->output_name, profile->output_name)) @@ -68,6 +71,14 @@ static bool profile_good_for_input(pa_card_profile *profile) { if (profile->card->active_profile->max_sink_channels != profile->max_sink_channels) return false; + PA_IDXSET_FOREACH(source, profile->card->sources, idx) { + if (!source->active_port) + continue; + + if ((source->active_port->available != PA_AVAILABLE_NO) && (source->active_port->priority >= prio)) + return false; + } + return true; } @@ -93,7 +104,7 @@ static int try_to_switch_profile(pa_device_port *port) { case PA_DIRECTION_INPUT: name = profile->input_name; - good = profile_good_for_input(profile); + good = profile_good_for_input(profile, port->priority); break; } |