Lines Matching refs:port
65 static bool profile_good_for_output(pa_card_profile *profile, pa_device_port *port) { in profile_good_for_output() argument
83 if (port == card->preferred_output_port) in profile_good_for_output()
90 …ink->active_port->available != PA_AVAILABLE_NO) && (sink->active_port->priority >= port->priority)) in profile_good_for_output()
97 static bool profile_good_for_input(pa_card_profile *profile, pa_device_port *port) { in profile_good_for_input() argument
115 if (port == card->preferred_input_port) in profile_good_for_input()
122 …e->active_port->available != PA_AVAILABLE_NO) && (source->active_port->priority >= port->priority)) in profile_good_for_input()
129 static int try_to_switch_profile(pa_device_port *port) { in try_to_switch_profile() argument
135 port->name, pa_strnull(port->preferred_profile)); in try_to_switch_profile()
137 PA_HASHMAP_FOREACH(profile, port->profiles, state) { in try_to_switch_profile()
143 switch (port->direction) { in try_to_switch_profile()
146 good = profile_good_for_output(profile, port); in try_to_switch_profile()
151 good = profile_good_for_input(profile, port); in try_to_switch_profile()
159 if (pa_safe_streq(name ? name : profile->name, port->preferred_profile)) in try_to_switch_profile()
174 if (pa_card_set_profile(port->card, best_profile, false) != 0) { in try_to_switch_profile()
183 pa_device_port *port; member
199 static struct port_pointers find_port_pointers(pa_device_port *port) { in find_port_pointers() argument
200 struct port_pointers pp = { .port = port }; in find_port_pointers()
204 pa_assert(port); in find_port_pointers()
205 pa_assert_se(card = port->card); in find_port_pointers()
207 switch (port->direction) { in find_port_pointers()
210 if (port == pa_hashmap_get(pp.sink->ports, port->name)) in find_port_pointers()
216 if (port == pa_hashmap_get(pp.source->ports, port->name)) in find_port_pointers()
222 card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name); in find_port_pointers()
223 pp.is_preferred_profile_active = pp.is_possible_profile_active && (!port->preferred_profile || in find_port_pointers()
224 …pa_safe_streq(port->preferred_profile, profile_name_for_dir(card->active_profile, port->direction)… in find_port_pointers()
225 …port_active = (pp.sink && pp.sink->active_port == port) || (pp.source && pp.source->active_port ==… in find_port_pointers()
231 static void switch_to_port(pa_device_port *port, struct port_pointers pp) { in switch_to_port() argument
235 pa_log_debug("Trying to switch to port %s", port->name); in switch_to_port()
237 if (try_to_switch_profile(port) < 0) { in switch_to_port()
243 pp = find_port_pointers(port); in switch_to_port()
247 pa_source_set_port(pp.source, port->name, false); in switch_to_port()
249 pa_sink_set_port(pp.sink, port->name, false); in switch_to_port()
253 static void switch_from_port(pa_device_port *port, struct port_pointers pp) { in switch_from_port() argument
261 PA_HASHMAP_FOREACH(p, port->card->ports, state) { in switch_from_port()
262 if (p == port) in switch_from_port()
268 if (p->direction != port->direction) in switch_from_port()
275 …pa_log_debug("Trying to switch away from port %s, found %s", port->name, best_port ? best_port->na… in switch_from_port()
288 static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port *port, void* userda… in port_available_hook_callback() argument
289 struct port_pointers pp = find_port_pointers(port); in port_available_hook_callback()
291 if (!port->card) { in port_available_hook_callback()
292 pa_log_warn("Port %s does not have a card", port->name); in port_available_hook_callback()
301 if (pa_safe_streq(pa_proplist_gets(port->card->proplist, PA_PROP_DEVICE_BUS), "bluetooth")) in port_available_hook_callback()
304 switch (port->available) { in port_available_hook_callback()
329 if (!port->availability_group) { in port_available_hook_callback()
330 …hing to port %s, its availability is unknown and it's not in any availability group.", port->name); in port_available_hook_callback()
337 …if (port->direction == PA_DIRECTION_INPUT && pp.source && !pp.source->active_port->availability_gr… in port_available_hook_callback()
338 … pa_log_debug("Not switching to input port %s, its availability is unknown.", port->name); in port_available_hook_callback()
342 switch_to_port(port, pp); in port_available_hook_callback()
346 switch_to_port(port, pp); in port_available_hook_callback()
349 switch_from_port(port, pp); in port_available_hook_callback()
400 pa_device_port *port; in handle_all_unavailable() local
403 PA_HASHMAP_FOREACH(port, card->ports, state2) { in handle_all_unavailable()
404 if (port->available == PA_AVAILABLE_NO) in handle_all_unavailable()
405 port_available_hook_callback(core, port, NULL); in handle_all_unavailable()