remove unused type map

Add reset methods for array and map
Signal disconnect before destroying the proxies in remote.
This commit is contained in:
Wim Taymans 2018-09-26 13:11:23 +02:00
parent 04f8da9110
commit d4fa4e63e8
6 changed files with 18 additions and 19 deletions

View file

@ -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)
{

View file

@ -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)

View file

@ -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);
}

View file

@ -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

View file

@ -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 */

View file

@ -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;
}