[pulseaudio-commits] src/modules src/pulse src/pulsecore
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Mon Feb 18 07:29:49 PST 2013
src/modules/alsa/alsa-mixer.c | 12 +++----
src/modules/alsa/alsa-mixer.h | 2 -
src/modules/alsa/alsa-ucm.c | 4 +-
src/modules/alsa/module-alsa-card.c | 10 +++---
src/modules/bluetooth/module-bluetooth-device.c | 40 ++++++++++++------------
src/modules/bluetooth/module-bluetooth-policy.c | 6 +--
src/modules/module-switch-on-port-available.c | 20 ++++++------
src/pulse/def.h | 2 +
src/pulsecore/card.h | 8 ++++
src/pulsecore/cli-text.c | 8 ++--
src/pulsecore/device-port.c | 10 +++---
src/pulsecore/device-port.h | 4 +-
12 files changed, 68 insertions(+), 58 deletions(-)
New commits:
commit 8851644a3c76cf29c8244a19446781cfa1943763
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date: Mon Feb 18 16:13:24 2013 +0100
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.
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 97f25af..f2e68d3 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -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;
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index 2e3c115..5b710a3 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -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;
diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
index e01721f..f69ee89 100644
--- a/src/modules/alsa/alsa-ucm.c
+++ b/src/modules/alsa/alsa-ucm.c
@@ -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);
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index 3f5af34..f5e1c9e 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -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;
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 776bcba..9fa768a 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -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;
}
diff --git a/src/modules/bluetooth/module-bluetooth-policy.c b/src/modules/bluetooth/module-bluetooth-policy.c
index fc605b3..f53a422 100644
--- a/src/modules/bluetooth/module-bluetooth-policy.c
+++ b/src/modules/bluetooth/module-bluetooth-policy.c
@@ -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)
diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c
index 1da612d..9b2029b 100644
--- a/src/modules/module-switch-on-port-available.c
+++ b/src/modules/module-switch-on-port-available.c
@@ -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);
}
}
diff --git a/src/pulse/def.h b/src/pulse/def.h
index b939319..f8c2a5f 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -991,6 +991,7 @@ typedef void (*pa_free_cb_t)(void *p);
* playback, \since 1.0 */
#define PA_STREAM_EVENT_FORMAT_LOST "format-lost"
+#ifndef __INCLUDED_FROM_PULSE_AUDIO
/** Port availability / jack detection status
* \since 2.0 */
typedef enum pa_port_available {
@@ -1005,6 +1006,7 @@ typedef enum pa_port_available {
#define PA_PORT_AVAILABLE_YES PA_PORT_AVAILABLE_YES
/** \endcond */
+#endif
PA_C_DECL_END
diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
index d72a293..ec2f9d2 100644
--- a/src/pulsecore/card.h
+++ b/src/pulsecore/card.h
@@ -29,6 +29,14 @@ typedef struct pa_card pa_card;
#include <pulsecore/module.h>
#include <pulsecore/idxset.h>
+/* This enum replaces pa_port_available_t (defined in pulse/def.h) for
+ * internal use, so make sure both enum types stay in sync. */
+typedef enum pa_available {
+ PA_AVAILABLE_UNKNOWN = 0,
+ PA_AVAILABLE_NO = 1,
+ PA_AVAILABLE_YES = 2,
+} pa_available_t;
+
typedef struct pa_card_profile {
pa_card *card;
char *name;
diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c
index 238fbd8..c4e0b37 100644
--- a/src/pulsecore/cli-text.c
+++ b/src/pulsecore/cli-text.c
@@ -103,13 +103,13 @@ char *pa_client_list_to_string(pa_core *c) {
return pa_strbuf_tostring_free(s);
}
-static const char *port_available_to_string(pa_port_available_t a) {
+static const char *port_available_to_string(pa_available_t a) {
switch (a) {
- case PA_PORT_AVAILABLE_UNKNOWN:
+ case PA_AVAILABLE_UNKNOWN:
return "unknown";
- case PA_PORT_AVAILABLE_NO:
+ case PA_AVAILABLE_NO:
return "no";
- case PA_PORT_AVAILABLE_YES:
+ case PA_AVAILABLE_YES:
return "yes";
default:
return "invalid"; /* Should never happen! */
diff --git a/src/pulsecore/device-port.c b/src/pulsecore/device-port.c
index e0f9560..f16de3a 100644
--- a/src/pulsecore/device-port.c
+++ b/src/pulsecore/device-port.c
@@ -26,7 +26,7 @@
PA_DEFINE_PUBLIC_CLASS(pa_device_port, pa_object);
-void pa_device_port_set_available(pa_device_port *p, pa_port_available_t status)
+void pa_device_port_set_available(pa_device_port *p, pa_available_t status)
{
pa_core *core;
@@ -35,11 +35,11 @@ void pa_device_port_set_available(pa_device_port *p, pa_port_available_t status)
if (p->available == status)
return;
-/* pa_assert(status != PA_PORT_AVAILABLE_UNKNOWN); */
+/* pa_assert(status != PA_AVAILABLE_UNKNOWN); */
p->available = status;
- pa_log_debug("Setting port %s to status %s", p->name, status == PA_PORT_AVAILABLE_YES ? "yes" :
- status == PA_PORT_AVAILABLE_NO ? "no" : "unknown");
+ pa_log_debug("Setting port %s to status %s", p->name, status == PA_AVAILABLE_YES ? "yes" :
+ status == PA_AVAILABLE_NO ? "no" : "unknown");
/* Post subscriptions to the card which owns us */
pa_assert_se(core = p->core);
@@ -79,7 +79,7 @@ pa_device_port *pa_device_port_new(pa_core *c, const char *name, const char *des
p->core = c;
p->card = NULL;
p->priority = 0;
- p->available = PA_PORT_AVAILABLE_UNKNOWN;
+ p->available = PA_AVAILABLE_UNKNOWN;
p->profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
p->is_input = FALSE;
p->is_output = FALSE;
diff --git a/src/pulsecore/device-port.h b/src/pulsecore/device-port.h
index 40306f5..c0c00cf 100644
--- a/src/pulsecore/device-port.h
+++ b/src/pulsecore/device-port.h
@@ -47,7 +47,7 @@ struct pa_device_port {
char *description;
unsigned priority;
- pa_port_available_t available; /* PA_PORT_AVAILABLE_UNKNOWN, PA_PORT_AVAILABLE_NO or PA_PORT_AVAILABLE_YES */
+ pa_available_t available; /* PA_AVAILABLE_UNKNOWN, PA_AVAILABLE_NO or PA_AVAILABLE_YES */
pa_proplist *proplist;
pa_hashmap *profiles; /* Does not own the profiles */
@@ -66,7 +66,7 @@ PA_DECLARE_PUBLIC_CLASS(pa_device_port);
pa_device_port *pa_device_port_new(pa_core *c, const char *name, const char *description, size_t extra);
/* The port's available status has changed */
-void pa_device_port_set_available(pa_device_port *p, pa_port_available_t available);
+void pa_device_port_set_available(pa_device_port *p, pa_available_t available);
void pa_device_port_set_latency_offset(pa_device_port *p, int64_t offset);
More information about the pulseaudio-commits
mailing list