mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
Merge branch 'port_switch' into 'master'
module-switch-on-port-available: check default sink/source before switch See merge request pulseaudio/pulseaudio!370
This commit is contained in:
commit
15efb87bc0
1 changed files with 3 additions and 1 deletions
|
|
@ -197,6 +197,7 @@ struct port_pointers {
|
||||||
bool is_possible_profile_active;
|
bool is_possible_profile_active;
|
||||||
bool is_preferred_profile_active;
|
bool is_preferred_profile_active;
|
||||||
bool is_port_active;
|
bool is_port_active;
|
||||||
|
bool is_default; /* is the sink/source default one */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* profile_name_for_dir(pa_card_profile *cp, pa_direction_t dir) {
|
static const char* profile_name_for_dir(pa_card_profile *cp, pa_direction_t dir) {
|
||||||
|
|
@ -234,6 +235,7 @@ static struct port_pointers find_port_pointers(pa_device_port *port) {
|
||||||
pp.is_preferred_profile_active = pp.is_possible_profile_active && (!port->preferred_profile ||
|
pp.is_preferred_profile_active = pp.is_possible_profile_active && (!port->preferred_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);
|
||||||
|
pp.is_default = (pp.sink && pp.sink == pp.sink->core->default_sink) || (pp.source && pp.source == pp.source->core->default_source);
|
||||||
|
|
||||||
return pp;
|
return pp;
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +267,7 @@ static void switch_from_port(pa_device_port *port, struct port_pointers pp) {
|
||||||
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 || !pp.is_default)
|
||||||
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 */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue