mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
core: Internally deprecate pa_port_available_t to use pa_available_t
Generalize the availability flag in order to be used beyond the scope of ports. However, pa_port_availability_t is left unchanged to avoid modifying the protocol and the client API. This should be replaced by pa_available_t after a validation phase of this new generic enum type.
This commit is contained in:
parent
3aefdd995c
commit
8851644a3c
12 changed files with 68 additions and 58 deletions
|
|
@ -1753,8 +1753,8 @@ static pa_alsa_jack* jack_get(pa_alsa_path *p, const char *section) {
|
|||
goto finish;
|
||||
|
||||
j = pa_xnew0(pa_alsa_jack, 1);
|
||||
j->state_unplugged = PA_PORT_AVAILABLE_NO;
|
||||
j->state_plugged = PA_PORT_AVAILABLE_YES;
|
||||
j->state_unplugged = PA_AVAILABLE_NO;
|
||||
j->state_plugged = PA_AVAILABLE_YES;
|
||||
j->path = p;
|
||||
j->name = pa_xstrdup(section);
|
||||
j->alsa_name = pa_sprintf_malloc("%s Jack", section);
|
||||
|
|
@ -2167,7 +2167,7 @@ static int element_parse_override_map(pa_config_parser_state *state) {
|
|||
static int jack_parse_state(pa_config_parser_state *state) {
|
||||
pa_alsa_path *p;
|
||||
pa_alsa_jack *j;
|
||||
pa_port_available_t pa;
|
||||
pa_available_t pa;
|
||||
|
||||
pa_assert(state);
|
||||
|
||||
|
|
@ -2179,11 +2179,11 @@ static int jack_parse_state(pa_config_parser_state *state) {
|
|||
}
|
||||
|
||||
if (pa_streq(state->rvalue, "yes"))
|
||||
pa = PA_PORT_AVAILABLE_YES;
|
||||
pa = PA_AVAILABLE_YES;
|
||||
else if (pa_streq(state->rvalue, "no"))
|
||||
pa = PA_PORT_AVAILABLE_NO;
|
||||
pa = PA_AVAILABLE_NO;
|
||||
else if (pa_streq(state->rvalue, "unknown"))
|
||||
pa = PA_PORT_AVAILABLE_UNKNOWN;
|
||||
pa = PA_AVAILABLE_UNKNOWN;
|
||||
else {
|
||||
pa_log("[%s:%u] state must be 'yes', 'no' or 'unknown' in '%s'", state->filename, state->lineno, state->section);
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ struct pa_alsa_jack {
|
|||
pa_bool_t has_control; /* is the jack itself present? */
|
||||
pa_bool_t plugged_in; /* is this jack currently plugged in? */
|
||||
snd_hctl_elem_t *hctl_elem; /* Jack detection handle */
|
||||
pa_port_available_t state_unplugged, state_plugged;
|
||||
pa_available_t state_unplugged, state_plugged;
|
||||
|
||||
pa_alsa_required_t required;
|
||||
pa_alsa_required_t required_any;
|
||||
|
|
|
|||
|
|
@ -1216,8 +1216,8 @@ static pa_alsa_jack* ucm_get_jack(pa_alsa_ucm_config *ucm, const char *dev_name,
|
|||
goto out;
|
||||
|
||||
j = pa_xnew0(pa_alsa_jack, 1);
|
||||
j->state_unplugged = PA_PORT_AVAILABLE_NO;
|
||||
j->state_plugged = PA_PORT_AVAILABLE_YES;
|
||||
j->state_unplugged = PA_AVAILABLE_NO;
|
||||
j->state_plugged = PA_AVAILABLE_YES;
|
||||
j->name = pa_xstrdup(name);
|
||||
j->alsa_name = pa_sprintf_malloc("%s Jack", dev_name);
|
||||
|
||||
|
|
|
|||
|
|
@ -313,11 +313,11 @@ static void report_port_state(pa_device_port *p, struct userdata *u)
|
|||
{
|
||||
void *state;
|
||||
pa_alsa_jack *jack;
|
||||
pa_port_available_t pa = PA_PORT_AVAILABLE_UNKNOWN;
|
||||
pa_available_t pa = PA_AVAILABLE_UNKNOWN;
|
||||
pa_device_port *port;
|
||||
|
||||
PA_HASHMAP_FOREACH(jack, u->jacks, state) {
|
||||
pa_port_available_t cpa;
|
||||
pa_available_t cpa;
|
||||
|
||||
if (u->use_ucm)
|
||||
port = pa_hashmap_get(u->card->ports, jack->name);
|
||||
|
|
@ -334,11 +334,11 @@ static void report_port_state(pa_device_port *p, struct userdata *u)
|
|||
cpa = jack->plugged_in ? jack->state_plugged : jack->state_unplugged;
|
||||
|
||||
/* "Yes" and "no" trumphs "unknown" if we have more than one jack */
|
||||
if (cpa == PA_PORT_AVAILABLE_UNKNOWN)
|
||||
if (cpa == PA_AVAILABLE_UNKNOWN)
|
||||
continue;
|
||||
|
||||
if ((cpa == PA_PORT_AVAILABLE_NO && pa == PA_PORT_AVAILABLE_YES) ||
|
||||
(pa == PA_PORT_AVAILABLE_NO && cpa == PA_PORT_AVAILABLE_YES))
|
||||
if ((cpa == PA_AVAILABLE_NO && pa == PA_AVAILABLE_YES) ||
|
||||
(pa == PA_AVAILABLE_NO && cpa == PA_AVAILABLE_YES))
|
||||
pa_log_warn("Availability of port '%s' is inconsistent!", p->name);
|
||||
else
|
||||
pa = cpa;
|
||||
|
|
|
|||
|
|
@ -1191,23 +1191,23 @@ finish:
|
|||
pa_log_debug("IO thread shutting down");
|
||||
}
|
||||
|
||||
static pa_port_available_t transport_state_to_availability(pa_bluetooth_transport_state_t state) {
|
||||
static pa_available_t transport_state_to_availability(pa_bluetooth_transport_state_t state) {
|
||||
if (state == PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)
|
||||
return PA_PORT_AVAILABLE_NO;
|
||||
return PA_AVAILABLE_NO;
|
||||
else if (state >= PA_BLUETOOTH_TRANSPORT_STATE_PLAYING)
|
||||
return PA_PORT_AVAILABLE_YES;
|
||||
return PA_AVAILABLE_YES;
|
||||
else
|
||||
return PA_PORT_AVAILABLE_UNKNOWN;
|
||||
return PA_AVAILABLE_UNKNOWN;
|
||||
}
|
||||
|
||||
static pa_port_available_t transport_state_to_availability_merged(pa_bluetooth_transport_state_t state1,
|
||||
static pa_available_t transport_state_to_availability_merged(pa_bluetooth_transport_state_t state1,
|
||||
pa_bluetooth_transport_state_t state2) {
|
||||
if (state1 == PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED && state2 == PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)
|
||||
return PA_PORT_AVAILABLE_NO;
|
||||
return PA_AVAILABLE_NO;
|
||||
else if (state1 >= PA_BLUETOOTH_TRANSPORT_STATE_PLAYING || state2 >= PA_BLUETOOTH_TRANSPORT_STATE_PLAYING)
|
||||
return PA_PORT_AVAILABLE_YES;
|
||||
return PA_AVAILABLE_YES;
|
||||
else
|
||||
return PA_PORT_AVAILABLE_UNKNOWN;
|
||||
return PA_AVAILABLE_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Run from main thread */
|
||||
|
|
@ -1229,7 +1229,7 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
|
|||
switch (profile) {
|
||||
case PROFILE_HFGW: {
|
||||
pa_device_port *port;
|
||||
pa_port_available_t available = transport_state_to_availability(state);
|
||||
pa_available_t available = transport_state_to_availability(state);
|
||||
|
||||
pa_assert_se(port = pa_hashmap_get(u->card->ports, "hfgw-output"));
|
||||
pa_device_port_set_available(port, available);
|
||||
|
|
@ -1237,15 +1237,15 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
|
|||
pa_assert_se(port = pa_hashmap_get(u->card->ports, "hfgw-input"));
|
||||
pa_device_port_set_available(port, available);
|
||||
|
||||
acquire = (available == PA_PORT_AVAILABLE_YES && u->profile == PROFILE_HFGW);
|
||||
release = (available != PA_PORT_AVAILABLE_YES && u->profile == PROFILE_HFGW);
|
||||
acquire = (available == PA_AVAILABLE_YES && u->profile == PROFILE_HFGW);
|
||||
release = (available != PA_AVAILABLE_YES && u->profile == PROFILE_HFGW);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PROFILE_HSP: {
|
||||
pa_device_port *port;
|
||||
pa_port_available_t available;
|
||||
pa_available_t available;
|
||||
pa_bluetooth_transport *other = u->device->transports[PROFILE_A2DP];
|
||||
|
||||
if (!other)
|
||||
|
|
@ -1259,28 +1259,28 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
|
|||
pa_assert_se(port = pa_hashmap_get(u->card->ports, "hsp-input"));
|
||||
pa_device_port_set_available(port, available);
|
||||
|
||||
acquire = (available == PA_PORT_AVAILABLE_YES && u->profile == PROFILE_HSP);
|
||||
release = (available != PA_PORT_AVAILABLE_YES && u->profile == PROFILE_HSP);
|
||||
acquire = (available == PA_AVAILABLE_YES && u->profile == PROFILE_HSP);
|
||||
release = (available != PA_AVAILABLE_YES && u->profile == PROFILE_HSP);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PROFILE_A2DP_SOURCE: {
|
||||
pa_device_port *port;
|
||||
pa_port_available_t available = transport_state_to_availability(state);
|
||||
pa_available_t available = transport_state_to_availability(state);
|
||||
|
||||
pa_assert_se(port = pa_hashmap_get(u->card->ports, "a2dp-input"));
|
||||
pa_device_port_set_available(port, available);
|
||||
|
||||
acquire = (available == PA_PORT_AVAILABLE_YES && u->profile == PROFILE_A2DP_SOURCE);
|
||||
release = (available != PA_PORT_AVAILABLE_YES && u->profile == PROFILE_A2DP_SOURCE);
|
||||
acquire = (available == PA_AVAILABLE_YES && u->profile == PROFILE_A2DP_SOURCE);
|
||||
release = (available != PA_AVAILABLE_YES && u->profile == PROFILE_A2DP_SOURCE);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PROFILE_A2DP: {
|
||||
pa_device_port *port;
|
||||
pa_port_available_t available;
|
||||
pa_available_t available;
|
||||
pa_bluetooth_transport *other = u->device->transports[PROFILE_HSP];
|
||||
|
||||
if (!other)
|
||||
|
|
@ -1291,8 +1291,8 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
|
|||
pa_assert_se(port = pa_hashmap_get(u->card->ports, "bluetooth-output"));
|
||||
pa_device_port_set_available(port, available);
|
||||
|
||||
acquire = (available == PA_PORT_AVAILABLE_YES && u->profile == PROFILE_A2DP);
|
||||
release = (available != PA_PORT_AVAILABLE_YES && u->profile == PROFILE_A2DP);
|
||||
acquire = (available == PA_AVAILABLE_YES && u->profile == PROFILE_A2DP);
|
||||
release = (available != PA_AVAILABLE_YES && u->profile == PROFILE_A2DP);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ static pa_device_port* find_best_port(pa_hashmap *ports) {
|
|||
pa_device_port *result = NULL;
|
||||
|
||||
PA_HASHMAP_FOREACH(port, ports, state) {
|
||||
if (port->available != PA_PORT_AVAILABLE_YES)
|
||||
if (port->available != PA_AVAILABLE_YES)
|
||||
continue;
|
||||
|
||||
if (result == NULL || port->priority > result->priority)
|
||||
|
|
@ -193,10 +193,10 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
|
|||
|
||||
is_active_profile = card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name);
|
||||
|
||||
if (is_active_profile && port->available == PA_PORT_AVAILABLE_YES)
|
||||
if (is_active_profile && port->available == PA_AVAILABLE_YES)
|
||||
return PA_HOOK_OK;
|
||||
|
||||
if (!is_active_profile && port->available != PA_PORT_AVAILABLE_YES)
|
||||
if (!is_active_profile && port->available != PA_AVAILABLE_YES)
|
||||
return PA_HOOK_OK;
|
||||
|
||||
if ((port2 = find_best_port(card->ports)) == NULL)
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ static pa_device_port* find_best_port(pa_hashmap *ports) {
|
|||
|
||||
PA_HASHMAP_FOREACH(port, ports, state) {
|
||||
if (result == NULL ||
|
||||
result->available == PA_PORT_AVAILABLE_NO ||
|
||||
(port->available != PA_PORT_AVAILABLE_NO && port->priority > result->priority)) {
|
||||
result->available == PA_AVAILABLE_NO ||
|
||||
(port->available != PA_AVAILABLE_NO && port->priority > result->priority)) {
|
||||
result = port;
|
||||
}
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ static pa_bool_t try_to_switch_profile(pa_card *card, pa_device_port *port) {
|
|||
PA_IDXSET_FOREACH(sink, card->sinks, state2) {
|
||||
if (!sink->active_port)
|
||||
continue;
|
||||
if (sink->active_port->available != PA_PORT_AVAILABLE_NO)
|
||||
if (sink->active_port->available != PA_AVAILABLE_NO)
|
||||
found_active_port = TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
|
|||
pa_source *source;
|
||||
pa_bool_t is_active_profile, is_active_port;
|
||||
|
||||
if (port->available == PA_PORT_AVAILABLE_UNKNOWN)
|
||||
if (port->available == PA_AVAILABLE_UNKNOWN)
|
||||
return PA_HOOK_OK;
|
||||
|
||||
pa_log_debug("finding port %s", port->name);
|
||||
|
|
@ -155,10 +155,10 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
|
|||
is_active_profile = card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name);
|
||||
is_active_port = (sink && sink->active_port == port) || (source && source->active_port == port);
|
||||
|
||||
if (port->available == PA_PORT_AVAILABLE_NO && !is_active_port)
|
||||
if (port->available == PA_AVAILABLE_NO && !is_active_port)
|
||||
return PA_HOOK_OK;
|
||||
|
||||
if (port->available == PA_PORT_AVAILABLE_YES) {
|
||||
if (port->available == PA_AVAILABLE_YES) {
|
||||
if (is_active_port)
|
||||
return PA_HOOK_OK;
|
||||
|
||||
|
|
@ -178,11 +178,11 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
|
|||
pa_sink_set_port(sink, port->name, FALSE);
|
||||
}
|
||||
|
||||
if (port->available == PA_PORT_AVAILABLE_NO) {
|
||||
if (port->available == PA_AVAILABLE_NO) {
|
||||
if (sink) {
|
||||
pa_device_port *p2 = find_best_port(sink->ports);
|
||||
|
||||
if (p2 && p2->available != PA_PORT_AVAILABLE_NO)
|
||||
if (p2 && p2->available != PA_AVAILABLE_NO)
|
||||
pa_sink_set_port(sink, p2->name, FALSE);
|
||||
else {
|
||||
/* Maybe try to switch to another profile? */
|
||||
|
|
@ -192,7 +192,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);
|
||||
|
||||
if (p2 && p2->available != PA_PORT_AVAILABLE_NO)
|
||||
if (p2 && p2->available != PA_AVAILABLE_NO)
|
||||
pa_source_set_port(source, p2->name, FALSE);
|
||||
else {
|
||||
/* Maybe try to switch to another profile? */
|
||||
|
|
@ -212,7 +212,7 @@ static void handle_all_unavailable(pa_core *core) {
|
|||
void *state2;
|
||||
|
||||
PA_HASHMAP_FOREACH(port, card->ports, state2) {
|
||||
if (port->available == PA_PORT_AVAILABLE_NO)
|
||||
if (port->available == PA_AVAILABLE_NO)
|
||||
port_available_hook_callback(core, port, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue