"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/modules/module-switch-on-port-available.c" between
pulseaudio-14.0.tar.xz and pulseaudio-14.2.tar.xz

About: PulseAudio is a networked sound server (for POSIX OSes), a proxy for your sound applications.

module-switch-on-port-available.c  (pulseaudio-14.0.tar.xz):module-switch-on-port-available.c  (pulseaudio-14.2.tar.xz)
skipping to change at line 231 skipping to change at line 231
pp.is_possible_profile_active = pp.is_possible_profile_active =
card->active_profile == pa_hashmap_get(port->profiles, card->active_prof ile->name); card->active_profile == pa_hashmap_get(port->profiles, card->active_prof ile->name);
pp.is_preferred_profile_active = pp.is_possible_profile_active && (!port->pr eferred_profile || pp.is_preferred_profile_active = pp.is_possible_profile_active && (!port->pr eferred_profile ||
pa_safe_streq(port->preferred_profile, profile_name_for_dir(card->active _profile, port->direction))); pa_safe_streq(port->preferred_profile, profile_name_for_dir(card->active _profile, port->direction)));
pp.is_port_active = (pp.sink && pp.sink->active_port == port) || (pp.source && pp.source->active_port == port); pp.is_port_active = (pp.sink && pp.sink->active_port == port) || (pp.source && pp.source->active_port == port);
return pp; return pp;
} }
/* Switches to a port, switching profiles if necessary or preferred */ /* Switches to a port, switching profiles if necessary or preferred */
static void switch_to_port(pa_device_port *port) { static void switch_to_port(pa_device_port *port, struct port_pointers pp) {
struct port_pointers pp = find_port_pointers(port);
if (pp.is_port_active) if (pp.is_port_active)
return; /* Already selected */ return; /* Already selected */
pa_log_debug("Trying to switch to port %s", port->name); pa_log_debug("Trying to switch to port %s", port->name);
if (!pp.is_preferred_profile_active) { if (!pp.is_preferred_profile_active) {
if (try_to_switch_profile(port) < 0) { if (try_to_switch_profile(port) < 0) {
if (!pp.is_possible_profile_active) if (!pp.is_possible_profile_active)
return; return;
} }
else else
skipping to change at line 255 skipping to change at line 253
pp = find_port_pointers(port); pp = find_port_pointers(port);
} }
if (pp.source) if (pp.source)
pa_source_set_port(pp.source, port->name, false); pa_source_set_port(pp.source, port->name, false);
if (pp.sink) if (pp.sink)
pa_sink_set_port(pp.sink, port->name, false); pa_sink_set_port(pp.sink, port->name, false);
} }
/* Switches away from a port, switching profiles if necessary or preferred */ /* Switches away from a port, switching profiles if necessary or preferred */
static void switch_from_port(pa_device_port *port) { static void switch_from_port(pa_device_port *port, struct port_pointers pp) {
struct port_pointers pp = find_port_pointers(port);
pa_device_port *p, *best_port = NULL; pa_device_port *p, *best_port = NULL;
void *state; void *state;
if (!pp.is_port_active) if (!pp.is_port_active)
return; /* Already deselected */ return; /* Already deselected */
/* Try to find a good enough port to switch to */ /* Try to find a good enough port to switch to */
PA_HASHMAP_FOREACH(p, port->card->ports, state) { PA_HASHMAP_FOREACH(p, port->card->ports, state) {
if (p == port) if (p == port)
continue; continue;
skipping to change at line 284 skipping to change at line 281
if (!best_port || best_port->priority < p->priority) if (!best_port || best_port->priority < p->priority)
best_port = p; best_port = p;
} }
pa_log_debug("Trying to switch away from port %s, found %s", port->name, bes t_port ? best_port->name : "no better option"); pa_log_debug("Trying to switch away from port %s, found %s", port->name, bes t_port ? best_port->name : "no better option");
/* If there is no available port to switch to we need check if the active /* If there is no available port to switch to we need check if the active
* profile is still available in the * profile is still available in the
* PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED callback, as at this point * PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED callback, as at this point
* the profile availability hasn't been updated yet. */ * the profile availability hasn't been updated yet. */
if (best_port) if (best_port) {
switch_to_port(best_port); struct port_pointers best_pp = find_port_pointers(best_port);
switch_to_port(best_port, best_pp);
}
} }
static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port *port, void* userdata) { static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port *port, void* userdata) {
pa_assert(port); struct port_pointers pp = find_port_pointers(port);
if (!port->card) { if (!port->card) {
pa_log_warn("Port %s does not have a card", port->name); pa_log_warn("Port %s does not have a card", port->name);
return PA_HOOK_OK; return PA_HOOK_OK;
} }
/* Our profile switching logic caused trouble with bluetooth headsets (see /* Our profile switching logic caused trouble with bluetooth headsets (see
* https://bugs.freedesktop.org/show_bug.cgi?id=107044) and * https://bugs.freedesktop.org/show_bug.cgi?id=107044) and
* module-bluetooth-policy takes care of automatic profile switching * module-bluetooth-policy takes care of automatic profile switching
* anyway, so we ignore bluetooth cards in * anyway, so we ignore bluetooth cards in
skipping to change at line 316 skipping to change at line 315
/* If a port availability became unknown, let's see if it's part of /* If a port availability became unknown, let's see if it's part of
* some availability group. If it is, it is likely to be a headphone * some availability group. If it is, it is likely to be a headphone
* jack that does not have impedance sensing to detect whether what was * jack that does not have impedance sensing to detect whether what was
* plugged in was a headphone, headset or microphone. In desktop * plugged in was a headphone, headset or microphone. In desktop
* environments that support it, this will trigger a user choice to * environments that support it, this will trigger a user choice to
* select what kind of device was plugged in. However, let's switch to * select what kind of device was plugged in. However, let's switch to
* the headphone port at least, so that we have don't break * the headphone port at least, so that we have don't break
* functionality for setups that can't trigger this kind of * functionality for setups that can't trigger this kind of
* interaction. * interaction.
* *
* For headset or microphone, if they are part of some availability grou
p
* and they become unknown from off, it needs to check if their source i
s
* unlinked or not, if their source is unlinked, let switch_to_port()
* process them, then with the running of pa_card_set_profile(), their
* source will be created, otherwise the headset or microphone can't be
used
* to record sound since there is no source for these 2 ports. This issu
e
* is observed on Dell machines which have multi-function audio jack but
no
* internal mic.
*
* We should make this configurable so that users can optionally * We should make this configurable so that users can optionally
* override the default to a headset or mic. */ * override the default to a headset or mic. */
/* Not part of a group of ports, so likely not a combination port */ /* Not part of a group of ports, so likely not a combination port */
if (!port->availability_group) { if (!port->availability_group) {
pa_log_debug("Not switching to port %s, its availability is unknown and it's not in any availability group.", port->name); pa_log_debug("Not switching to port %s, its availability is unknown and it's not in any availability group.", port->name);
break; break;
} }
/* For no we only switch the headphone port */ /* Switch the headphone port, the input ports without source and the
if (port->direction != PA_DIRECTION_OUTPUT) { * input ports their source->active_port is part of a group of ports.
*/
if (port->direction == PA_DIRECTION_INPUT && pp.source && !pp.source->ac
tive_port->availability_group) {
pa_log_debug("Not switching to input port %s, its availability is un known.", port->name); pa_log_debug("Not switching to input port %s, its availability is un known.", port->name);
break; break;
} }
switch_to_port(port); switch_to_port(port, pp);
break; break;
case PA_AVAILABLE_YES: case PA_AVAILABLE_YES:
switch_to_port(port); switch_to_port(port, pp);
break; break;
case PA_AVAILABLE_NO: case PA_AVAILABLE_NO:
switch_from_port(port); switch_from_port(port, pp);
break; break;
default: default:
break; break;
} }
return PA_HOOK_OK; return PA_HOOK_OK;
} }
static pa_card_profile *find_best_profile(pa_card *card) { static pa_card_profile *find_best_profile(pa_card *card) {
pa_card_profile *profile, *best_profile; pa_card_profile *profile, *best_profile;
 End of changes. 9 change blocks. 
13 lines changed or deleted 29 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)