proxy/resource: add method to remove

This commit is contained in:
Wim Taymans 2019-12-05 12:04:45 +01:00
parent ed9d4e5e80
commit d5ea24ae2c
5 changed files with 19 additions and 8 deletions

View file

@ -174,8 +174,7 @@ static int destroy_resource(void *object, void *data)
if (resource &&
resource != client->core_resource) {
resource->removed = true;
pw_resource_destroy(resource);
pw_resource_remove(resource);
}
return 0;
}

View file

@ -901,7 +901,10 @@ pw_core_find_port(struct pw_core *core,
const struct pw_export_type *pw_core_find_export_type(struct pw_core *core, uint32_t type);
int pw_proxy_install_marshal(struct pw_proxy *proxy, bool implementor);
void pw_proxy_remove(struct pw_proxy *proxy);
int pw_resource_install_marshal(struct pw_resource *resource, bool implementor);
void pw_resource_remove(struct pw_resource *resource);
int pw_core_recalc_graph(struct pw_core *core);

View file

@ -210,6 +210,12 @@ void pw_proxy_destroy(struct pw_proxy *proxy)
}
}
void pw_proxy_remove(struct pw_proxy *proxy)
{
proxy->removed = true;
pw_proxy_destroy(proxy);
}
SPA_EXPORT
void pw_proxy_unref(struct pw_proxy *proxy)
{

View file

@ -139,10 +139,8 @@ static void core_event_remove_id(void *data, uint32_t id)
struct pw_proxy *proxy;
pw_log_debug(NAME" %p: object remove %u", this, id);
if ((proxy = pw_map_lookup(&this->objects, id)) != NULL) {
proxy->removed = true;
pw_proxy_destroy(proxy);
}
if ((proxy = pw_map_lookup(&this->objects, id)) != NULL)
pw_proxy_remove(proxy);
}
static void core_event_bound_id(void *data, uint32_t id, uint32_t global_id)
@ -425,8 +423,7 @@ do_connect(struct spa_loop *loop,
return 0;
error_clean_core_proxy:
((struct pw_proxy*)remote->core_proxy)->removed = true;
pw_proxy_destroy((struct pw_proxy*)remote->core_proxy);
pw_proxy_remove((struct pw_proxy*)remote->core_proxy);
error_disconnect:
pw_protocol_client_disconnect(remote->conn);
pw_remote_update_state(remote, PW_REMOTE_STATE_ERROR, "can't connect: %s", spa_strerror(res));

View file

@ -259,3 +259,9 @@ void pw_resource_destroy(struct pw_resource *resource)
free(resource);
}
void pw_resource_remove(struct pw_resource *resource)
{
resource->removed = true;
pw_resource_destroy(resource);
}