[pulseaudio-discuss] [PATCH 02/15] node: Replace a state enum with an unlinked flag
Tanu Kaskinen
tanu.kaskinen at linux.intel.com
Thu Feb 13 19:35:47 CET 2014
I think this is cleaner.
---
src/pulsecore/node.c | 10 +++-------
src/pulsecore/node.h | 9 ++-------
2 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/src/pulsecore/node.c b/src/pulsecore/node.c
index 3c6584c..5d1397b 100644
--- a/src/pulsecore/node.c
+++ b/src/pulsecore/node.c
@@ -131,7 +131,6 @@ pa_node *pa_node_new(pa_core *core, pa_node_new_data *data) {
n = pa_xnew0(pa_node, 1);
n->core = core;
- n->state = PA_NODE_STATE_INIT;
if (!(registered_name = pa_namereg_register(core, name, PA_NAMEREG_NODE, n, false))) {
pa_log("Failed to register name %s.", name);
@@ -159,7 +158,7 @@ fail:
void pa_node_free(pa_node *node) {
pa_assert(node);
- if (node->state == PA_NODE_STATE_LINKED)
+ if (!node->unlinked)
pa_node_unlink(node);
pa_xfree(node->description);
@@ -381,12 +380,10 @@ int pa_node_put(pa_node *node, pa_node **requested_connections, unsigned n_reque
};
pa_assert(node);
- pa_assert(node->state == PA_NODE_STATE_INIT);
pa_assert(node->owner);
pa_assert(requested_connections || n_requested_connections == 0);
pa_assert_se(pa_idxset_put(node->core->nodes, node, &node->index) >= 0);
- node->state = PA_NODE_STATE_LINKED;
if (node->monitor_of)
node->monitor_of->monitor = node;
@@ -408,9 +405,8 @@ int pa_node_put(pa_node *node, pa_node **requested_connections, unsigned n_reque
void pa_node_unlink(pa_node *node) {
pa_assert(node);
- pa_assert(node->state != PA_NODE_STATE_INIT);
- if (node->state == PA_NODE_STATE_UNLINKED)
+ if (node->unlinked)
return;
pa_log_debug("Unlinking node %s.", node->name);
@@ -420,7 +416,7 @@ void pa_node_unlink(pa_node *node) {
pa_assert_se(pa_idxset_remove_by_index(node->core->nodes, node->index));
- node->state = PA_NODE_STATE_UNLINKED;
+ node->unlinked = true;
}
void pa_node_active_changed(pa_node *node, bool new_active) {
diff --git a/src/pulsecore/node.h b/src/pulsecore/node.h
index ab31d96..1014f16 100644
--- a/src/pulsecore/node.h
+++ b/src/pulsecore/node.h
@@ -40,12 +40,6 @@ typedef enum {
const char *pa_node_type_to_string(pa_node_type_t type);
-typedef enum {
- PA_NODE_STATE_INIT,
- PA_NODE_STATE_LINKED,
- PA_NODE_STATE_UNLINKED
-} pa_node_state_t;
-
struct pa_node_new_data {
/* Node names are generated automatically as much as possible, but
* sometimes the available information for automatic generation isn't
@@ -73,11 +67,12 @@ struct pa_node {
pa_node_type_t type;
pa_direction_t direction;
- pa_node_state_t state;
pa_node *monitor;
pa_node *monitor_of;
bool active;
+ bool unlinked;
+
void *owner;
};
--
1.8.3.1
More information about the pulseaudio-discuss
mailing list