diff --git a/src/pipewire/array.h b/src/pipewire/array.h index af05f5d36..49de93a73 100644 --- a/src/pipewire/array.h +++ b/src/pipewire/array.h @@ -82,6 +82,12 @@ static inline void pw_array_clear(struct pw_array *arr) free(arr->data); } +/** Reset the array */ +static inline void pw_array_reset(struct pw_array *arr) +{ + arr->size = 0; +} + /** Make sure \a size bytes can be added to the array \memberof pw_array */ static inline bool pw_array_ensure_size(struct pw_array *arr, size_t size) { diff --git a/src/pipewire/client.c b/src/pipewire/client.c index 45c82d1c5..a33824f50 100644 --- a/src/pipewire/client.c +++ b/src/pipewire/client.c @@ -192,7 +192,6 @@ struct pw_client *pw_client_new(struct pw_core *core, spa_hook_list_init(&this->listener_list); pw_map_init(&this->objects, 0, 32); - pw_map_init(&this->types, 0, 32); pw_core_add_listener(core, &impl->core_listener, &core_events, impl); @@ -320,7 +319,6 @@ void pw_client_destroy(struct pw_client *client) pw_log_debug("client %p: free", impl); pw_map_clear(&client->objects); - pw_map_clear(&client->types); pw_array_clear(&impl->permissions); if (client->properties) diff --git a/src/pipewire/core.c b/src/pipewire/core.c index 4fc398c0a..7e6ab70ff 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -140,8 +140,6 @@ static void core_hello(void *object) struct pw_core *this = resource->core; pw_log_debug("core %p: hello from source %p", this, resource); - resource->client->n_types = 0; - this->info.change_mask = PW_CORE_CHANGE_MASK_ALL; pw_core_resource_info(resource, &this->info); } diff --git a/src/pipewire/map.h b/src/pipewire/map.h index 4419383d4..58d0f4d50 100644 --- a/src/pipewire/map.h +++ b/src/pipewire/map.h @@ -83,6 +83,12 @@ static inline void pw_map_clear(struct pw_map *map) pw_array_clear(&map->items); } +static inline void pw_map_reset(struct pw_map *map) +{ + pw_array_reset(&map->items); + map->free_list = SPA_ID_INVALID; +} + /** Insert data in the map * \param map the map to insert into * \param data the item to add diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 2a9d043d4..750f61a86 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -105,8 +105,6 @@ struct pw_client { struct pw_resource *core_resource; /**< core resource object */ struct pw_map objects; /**< list of resource objects */ - uint32_t n_types; /**< number of client types */ - struct pw_map types; /**< map of client types */ struct spa_list resource_list; /**< The list of resources of this client */ @@ -540,9 +538,6 @@ struct pw_remote { * indexed with the client id */ struct pw_core_info *info; /**< info about the remote core */ - uint32_t n_types; /**< number of client types */ - struct pw_map types; /**< client types */ - struct spa_list proxy_list; /**< list of \ref pw_proxy objects */ struct spa_list stream_list; /**< list of \ref pw_stream objects */ struct spa_list remote_node_list; /**< list of \ref pw_remote_node objects */ diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c index 20bfdd761..a620c577c 100644 --- a/src/pipewire/remote.c +++ b/src/pipewire/remote.c @@ -245,7 +245,6 @@ struct pw_remote *pw_remote_new(struct pw_core *core, this->state = PW_REMOTE_STATE_UNCONNECTED; pw_map_init(&this->objects, 64, 32); - pw_map_init(&this->types, 64, 32); spa_list_init(&this->proxy_list); spa_list_init(&this->stream_list); @@ -310,7 +309,6 @@ void pw_remote_destroy(struct pw_remote *remote) spa_list_remove(&remote->link); pw_map_clear(&remote->objects); - pw_map_clear(&remote->types); if (remote->properties) pw_properties_free(remote->properties); @@ -463,21 +461,19 @@ int pw_remote_disconnect(struct pw_remote *remote) pw_protocol_client_disconnect (remote->conn); - spa_list_consume(proxy, &remote->proxy_list, link) - pw_proxy_destroy(proxy); remote->core_proxy = NULL; - pw_map_clear(&remote->objects); - pw_map_init(&remote->objects, 64, 32); - pw_map_clear(&remote->types); - pw_map_init(&remote->types, 64, 32); - remote->n_types = 0; + pw_remote_update_state(remote, PW_REMOTE_STATE_UNCONNECTED, NULL); + + spa_list_consume(proxy, &remote->proxy_list, link) + pw_proxy_destroy(proxy); + + pw_map_reset(&remote->objects); if (remote->info) { pw_core_info_free (remote->info); remote->info = NULL; } - pw_remote_update_state(remote, PW_REMOTE_STATE_UNCONNECTED, NULL); return 0; }