mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
Use mapper to make object id
Reuse object ids by using a mapper Simpify the uri struct a little.
This commit is contained in:
parent
f42268b9a5
commit
e7cae649aa
14 changed files with 61 additions and 64 deletions
|
|
@ -99,7 +99,7 @@ pinos_client_new (PinosCore *core,
|
|||
spa_list_insert (core->client_list.prev, &this->link);
|
||||
|
||||
this->global = pinos_core_add_global (core,
|
||||
core->registry.uri.client,
|
||||
core->uri.client,
|
||||
this);
|
||||
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@
|
|||
typedef struct {
|
||||
PinosCore this;
|
||||
|
||||
uint32_t counter;
|
||||
|
||||
SpaSupport support[4];
|
||||
|
||||
} PinosCoreImpl;
|
||||
|
|
@ -38,13 +36,15 @@ pinos_core_new (PinosMainLoop *main_loop)
|
|||
|
||||
impl = calloc (1, sizeof (PinosCoreImpl));
|
||||
this = &impl->this;
|
||||
pinos_registry_init (&this->registry);
|
||||
pinos_uri_init (&this->uri);
|
||||
|
||||
pinos_map_init (&this->objects, 512);
|
||||
|
||||
this->data_loop = pinos_data_loop_new ();
|
||||
this->main_loop = main_loop;
|
||||
|
||||
impl->support[0].uri = SPA_ID_MAP_URI;
|
||||
impl->support[0].data = this->registry.map;
|
||||
impl->support[0].data = this->uri.map;
|
||||
impl->support[1].uri = SPA_LOG_URI;
|
||||
impl->support[1].data = pinos_log_get ();
|
||||
impl->support[2].uri = SPA_LOOP__DataLoop;
|
||||
|
|
@ -93,17 +93,17 @@ pinos_core_add_global (PinosCore *core,
|
|||
uint32_t type,
|
||||
void *object)
|
||||
{
|
||||
PinosCoreImpl *impl = SPA_CONTAINER_OF (core, PinosCoreImpl, this);
|
||||
PinosGlobal *global;
|
||||
|
||||
global = calloc (1, sizeof (PinosGlobal));
|
||||
global->core = core;
|
||||
global->id = ++impl->counter;
|
||||
global->type = type;
|
||||
global->object = object;
|
||||
|
||||
pinos_signal_init (&global->destroy_signal);
|
||||
|
||||
global->id = pinos_map_insert_new (&core->objects, global);
|
||||
|
||||
spa_list_insert (core->global_list.prev, &global->link);
|
||||
pinos_signal_emit (&core->global_added, core, global);
|
||||
|
||||
|
|
@ -117,6 +117,8 @@ pinos_global_destroy (PinosGlobal *global)
|
|||
|
||||
pinos_signal_emit (&global->destroy_signal, global);
|
||||
|
||||
pinos_map_remove (&core->objects, global->id);
|
||||
|
||||
spa_list_remove (&global->link);
|
||||
pinos_signal_emit (&core->global_removed, core, global);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ typedef struct _PinosGlobal PinosGlobal;
|
|||
|
||||
#include <pinos/server/main-loop.h>
|
||||
#include <pinos/server/data-loop.h>
|
||||
#include <pinos/server/registry.h>
|
||||
#include <pinos/server/uri.h>
|
||||
#include <pinos/server/node.h>
|
||||
#include <pinos/server/link.h>
|
||||
|
||||
|
|
@ -52,7 +52,9 @@ struct _PinosGlobal {
|
|||
* Pinos core object class.
|
||||
*/
|
||||
struct _PinosCore {
|
||||
PinosRegistry registry;
|
||||
PinosURI uri;
|
||||
|
||||
PinosMap objects;
|
||||
|
||||
SpaList global_list;
|
||||
SpaList client_list;
|
||||
|
|
|
|||
|
|
@ -712,7 +712,7 @@ pinos_link_new (PinosCore *core,
|
|||
spa_list_insert (core->link_list.prev, &this->link);
|
||||
|
||||
this->global = pinos_core_add_global (core,
|
||||
core->registry.uri.link,
|
||||
core->uri.link,
|
||||
this);
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ pinoscore_headers = [
|
|||
'node.h',
|
||||
'node-factory.h',
|
||||
'port.h',
|
||||
'registry.h',
|
||||
'uri.h',
|
||||
]
|
||||
|
||||
pinoscore_sources = [
|
||||
|
|
@ -25,7 +25,7 @@ pinoscore_sources = [
|
|||
'node.c',
|
||||
'node-factory.c',
|
||||
'port.c',
|
||||
'registry.c',
|
||||
'uri.c',
|
||||
]
|
||||
|
||||
libpinoscore_c_args = [
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ pinos_node_new (PinosCore *core,
|
|||
spa_list_insert (core->node_list.prev, &this->link);
|
||||
|
||||
this->global = pinos_core_add_global (core,
|
||||
core->registry.uri.node,
|
||||
core->uri.node,
|
||||
this);
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "pinos/client/pinos.h"
|
||||
#include "pinos/server/core.h"
|
||||
#include "pinos/server/registry.h"
|
||||
#include "pinos/server/uri.h"
|
||||
#include "pinos/server/node.h"
|
||||
#include "pinos/server/node-factory.h"
|
||||
#include "pinos/server/client.h"
|
||||
|
|
@ -30,20 +30,18 @@
|
|||
#include "spa/include/spa/monitor.h"
|
||||
|
||||
void
|
||||
pinos_registry_init (PinosRegistry *reg)
|
||||
pinos_uri_init (PinosURI *uri)
|
||||
{
|
||||
reg->map = pinos_id_map_get_default();
|
||||
uri->map = pinos_id_map_get_default();
|
||||
|
||||
reg->uri.registry = spa_id_map_get_id (reg->map, PINOS_REGISTRY_URI);
|
||||
reg->uri.node = spa_id_map_get_id (reg->map, PINOS_NODE_URI);
|
||||
reg->uri.node_factory = spa_id_map_get_id (reg->map, PINOS_NODE_FACTORY_URI);
|
||||
reg->uri.link = spa_id_map_get_id (reg->map, PINOS_LINK_URI);
|
||||
reg->uri.client = spa_id_map_get_id (reg->map, PINOS_CLIENT_URI);
|
||||
reg->uri.client_node = spa_id_map_get_id (reg->map, PINOS_CLIENT_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->link = spa_id_map_get_id (uri->map, PINOS_LINK_URI);
|
||||
uri->client = spa_id_map_get_id (uri->map, PINOS_CLIENT_URI);
|
||||
uri->client_node = spa_id_map_get_id (uri->map, PINOS_CLIENT_NODE_URI);
|
||||
|
||||
reg->uri.spa_node = spa_id_map_get_id (reg->map, SPA_NODE_URI);
|
||||
reg->uri.spa_clock = spa_id_map_get_id (reg->map, SPA_CLOCK_URI);
|
||||
reg->uri.spa_monitor = spa_id_map_get_id (reg->map, SPA_MONITOR_URI);
|
||||
uri->spa_node = spa_id_map_get_id (uri->map, SPA_NODE_URI);
|
||||
uri->spa_clock = spa_id_map_get_id (uri->map, SPA_CLOCK_URI);
|
||||
uri->spa_monitor = spa_id_map_get_id (uri->map, SPA_MONITOR_URI);
|
||||
|
||||
pinos_map_init (®->objects, 512);
|
||||
}
|
||||
|
|
@ -17,24 +17,29 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PINOS_REGISTRY_H__
|
||||
#define __PINOS_REGISTRY_H__
|
||||
#ifndef __PINOS_URI_H__
|
||||
#define __PINOS_URI_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PINOS_REGISTRY_URI "http://pinos.org/ns/registry"
|
||||
#define PINOS_REGISTRY_PREFIX PINOS_REGISTRY_URI "#"
|
||||
#define PINOS_URI_URI "http://pinos.org/ns/uri"
|
||||
#define PINOS_URI_PREFIX PINOS_URI_URI "#"
|
||||
|
||||
#include <pinos/client/map.h>
|
||||
#include <pinos/client/signal.h>
|
||||
#include <spa/include/spa/id-map.h>
|
||||
|
||||
typedef struct _PinosRegistry PinosRegistry;
|
||||
typedef struct _PinosURI PinosURI;
|
||||
|
||||
/**
|
||||
* PinosURI:
|
||||
*
|
||||
* Pinos URI support struct.
|
||||
*/
|
||||
struct _PinosURI {
|
||||
SpaIDMap *map;
|
||||
|
||||
typedef struct {
|
||||
uint32_t registry;
|
||||
uint32_t node;
|
||||
uint32_t node_factory;
|
||||
uint32_t link;
|
||||
|
|
@ -44,23 +49,12 @@ typedef struct {
|
|||
uint32_t spa_node;
|
||||
uint32_t spa_clock;
|
||||
uint32_t spa_monitor;
|
||||
} PinosURI;
|
||||
|
||||
/**
|
||||
* PinosRegistry:
|
||||
*
|
||||
* Pinos registry struct.
|
||||
*/
|
||||
struct _PinosRegistry {
|
||||
SpaIDMap *map;
|
||||
PinosURI uri;
|
||||
PinosMap objects;
|
||||
};
|
||||
|
||||
void pinos_registry_init (PinosRegistry *reg);
|
||||
void pinos_uri_init (PinosURI *uri);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PINOS_REGISTRY_H__ */
|
||||
#endif /* __PINOS_URI_H__ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue