[pulseaudio-commits] 3 commits - src/modules
Arun Raghavan
arun at kemper.freedesktop.org
Tue May 3 03:49:54 UTC 2016
src/modules/module-switch-on-port-available.c | 37 ++++++++++++++++++--------
1 file changed, 27 insertions(+), 10 deletions(-)
New commits:
commit b88f2859a988ce5a1667363445c67fc34b756298
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Fri Mar 4 15:23:29 2016 +0200
switch-on-port-available: avoid repetitive pointer deferencing
Trivial refactoring.
diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c
index 9bfb43f..2453644 100644
--- a/src/modules/module-switch-on-port-available.c
+++ b/src/modules/module-switch-on-port-available.c
@@ -30,22 +30,25 @@
#include "module-switch-on-port-available-symdef.h"
static bool profile_good_for_output(pa_card_profile *profile, unsigned prio) {
+ pa_card *card;
pa_sink *sink;
uint32_t idx;
pa_assert(profile);
- if (!pa_safe_streq(profile->card->active_profile->input_name, profile->input_name))
+ card = profile->card;
+
+ if (!pa_safe_streq(card->active_profile->input_name, profile->input_name))
return false;
- if (profile->card->active_profile->n_sources != profile->n_sources)
+ if (card->active_profile->n_sources != profile->n_sources)
return false;
- if (profile->card->active_profile->max_source_channels != profile->max_source_channels)
+ if (card->active_profile->max_source_channels != profile->max_source_channels)
return false;
/* Try not to switch to HDMI sinks from analog when HDMI is becoming available */
- PA_IDXSET_FOREACH(sink, profile->card->sinks, idx) {
+ PA_IDXSET_FOREACH(sink, card->sinks, idx) {
if (!sink->active_port)
continue;
@@ -57,21 +60,24 @@ static bool profile_good_for_output(pa_card_profile *profile, unsigned prio) {
}
static bool profile_good_for_input(pa_card_profile *profile, unsigned prio) {
+ pa_card *card;
pa_source *source;
uint32_t idx;
pa_assert(profile);
- if (!pa_safe_streq(profile->card->active_profile->output_name, profile->output_name))
+ card = profile->card;
+
+ if (!pa_safe_streq(card->active_profile->output_name, profile->output_name))
return false;
- if (profile->card->active_profile->n_sinks != profile->n_sinks)
+ if (card->active_profile->n_sinks != profile->n_sinks)
return false;
- if (profile->card->active_profile->max_sink_channels != profile->max_sink_channels)
+ if (card->active_profile->max_sink_channels != profile->max_sink_channels)
return false;
- PA_IDXSET_FOREACH(source, profile->card->sources, idx) {
+ PA_IDXSET_FOREACH(source, card->sources, idx) {
if (!source->active_port)
continue;
commit a99eb81db363427d706ee28db73dd33999291cf3
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Fri Mar 4 15:23:28 2016 +0200
switch-on-port-available: fix inverted if condition
I'm sure the original intention was to switch the port if the target
port is available on the currently active profile.
diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c
index e5e1e9d..9bfb43f 100644
--- a/src/modules/module-switch-on-port-available.c
+++ b/src/modules/module-switch-on-port-available.c
@@ -193,7 +193,7 @@ static bool switch_to_port(pa_device_port *port) {
pa_log_debug("Trying to switch to port %s", port->name);
if (!pp.is_preferred_profile_active) {
if (try_to_switch_profile(port) < 0) {
- if (pp.is_possible_profile_active)
+ if (!pp.is_possible_profile_active)
return false;
}
else
commit fe4f96d56ee2e8818790b3d562a22d26192591c7
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Fri Mar 4 15:23:27 2016 +0200
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.
diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c
index 6f4c895..e5e1e9d 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;
}
More information about the pulseaudio-commits
mailing list