Registry: implement registry

Make GET_REGISTRY method to create a registry resource, send global
added and removed to this resource.
Use map for storing proxies and resources.
This commit is contained in:
Wim Taymans 2016-11-30 19:09:09 +01:00
parent 3dada4731c
commit 7c29209023
15 changed files with 221 additions and 59 deletions

View file

@ -710,10 +710,16 @@ pinos_connection_parse_message (PinosConnection *conn,
memcpy (message, conn->in.data, sizeof (PinosMessageNotifyDone)); memcpy (message, conn->in.data, sizeof (PinosMessageNotifyDone));
break; break;
case PINOS_MESSAGE_SUBSCRIBE: case PINOS_MESSAGE_GET_REGISTRY:
if (conn->in.size < sizeof (PinosMessageSubscribe)) if (conn->in.size < sizeof (PinosMessageGetRegistry))
return false; return false;
memcpy (message, conn->in.data, sizeof (PinosMessageSubscribe)); memcpy (message, conn->in.data, sizeof (PinosMessageGetRegistry));
break;
case PINOS_MESSAGE_BIND:
if (conn->in.size < sizeof (PinosMessageBind))
return false;
memcpy (message, conn->in.data, sizeof (PinosMessageBind));
break; break;
case PINOS_MESSAGE_NOTIFY_GLOBAL: case PINOS_MESSAGE_NOTIFY_GLOBAL:
@ -749,6 +755,17 @@ pinos_connection_parse_message (PinosConnection *conn,
d->datafd = connection_get_fd (conn, d->datafd); d->datafd = connection_get_fd (conn, d->datafd);
break; break;
} }
case PINOS_MESSAGE_DESTROY:
if (conn->in.size < sizeof (PinosMessageDestroy))
return false;
memcpy (message, conn->in.data, sizeof (PinosMessageDestroy));
break;
case PINOS_MESSAGE_DESTROY_DONE:
if (conn->in.size < sizeof (PinosMessageDestroyDone))
return false;
memcpy (message, conn->in.data, sizeof (PinosMessageDestroyDone));
break;
/* C -> S */ /* C -> S */
case PINOS_MESSAGE_NODE_UPDATE: case PINOS_MESSAGE_NODE_UPDATE:
@ -865,9 +882,14 @@ pinos_connection_add_message (PinosConnection *conn,
memcpy (p, message, sizeof (PinosMessageNotifyDone)); memcpy (p, message, sizeof (PinosMessageNotifyDone));
break; break;
case PINOS_MESSAGE_SUBSCRIBE: case PINOS_MESSAGE_GET_REGISTRY:
p = connection_add_message (conn, dest_id, type, sizeof (PinosMessageSubscribe)); p = connection_add_message (conn, dest_id, type, sizeof (PinosMessageGetRegistry));
memcpy (p, message, sizeof (PinosMessageSubscribe)); memcpy (p, message, sizeof (PinosMessageGetRegistry));
break;
case PINOS_MESSAGE_BIND:
p = connection_add_message (conn, dest_id, type, sizeof (PinosMessageBind));
memcpy (p, message, sizeof (PinosMessageBind));
break; break;
case PINOS_MESSAGE_NOTIFY_GLOBAL: case PINOS_MESSAGE_NOTIFY_GLOBAL:
@ -900,6 +922,16 @@ pinos_connection_add_message (PinosConnection *conn,
d->datafd = connection_add_fd (conn, d->datafd); d->datafd = connection_add_fd (conn, d->datafd);
break; break;
} }
case PINOS_MESSAGE_DESTROY:
p = connection_add_message (conn, dest_id, type, sizeof (PinosMessageDestroy));
memcpy (p, message, sizeof (PinosMessageDestroy));
break;
case PINOS_MESSAGE_DESTROY_DONE:
p = connection_add_message (conn, dest_id, type, sizeof (PinosMessageDestroyDone));
memcpy (p, message, sizeof (PinosMessageDestroyDone));
break;
/* C -> S */ /* C -> S */
case PINOS_MESSAGE_NODE_UPDATE: case PINOS_MESSAGE_NODE_UPDATE:

View file

@ -37,8 +37,9 @@ typedef enum {
PINOS_MESSAGE_SYNC, PINOS_MESSAGE_SYNC,
PINOS_MESSAGE_NOTIFY_DONE, PINOS_MESSAGE_NOTIFY_DONE,
PINOS_MESSAGE_GET_REGISTRY,
PINOS_MESSAGE_SUBSCRIBE, PINOS_MESSAGE_BIND,
PINOS_MESSAGE_NOTIFY_GLOBAL, PINOS_MESSAGE_NOTIFY_GLOBAL,
PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE, PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE,
@ -48,6 +49,9 @@ typedef enum {
PINOS_MESSAGE_CREATE_CLIENT_NODE, PINOS_MESSAGE_CREATE_CLIENT_NODE,
PINOS_MESSAGE_CREATE_CLIENT_NODE_DONE, PINOS_MESSAGE_CREATE_CLIENT_NODE_DONE,
PINOS_MESSAGE_DESTROY,
PINOS_MESSAGE_DESTROY_DONE,
/* client to server */ /* client to server */
PINOS_MESSAGE_NODE_UPDATE, PINOS_MESSAGE_NODE_UPDATE,
PINOS_MESSAGE_PORT_UPDATE, PINOS_MESSAGE_PORT_UPDATE,
@ -84,10 +88,17 @@ typedef struct {
uint32_t seq; uint32_t seq;
} PinosMessageNotifyDone; } PinosMessageNotifyDone;
/* PINOS_MESSAGE_SUBSCRIBE */ /* PINOS_MESSAGE_GET_REGISTRY */
typedef struct { typedef struct {
uint32_t seq; uint32_t seq;
} PinosMessageSubscribe; uint32_t new_id;
} PinosMessageGetRegistry;
/* PINOS_MESSAGE_BIND */
typedef struct {
uint32_t id;
uint32_t new_id;
} PinosMessageBind;
/* PINOS_MESSAGE_NOTIFY_GLOBAL */ /* PINOS_MESSAGE_NOTIFY_GLOBAL */
typedef struct { typedef struct {
@ -106,7 +117,7 @@ typedef struct {
const char *factory_name; const char *factory_name;
const char *name; const char *name;
SpaDict *props; SpaDict *props;
uint32_t id; uint32_t new_id;
} PinosMessageCreateNode; } PinosMessageCreateNode;
/* PINOS_MESSAGE_CREATE_NODE_DONE */ /* PINOS_MESSAGE_CREATE_NODE_DONE */
@ -119,7 +130,7 @@ typedef struct {
uint32_t seq; uint32_t seq;
const char *name; const char *name;
SpaDict *props; SpaDict *props;
uint32_t id; uint32_t new_id;
} PinosMessageCreateClientNode; } PinosMessageCreateClientNode;
/* PINOS_MESSAGE_CREATE_CLIENT_NODE_DONE */ /* PINOS_MESSAGE_CREATE_CLIENT_NODE_DONE */
@ -128,6 +139,18 @@ typedef struct {
int datafd; int datafd;
} PinosMessageCreateClientNodeDone; } PinosMessageCreateClientNodeDone;
/* PINOS_MESSAGE_DESTROY */
typedef struct {
uint32_t seq;
uint32_t id;
} PinosMessageDestroy;
/* PINOS_MESSAGE_DESTROY_DONE */
typedef struct {
uint32_t seq;
uint32_t id;
} PinosMessageDestroyDone;
/* PINOS_MESSAGE_NODE_UPDATE */ /* PINOS_MESSAGE_NODE_UPDATE */
typedef struct { typedef struct {
#define PINOS_MESSAGE_NODE_UPDATE_MAX_INPUTS (1 << 0) #define PINOS_MESSAGE_NODE_UPDATE_MAX_INPUTS (1 << 0)

View file

@ -113,12 +113,32 @@ core_dispatch_func (void *object,
context_set_state (context, PINOS_CONTEXT_STATE_CONNECTED, NULL); context_set_state (context, PINOS_CONTEXT_STATE_CONNECTED, NULL);
break; break;
} }
default:
pinos_log_warn ("unhandled message %d", type);
break;
}
return SPA_RESULT_OK;
}
static SpaResult
registry_dispatch_func (void *object,
PinosMessageType type,
void *message,
void *data)
{
switch (type) {
case PINOS_MESSAGE_NOTIFY_GLOBAL: case PINOS_MESSAGE_NOTIFY_GLOBAL:
{ {
PinosMessageNotifyGlobal *ng = message; PinosMessageNotifyGlobal *ng = message;
pinos_log_debug ("got global %u %s", ng->id, ng->type); pinos_log_debug ("got global %u %s", ng->id, ng->type);
break; break;
} }
case PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE:
{
PinosMessageNotifyGlobalRemove *ng = message;
pinos_log_debug ("got global remove %u", ng->id);
break;
}
default: default:
pinos_log_warn ("unhandled message %d", type); pinos_log_warn ("unhandled message %d", type);
break; break;
@ -292,7 +312,7 @@ pinos_context_connect (PinosContext *context)
socklen_t size; socklen_t size;
const char *runtime_dir, *name = NULL; const char *runtime_dir, *name = NULL;
int name_size, fd; int name_size, fd;
PinosMessageSubscribe sm; PinosMessageGetRegistry grm;
context_set_state (context, PINOS_CONTEXT_STATE_CONNECTING, NULL); context_set_state (context, PINOS_CONTEXT_STATE_CONNECTING, NULL);
@ -349,10 +369,17 @@ pinos_context_connect (PinosContext *context)
context->core_proxy->dispatch_func = core_dispatch_func; context->core_proxy->dispatch_func = core_dispatch_func;
context->core_proxy->dispatch_data = context; context->core_proxy->dispatch_data = context;
sm.seq = 0; context->registry_proxy = pinos_proxy_new (context,
SPA_ID_INVALID,
0);
context->registry_proxy->dispatch_func = registry_dispatch_func;
context->registry_proxy->dispatch_data = context;
grm.seq = 0;
grm.new_id = context->registry_proxy->id;
pinos_proxy_send_message (context->core_proxy, pinos_proxy_send_message (context->core_proxy,
PINOS_MESSAGE_SUBSCRIBE, PINOS_MESSAGE_GET_REGISTRY,
&sm, &grm,
true); true);
return true; return true;
} }

View file

@ -63,6 +63,7 @@ struct _PinosContext {
PinosLoop *loop; PinosLoop *loop;
PinosProxy *core_proxy; PinosProxy *core_proxy;
PinosProxy *registry_proxy;
PinosMap objects; PinosMap objects;

View file

@ -45,7 +45,8 @@ struct _PinosMap {
#define pinos_map_get_size(m) pinos_array_get_len (&(m)->items, PinosMapItem) #define pinos_map_get_size(m) pinos_array_get_len (&(m)->items, PinosMapItem)
#define pinos_map_get_item(m,id) pinos_array_get_unchecked(&(m)->items,id,PinosMapItem) #define pinos_map_get_item(m,id) pinos_array_get_unchecked(&(m)->items,id,PinosMapItem)
#define pinos_map_item_is_free(m,id) (pinos_map_get_item(m,id)->next & 0x1) #define pinos_map_item_is_free(item) ((item)->next & 0x1)
#define pinos_map_id_is_free(m,id) (pinos_map_item_is_free (pinos_map_get_item(m,id)))
#define pinos_map_check_id(m,id) ((id) < pinos_map_get_size (m)) #define pinos_map_check_id(m,id) ((id) < pinos_map_get_size (m))
#define pinos_map_has_item(m,id) (pinos_map_check_id(m,id) && !pinos_map_item_is_free(m, id)) #define pinos_map_has_item(m,id) (pinos_map_check_id(m,id) && !pinos_map_item_is_free(m, id))
#define pinos_map_lookup_unchecked(m,id) pinos_map_get_item(m,id)->data #define pinos_map_lookup_unchecked(m,id) pinos_map_get_item(m,id)->data
@ -104,6 +105,19 @@ pinos_map_lookup (PinosMap *map,
return NULL; return NULL;
} }
static inline void
pinos_map_for_each (PinosMap *map,
void (*func) (void *, void *),
void *data)
{
PinosMapItem *item;
pinos_array_for_each (item, &map->items) {
if (!pinos_map_item_is_free (item))
func (item->data, data);
}
}
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif

View file

@ -607,7 +607,10 @@ stream_dispatch_func (void *object,
switch (type) { switch (type) {
case PINOS_MESSAGE_SYNC: case PINOS_MESSAGE_SYNC:
case PINOS_MESSAGE_SUBSCRIBE: case PINOS_MESSAGE_GET_REGISTRY:
case PINOS_MESSAGE_BIND:
case PINOS_MESSAGE_DESTROY:
case PINOS_MESSAGE_DESTROY_DONE:
case PINOS_MESSAGE_CREATE_NODE: case PINOS_MESSAGE_CREATE_NODE:
case PINOS_MESSAGE_CREATE_CLIENT_NODE: case PINOS_MESSAGE_CREATE_CLIENT_NODE:
case PINOS_MESSAGE_NODE_UPDATE: case PINOS_MESSAGE_NODE_UPDATE:
@ -899,7 +902,7 @@ pinos_stream_connect (PinosStream *stream,
items[0].key = "pinos.target.node"; items[0].key = "pinos.target.node";
items[0].value = port_path; items[0].value = port_path;
ccn.props = &dict; ccn.props = &dict;
ccn.id = impl->node_proxy->id; ccn.new_id = impl->node_proxy->id;
pinos_proxy_send_message (stream->context->core_proxy, pinos_proxy_send_message (stream->context->core_proxy,
PINOS_MESSAGE_CREATE_CLIENT_NODE, PINOS_MESSAGE_CREATE_CLIENT_NODE,

View file

@ -171,6 +171,29 @@ client_destroy (PinosProtocolNativeClient *this)
close (this->fd); close (this->fd);
} }
static void
destroy_registry_resource (void *object)
{
PinosResource *resource = object;
spa_list_remove (&resource->link);
}
static SpaResult
registry_dispatch_func (void *object,
PinosMessageType type,
void *message,
void *data)
{
switch (type) {
case PINOS_MESSAGE_BIND:
break;
default:
pinos_log_error ("unhandled message %d", type);
break;
}
return SPA_RESULT_OK;
}
static SpaResult static SpaResult
core_dispatch_func (void *object, core_dispatch_func (void *object,
PinosMessageType type, PinosMessageType type,
@ -182,18 +205,30 @@ core_dispatch_func (void *object,
PinosClient *c = client->parent.global->object; PinosClient *c = client->parent.global->object;
switch (type) { switch (type) {
case PINOS_MESSAGE_SUBSCRIBE: case PINOS_MESSAGE_GET_REGISTRY:
{ {
PinosMessageSubscribe *m = message; PinosMessageGetRegistry *m = message;
PinosGlobal *global; PinosGlobal *global;
PinosMessageNotifyDone nd; PinosMessageNotifyDone nd;
PinosResource *registry_resource;
registry_resource = pinos_resource_new (c,
SPA_ID_INVALID,
impl->core->uri.registry,
impl->core,
destroy_registry_resource);
registry_resource->dispatch_func = registry_dispatch_func;
registry_resource->dispatch_data = client;
spa_list_insert (impl->core->registry_resource_list.prev, &registry_resource->link);
spa_list_for_each (global, &impl->core->global_list, link) { spa_list_for_each (global, &impl->core->global_list, link) {
PinosMessageNotifyGlobal ng; PinosMessageNotifyGlobal ng;
ng.id = global->id; ng.id = global->id;
ng.type = spa_id_map_get_uri (impl->core->uri.map, global->type); ng.type = spa_id_map_get_uri (impl->core->uri.map, global->type);
pinos_resource_send_message (client->core_resource, pinos_resource_send_message (registry_resource,
PINOS_MESSAGE_NOTIFY_GLOBAL, PINOS_MESSAGE_NOTIFY_GLOBAL,
&ng, &ng,
false); false);
@ -221,7 +256,7 @@ core_dispatch_func (void *object,
} }
node = pinos_client_node_new (c, node = pinos_client_node_new (c,
m->id, m->new_id,
m->name, m->name,
props); props);
@ -267,18 +302,6 @@ client_send_func (void *object,
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
static PinosResource *
find_resource (PinosClient *client, uint32_t id)
{
PinosResource *resource;
spa_list_for_each (resource, &client->resource_list, link) {
if (resource->id == id)
return resource;
}
return NULL;
}
static void static void
connection_data (SpaSource *source, connection_data (SpaSource *source,
int fd, int fd,
@ -290,6 +313,7 @@ connection_data (SpaSource *source,
PinosMessageType type; PinosMessageType type;
uint32_t id; uint32_t id;
size_t size; size_t size;
PinosClient *c = client->parent.global->object;
if (mask & (SPA_IO_ERR | SPA_IO_HUP)) { if (mask & (SPA_IO_ERR | SPA_IO_HUP)) {
pinos_log_debug ("protocol-native %p: got connection error", client->parent.impl); pinos_log_debug ("protocol-native %p: got connection error", client->parent.impl);
@ -311,7 +335,7 @@ connection_data (SpaSource *source,
continue; continue;
} }
resource = find_resource (client->parent.global->object, id); resource = pinos_map_lookup (&c->objects, id);
if (resource == NULL) { if (resource == NULL) {
pinos_log_error ("protocol-native %p: unknown resource %u", client->parent.impl, id); pinos_log_error ("protocol-native %p: unknown resource %u", client->parent.impl, id);
continue; continue;
@ -376,6 +400,8 @@ on_global_added (PinosListener *listener,
PinosGlobal *global) PinosGlobal *global)
{ {
PinosProtocolNative *impl = SPA_CONTAINER_OF (listener, PinosProtocolNative, global_added); PinosProtocolNative *impl = SPA_CONTAINER_OF (listener, PinosProtocolNative, global_added);
PinosMessageNotifyGlobal ng;
PinosResource *registry;
if (global->type == impl->core->uri.client) { if (global->type == impl->core->uri.client) {
object_new (sizeof (PinosProtocolNativeClient), object_new (sizeof (PinosProtocolNativeClient),
@ -389,6 +415,16 @@ on_global_added (PinosListener *listener,
NULL); NULL);
} else if (global->type == impl->core->uri.link) { } else if (global->type == impl->core->uri.link) {
} }
ng.id = global->id;
ng.type = spa_id_map_get_uri (impl->core->uri.map, global->type);
spa_list_for_each (registry, &core->registry_resource_list, link) {
pinos_resource_send_message (registry,
PINOS_MESSAGE_NOTIFY_GLOBAL,
&ng,
true);
}
} }
static void static void
@ -398,10 +434,20 @@ on_global_removed (PinosListener *listener,
{ {
PinosProtocolNative *impl = SPA_CONTAINER_OF (listener, PinosProtocolNative, global_removed); PinosProtocolNative *impl = SPA_CONTAINER_OF (listener, PinosProtocolNative, global_removed);
PinosProtocolNativeObject *object; PinosProtocolNativeObject *object;
PinosMessageNotifyGlobalRemove ng;
PinosResource *registry;
if ((object = find_object (impl, global->object))) { if ((object = find_object (impl, global->object))) {
object_destroy (object); object_destroy (object);
} }
ng.id = global->id;
spa_list_for_each (registry, &core->registry_resource_list, link) {
pinos_resource_send_message (registry,
PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE,
&ng,
true);
}
} }
static Socket * static Socket *

View file

@ -1208,6 +1208,12 @@ proxy_clear (SpaProxy *this)
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
static void
client_node_resource_destroy (PinosResource *resource)
{
pinos_client_node_destroy (resource->object);
}
/** /**
* pinos_client_node_new: * pinos_client_node_new:
* @daemon: a #PinosDaemon * @daemon: a #PinosDaemon
@ -1257,7 +1263,7 @@ pinos_client_node_new (PinosClient *client,
id, id,
client->core->uri.client_node, client->core->uri.client_node,
this, this,
(PinosDestroy) pinos_client_node_destroy); (PinosDestroy) client_node_resource_destroy);
impl->proxy.resource = this->resource; impl->proxy.resource = this->resource;
this->resource->dispatch_func = client_node_dispatch_func; this->resource->dispatch_func = client_node_dispatch_func;

View file

@ -51,7 +51,7 @@ pinos_client_new (PinosCore *core,
this->core = core; this->core = core;
this->properties = properties; this->properties = properties;
spa_list_init (&this->resource_list); pinos_map_init (&this->objects, 64);
pinos_signal_init (&this->destroy_signal); pinos_signal_init (&this->destroy_signal);
spa_list_insert (core->client_list.prev, &this->link); spa_list_insert (core->client_list.prev, &this->link);
@ -80,6 +80,13 @@ sync_destroy (void *object,
free (impl); free (impl);
} }
static void
destroy_resource (void *object,
void *data)
{
pinos_resource_destroy (object);
}
/** /**
* pinos_client_destroy: * pinos_client_destroy:
* @client: a #PinosClient * @client: a #PinosClient
@ -89,13 +96,10 @@ sync_destroy (void *object,
void void
pinos_client_destroy (PinosClient * client) pinos_client_destroy (PinosClient * client)
{ {
PinosResource *resource, *tmp;
pinos_log_debug ("client %p: destroy", client); pinos_log_debug ("client %p: destroy", client);
pinos_signal_emit (&client->destroy_signal, client); pinos_signal_emit (&client->destroy_signal, client);
spa_list_for_each_safe (resource, tmp, &client->resource_list, link) pinos_map_for_each (&client->objects, destroy_resource, client);
pinos_resource_destroy (resource);
pinos_global_destroy (client->global); pinos_global_destroy (client->global);
spa_list_remove (&client->link); spa_list_remove (&client->link);

View file

@ -44,7 +44,7 @@ struct _PinosClient {
PinosProperties *properties; PinosProperties *properties;
SpaList resource_list; PinosMap objects;
PinosSendFunc send_func; PinosSendFunc send_func;
void *send_data; void *send_data;

View file

@ -56,6 +56,7 @@ pinos_core_new (PinosMainLoop *main_loop)
pinos_data_loop_start (this->data_loop); pinos_data_loop_start (this->data_loop);
spa_list_init (&this->registry_resource_list);
spa_list_init (&this->global_list); spa_list_init (&this->global_list);
spa_list_init (&this->client_list); spa_list_init (&this->client_list);
spa_list_init (&this->node_list); spa_list_init (&this->node_list);
@ -111,6 +112,8 @@ pinos_core_add_global (PinosCore *core,
spa_list_insert (core->global_list.prev, &global->link); spa_list_insert (core->global_list.prev, &global->link);
pinos_signal_emit (&core->global_added, core, global); pinos_signal_emit (&core->global_added, core, global);
pinos_log_debug ("global %p: new %u", global, global->id);
return global; return global;
} }

View file

@ -29,6 +29,7 @@ typedef struct _PinosGlobal PinosGlobal;
#define PINOS_CORE_URI "http://pinos.org/ns/core" #define PINOS_CORE_URI "http://pinos.org/ns/core"
#define PINOS_CORE_PREFIX PINOS_CORE_URI "#" #define PINOS_CORE_PREFIX PINOS_CORE_URI "#"
#define PINOS_CORE_REGISTRY PINOS_CORE_PREFIX "Registry"
#include <spa/include/spa/log.h> #include <spa/include/spa/log.h>
@ -62,6 +63,7 @@ struct _PinosCore {
PinosMap objects; PinosMap objects;
SpaList registry_resource_list;
SpaList global_list; SpaList global_list;
SpaList client_list; SpaList client_list;
SpaList node_list; SpaList node_list;

View file

@ -28,26 +28,25 @@ pinos_resource_new (PinosClient *client,
void *object, void *object,
PinosDestroy destroy) PinosDestroy destroy)
{ {
PinosResource *resource; PinosResource *this;
resource = calloc (1, sizeof (PinosResource)); this = calloc (1, sizeof (PinosResource));
pinos_log_debug ("resource %p: new for client %p", resource, client); this->core = client->core;
this->client = client;
this->id = id;
this->type = type;
this->object = object;
this->destroy = destroy;
resource->core = client->core; this->send_func = client->send_func;
resource->client = client; this->send_data = client->send_data;
resource->id = id;
resource->type = type;
resource->object = object;
resource->destroy = destroy;
resource->send_func = client->send_func; pinos_signal_init (&this->destroy_signal);
resource->send_data = client->send_data;
pinos_signal_init (&resource->destroy_signal); this->id = pinos_map_insert_new (&client->objects, this);
pinos_log_debug ("resource %p: new for client %p id %u", this, client, this->id);
spa_list_insert (client->resource_list.prev, &resource->link); return this;
return resource;
} }
static void static void
@ -67,10 +66,10 @@ pinos_resource_destroy (PinosResource *resource)
pinos_log_debug ("resource %p: destroy", resource); pinos_log_debug ("resource %p: destroy", resource);
pinos_signal_emit (&resource->destroy_signal, resource); pinos_signal_emit (&resource->destroy_signal, resource);
spa_list_remove (&resource->link); pinos_map_remove (&resource->client->objects, resource->id);
if (resource->destroy) if (resource->destroy)
resource->destroy (resource->object); resource->destroy (resource);
pinos_main_loop_defer (resource->core->main_loop, pinos_main_loop_defer (resource->core->main_loop,
resource, resource,

View file

@ -36,6 +36,7 @@ pinos_uri_init (PinosURI *uri)
uri->map = pinos_id_map_get_default(); uri->map = pinos_id_map_get_default();
uri->core = spa_id_map_get_id (uri->map, PINOS_CORE_URI); uri->core = spa_id_map_get_id (uri->map, PINOS_CORE_URI);
uri->registry = spa_id_map_get_id (uri->map, PINOS_CORE_REGISTRY);
uri->node = spa_id_map_get_id (uri->map, PINOS_NODE_URI); uri->node = spa_id_map_get_id (uri->map, PINOS_NODE_URI);
uri->node_factory = spa_id_map_get_id (uri->map, PINOS_NODE_FACTORY_URI); uri->node_factory = spa_id_map_get_id (uri->map, PINOS_NODE_FACTORY_URI);
uri->link = spa_id_map_get_id (uri->map, PINOS_LINK_URI); uri->link = spa_id_map_get_id (uri->map, PINOS_LINK_URI);

View file

@ -41,6 +41,7 @@ struct _PinosURI {
SpaIDMap *map; SpaIDMap *map;
uint32_t core; uint32_t core;
uint32_t registry;
uint32_t node; uint32_t node;
uint32_t node_factory; uint32_t node_factory;
uint32_t link; uint32_t link;