mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
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:
parent
3dada4731c
commit
7c29209023
15 changed files with 221 additions and 59 deletions
|
|
@ -1208,6 +1208,12 @@ proxy_clear (SpaProxy *this)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
client_node_resource_destroy (PinosResource *resource)
|
||||
{
|
||||
pinos_client_node_destroy (resource->object);
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_client_node_new:
|
||||
* @daemon: a #PinosDaemon
|
||||
|
|
@ -1257,7 +1263,7 @@ pinos_client_node_new (PinosClient *client,
|
|||
id,
|
||||
client->core->uri.client_node,
|
||||
this,
|
||||
(PinosDestroy) pinos_client_node_destroy);
|
||||
(PinosDestroy) client_node_resource_destroy);
|
||||
impl->proxy.resource = this->resource;
|
||||
|
||||
this->resource->dispatch_func = client_node_dispatch_func;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ pinos_client_new (PinosCore *core,
|
|||
this->core = core;
|
||||
this->properties = properties;
|
||||
|
||||
spa_list_init (&this->resource_list);
|
||||
pinos_map_init (&this->objects, 64);
|
||||
pinos_signal_init (&this->destroy_signal);
|
||||
|
||||
spa_list_insert (core->client_list.prev, &this->link);
|
||||
|
|
@ -80,6 +80,13 @@ sync_destroy (void *object,
|
|||
free (impl);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_resource (void *object,
|
||||
void *data)
|
||||
{
|
||||
pinos_resource_destroy (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_client_destroy:
|
||||
* @client: a #PinosClient
|
||||
|
|
@ -89,13 +96,10 @@ sync_destroy (void *object,
|
|||
void
|
||||
pinos_client_destroy (PinosClient * client)
|
||||
{
|
||||
PinosResource *resource, *tmp;
|
||||
|
||||
pinos_log_debug ("client %p: destroy", client);
|
||||
pinos_signal_emit (&client->destroy_signal, client);
|
||||
|
||||
spa_list_for_each_safe (resource, tmp, &client->resource_list, link)
|
||||
pinos_resource_destroy (resource);
|
||||
pinos_map_for_each (&client->objects, destroy_resource, client);
|
||||
|
||||
pinos_global_destroy (client->global);
|
||||
spa_list_remove (&client->link);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ struct _PinosClient {
|
|||
|
||||
PinosProperties *properties;
|
||||
|
||||
SpaList resource_list;
|
||||
PinosMap objects;
|
||||
|
||||
PinosSendFunc send_func;
|
||||
void *send_data;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ pinos_core_new (PinosMainLoop *main_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->client_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);
|
||||
pinos_signal_emit (&core->global_added, core, global);
|
||||
|
||||
pinos_log_debug ("global %p: new %u", global, global->id);
|
||||
|
||||
return global;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ typedef struct _PinosGlobal PinosGlobal;
|
|||
|
||||
#define PINOS_CORE_URI "http://pinos.org/ns/core"
|
||||
#define PINOS_CORE_PREFIX PINOS_CORE_URI "#"
|
||||
#define PINOS_CORE_REGISTRY PINOS_CORE_PREFIX "Registry"
|
||||
|
||||
#include <spa/include/spa/log.h>
|
||||
|
||||
|
|
@ -62,6 +63,7 @@ struct _PinosCore {
|
|||
|
||||
PinosMap objects;
|
||||
|
||||
SpaList registry_resource_list;
|
||||
SpaList global_list;
|
||||
SpaList client_list;
|
||||
SpaList node_list;
|
||||
|
|
|
|||
|
|
@ -28,26 +28,25 @@ pinos_resource_new (PinosClient *client,
|
|||
void *object,
|
||||
PinosDestroy destroy)
|
||||
{
|
||||
PinosResource *resource;
|
||||
PinosResource *this;
|
||||
|
||||
resource = calloc (1, sizeof (PinosResource));
|
||||
pinos_log_debug ("resource %p: new for client %p", resource, client);
|
||||
this = calloc (1, sizeof (PinosResource));
|
||||
this->core = client->core;
|
||||
this->client = client;
|
||||
this->id = id;
|
||||
this->type = type;
|
||||
this->object = object;
|
||||
this->destroy = destroy;
|
||||
|
||||
resource->core = client->core;
|
||||
resource->client = client;
|
||||
resource->id = id;
|
||||
resource->type = type;
|
||||
resource->object = object;
|
||||
resource->destroy = destroy;
|
||||
this->send_func = client->send_func;
|
||||
this->send_data = client->send_data;
|
||||
|
||||
resource->send_func = client->send_func;
|
||||
resource->send_data = client->send_data;
|
||||
pinos_signal_init (&this->destroy_signal);
|
||||
|
||||
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 resource;
|
||||
return this;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -67,10 +66,10 @@ pinos_resource_destroy (PinosResource *resource)
|
|||
pinos_log_debug ("resource %p: destroy", resource);
|
||||
pinos_signal_emit (&resource->destroy_signal, resource);
|
||||
|
||||
spa_list_remove (&resource->link);
|
||||
pinos_map_remove (&resource->client->objects, resource->id);
|
||||
|
||||
if (resource->destroy)
|
||||
resource->destroy (resource->object);
|
||||
resource->destroy (resource);
|
||||
|
||||
pinos_main_loop_defer (resource->core->main_loop,
|
||||
resource,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ pinos_uri_init (PinosURI *uri)
|
|||
uri->map = pinos_id_map_get_default();
|
||||
|
||||
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_factory = spa_id_map_get_id (uri->map, PINOS_NODE_FACTORY_URI);
|
||||
uri->link = spa_id_map_get_id (uri->map, PINOS_LINK_URI);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ struct _PinosURI {
|
|||
SpaIDMap *map;
|
||||
|
||||
uint32_t core;
|
||||
uint32_t registry;
|
||||
uint32_t node;
|
||||
uint32_t node_factory;
|
||||
uint32_t link;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue