summaryrefslogtreecommitdiff
path: root/src/modules/module-switch-on-port-available.c
diff options
context:
space:
mode:
authorDavid Henningsson <david.henningsson@canonical.com>2014-03-28 11:09:14 +0100
committerDavid Henningsson <david.henningsson@canonical.com>2014-04-04 07:28:34 +0200
commit319a665ce8c5f67404e3b19ece557bd910be7814 (patch)
tree57210c53d4c21f0e7570b3b51de8ec81b4257d8a /src/modules/module-switch-on-port-available.c
parent06ad1b7a06f48c012a63880b985954af25b87034 (diff)
downloadpulseaudio-319a665ce8c5f67404e3b19ece557bd910be7814.tar.gz
module-switch-on-port-available: Use new find best port function
Now that we have a generic function in device-port.h, we can use it instead of the custom one. Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Diffstat (limited to 'src/modules/module-switch-on-port-available.c')
-rw-r--r--src/modules/module-switch-on-port-available.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c
index d8cb82b6c..b0938d5dd 100644
--- a/src/modules/module-switch-on-port-available.c
+++ b/src/modules/module-switch-on-port-available.c
@@ -36,21 +36,6 @@ struct userdata {
pa_hook_slot *source_new_slot;
};
-static pa_device_port* find_best_port(pa_hashmap *ports) {
- void *state;
- pa_device_port* port, *result = NULL;
-
- PA_HASHMAP_FOREACH(port, ports, state) {
- if (result == NULL ||
- result->available == PA_AVAILABLE_NO ||
- (port->available != PA_AVAILABLE_NO && port->priority > result->priority)) {
- result = port;
- }
- }
-
- return result;
-}
-
static bool profile_good_for_output(pa_card_profile *profile) {
pa_sink *sink;
uint32_t idx;
@@ -203,7 +188,7 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
if (port->available == PA_AVAILABLE_NO) {
if (sink) {
- pa_device_port *p2 = find_best_port(sink->ports);
+ pa_device_port *p2 = pa_device_port_find_best(sink->ports);
if (p2 && p2->available != PA_AVAILABLE_NO)
pa_sink_set_port(sink, p2->name, false);
@@ -213,7 +198,7 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
}
if (source) {
- pa_device_port *p2 = find_best_port(source->ports);
+ pa_device_port *p2 = pa_device_port_find_best(source->ports);
if (p2 && p2->available != PA_AVAILABLE_NO)
pa_source_set_port(source, p2->name, false);
@@ -259,7 +244,7 @@ static pa_device_port *new_sink_source(pa_hashmap *ports, const char *name) {
if (p->available != PA_AVAILABLE_NO)
return NULL;
- pa_assert_se(p = find_best_port(ports));
+ pa_assert_se(p = pa_device_port_find_best(ports));
return p;
}