Lines Matching full:port
27 #include <pulsecore/device-port.h>
65 static bool profile_good_for_output(pa_card_profile *profile, pa_device_port *port) { in profile_good_for_output() argument
86 if (port == card->preferred_output_port) in profile_good_for_output()
93 …ink->active_port->available != PA_AVAILABLE_NO) && (sink->active_port->priority >= port->priority)) in profile_good_for_output()
100 static bool profile_good_for_input(pa_card_profile *profile, pa_device_port *port) { in profile_good_for_input() argument
121 if (port == card->preferred_input_port) in profile_good_for_input()
128 …e->active_port->available != PA_AVAILABLE_NO) && (source->active_port->priority >= port->priority)) in profile_good_for_input()
135 static int try_to_switch_profile(pa_device_port *port) { in try_to_switch_profile() argument
140 if (port->card->profile_is_sticky) { in try_to_switch_profile()
141 pa_log_info("Keeping sticky card profile '%s'", port->card->active_profile->name); in try_to_switch_profile()
145 pa_log_debug("Finding best profile for port %s, preferred = %s", in try_to_switch_profile()
146 port->name, pa_strnull(port->preferred_profile)); in try_to_switch_profile()
148 PA_HASHMAP_FOREACH(profile, port->profiles, state) { in try_to_switch_profile()
154 switch (port->direction) { in try_to_switch_profile()
157 good = profile_good_for_output(profile, port); in try_to_switch_profile()
162 good = profile_good_for_input(profile, port); in try_to_switch_profile()
170 if (pa_safe_streq(name ? name : profile->name, port->preferred_profile)) in try_to_switch_profile()
185 if (pa_card_set_profile(port->card, best_profile, false) != 0) { in try_to_switch_profile()
194 pa_device_port *port; member
210 static struct port_pointers find_port_pointers(pa_device_port *port) { in find_port_pointers() argument
211 struct port_pointers pp = { .port = port }; in find_port_pointers()
215 pa_assert(port); in find_port_pointers()
216 pa_assert_se(card = port->card); in find_port_pointers()
218 switch (port->direction) { in find_port_pointers()
221 if (port == pa_hashmap_get(pp.sink->ports, port->name)) in find_port_pointers()
227 if (port == pa_hashmap_get(pp.source->ports, port->name)) in find_port_pointers()
233 card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name); in find_port_pointers()
234 pp.is_preferred_profile_active = pp.is_possible_profile_active && (!port->preferred_profile || in find_port_pointers()
235 …pa_safe_streq(port->preferred_profile, profile_name_for_dir(card->active_profile, port->direction)… in find_port_pointers()
236 …port_active = (pp.sink && pp.sink->active_port == port) || (pp.source && pp.source->active_port ==… in find_port_pointers()
241 /* Switches to a port, switching profiles if necessary or preferred */
242 static void switch_to_port(pa_device_port *port, struct port_pointers pp) { in switch_to_port() argument
246 pa_log_debug("Trying to switch to port %s", port->name); in switch_to_port()
248 if (try_to_switch_profile(port) < 0) { in switch_to_port()
254 pp = find_port_pointers(port); in switch_to_port()
258 pa_source_set_port(pp.source, port->name, false); in switch_to_port()
260 pa_sink_set_port(pp.sink, port->name, false); in switch_to_port()
263 /* Switches away from a port, switching profiles if necessary or preferred */
264 static void switch_from_port(pa_device_port *port, struct port_pointers pp) { in switch_from_port() argument
271 /* Try to find a good enough port to switch to */ in switch_from_port()
272 PA_HASHMAP_FOREACH(p, port->card->ports, state) { in switch_from_port()
273 if (p == port) in switch_from_port()
279 if (p->direction != port->direction) in switch_from_port()
286 …pa_log_debug("Trying to switch away from port %s, found %s", port->name, best_port ? best_port->na… in switch_from_port()
288 /* If there is no available port to switch to we need check if the active in switch_from_port()
299 static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port *port, void* userda… in port_available_hook_callback() argument
300 struct port_pointers pp = find_port_pointers(port); in port_available_hook_callback()
302 if (!port->card) { in port_available_hook_callback()
303 pa_log_warn("Port %s does not have a card", port->name); in port_available_hook_callback()
311 * module-switch-on-port-available. */ in port_available_hook_callback()
312 if (pa_safe_streq(pa_proplist_gets(port->card->proplist, PA_PROP_DEVICE_BUS), "bluetooth")) in port_available_hook_callback()
315 switch (port->available) { in port_available_hook_callback()
317 /* If a port availability became unknown, let's see if it's part of in port_available_hook_callback()
323 * the headphone port at least, so that we have don't break in port_available_hook_callback()
339 /* Not part of a group of ports, so likely not a combination port */ in port_available_hook_callback()
340 if (!port->availability_group) { in port_available_hook_callback()
341 …pa_log_debug("Not switching to port %s, its availability is unknown and it's not in any availabili… in port_available_hook_callback()
345 /* Switch the headphone port, the input ports without source and the in port_available_hook_callback()
348 …if (port->direction == PA_DIRECTION_INPUT && pp.source && !pp.source->active_port->availability_gr… in port_available_hook_callback()
349 … pa_log_debug("Not switching to input port %s, its availability is unknown.", port->name); in port_available_hook_callback()
353 switch_to_port(port, pp); in port_available_hook_callback()
357 switch_to_port(port, pp); in port_available_hook_callback()
360 switch_from_port(port, pp); in port_available_hook_callback()
416 pa_device_port *port; in handle_all_unavailable() local
419 PA_HASHMAP_FOREACH(port, card->ports, state2) { in handle_all_unavailable()
420 if (port->available == PA_AVAILABLE_NO) in handle_all_unavailable()
421 port_available_hook_callback(core, port, NULL); in handle_all_unavailable()
453 pa_log_debug("Switching initial port for sink '%s' to '%s'", new_data->name, p->name); in sink_new_hook_callback()
464 pa_log_debug("Switching initial port for source '%s' to '%s'", new_data->name, p->name); in source_new_hook_callback()
486 * the user's input port preference. */ in update_preferred_input_port()
499 * whether the user wanted to activate some specific input port, or was the in update_preferred_input_port()
511 * wanted to activate the port that was selected by default, but if that's in update_preferred_input_port()
512 * the case, the user will change the port manually, and we'll update the in update_preferred_input_port()
513 * port preference at that time. If no port change occurs, we can assume in update_preferred_input_port()
514 * that the user likes the port that is now active. */ in update_preferred_input_port()
522 * the user's output port preference. */ in update_preferred_output_port()
535 * whether the user wanted to activate some specific output port, or was in update_preferred_output_port()
547 * wanted to activate the port that was selected by default, but if that's in update_preferred_output_port()
548 * the case, the user will change the port manually, and we'll update the in update_preferred_output_port()
549 * port preference at that time. If no port change occurs, we can assume in update_preferred_output_port()
550 * that the user likes the port that is now active. */ in update_preferred_output_port()
565 * a change in the user's port preferences. */ in card_profile_changed_callback()