client-node: improve cleanup

This commit is contained in:
Wim Taymans 2019-03-06 09:52:07 +01:00
parent 3777d9612e
commit 5ee287d79b
4 changed files with 25 additions and 9 deletions

View file

@ -112,6 +112,7 @@ struct port {
struct pw_properties *properties;
int have_format:1;
int removed:1;
uint32_t n_params;
struct spa_pod **params;
@ -596,7 +597,7 @@ clear_port(struct node *this, struct port *port)
spa_log_debug(this->log, "node %p: clear port %p", this, port);
if (port == NULL)
return ;
return;
do_update_port(this, port,
PW_CLIENT_NODE_PORT_UPDATE_PARAMS |
@ -619,7 +620,8 @@ clear_port(struct node *this, struct port *port)
this->n_outputs--;
}
}
spa_node_emit_port_info(&this->hooks, port->direction, port->id, NULL);
if (!port->removed)
spa_node_emit_port_info(&this->hooks, port->direction, port->id, NULL);
}
static int
@ -1518,6 +1520,7 @@ static void node_port_removed(void *data, struct pw_port *port)
pw_log_debug("client-node %p: port %p remove", &impl->this, port);
p->removed = true;
clear_port(this, p);
}

View file

@ -1103,9 +1103,15 @@ static void client_node_destroy(void *data)
pw_node_set_driver(impl->client_node->node, NULL);
spa_hook_remove(&impl->client_node_listener);
spa_hook_remove(&impl->node_listener);
pw_node_destroy(impl->this.node);
}
static void client_node_free(void *data)
{
struct impl *impl = data;
pw_log_debug("client-stream %p: free", &impl->this);
spa_hook_remove(&impl->client_node_listener);
cleanup(impl);
}
@ -1138,21 +1144,26 @@ static void client_node_info_changed(void *data, const struct pw_node_info *info
static const struct pw_node_events client_node_events = {
PW_VERSION_NODE_EVENTS,
.destroy = client_node_destroy,
.free = client_node_free,
.initialized = client_node_initialized,
.result = client_node_result,
.active_changed = client_node_active_changed,
.info_changed = client_node_info_changed,
};
static void node_destroy(void *data)
{
struct impl *impl = data;
pw_log_debug("client-stream %p: destroy", &impl->this);
spa_hook_remove(&impl->client_node_listener);
pw_client_node_destroy(impl->client_node);
}
static void node_free(void *data)
{
struct impl *impl = data;
pw_log_debug("client-stream %p: free", &impl->this);
spa_hook_remove(&impl->node_listener);
spa_hook_remove(&impl->client_node_listener);
pw_client_node_destroy(impl->client_node);
cleanup(impl);
}
@ -1184,6 +1195,7 @@ static void node_driver_changed(void *data, struct pw_node *old, struct pw_node
static const struct pw_node_events node_events = {
PW_VERSION_NODE_EVENTS,
.destroy = node_destroy,
.free = node_free,
.initialized = node_initialized,
.peer_added = node_peer_added,