summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/Doxyfile.in2
-rw-r--r--src/extensions/client-node.h30
-rw-r--r--src/gst/gstpipewiredeviceprovider.c56
-rw-r--r--src/gst/gstpipewiredeviceprovider.h3
-rw-r--r--src/gst/gstpipewiresrc.c3
-rw-r--r--src/modules/module-client-node/protocol-native.c55
-rw-r--r--src/modules/module-flatpak.c30
-rw-r--r--src/modules/module-protocol-native.c8
-rw-r--r--src/modules/module-protocol-native/protocol-native.c215
-rw-r--r--src/pipewire/client.c31
-rw-r--r--src/pipewire/client.h3
-rw-r--r--src/pipewire/core.c171
-rw-r--r--src/pipewire/core.h51
-rw-r--r--src/pipewire/interfaces.h127
-rw-r--r--src/pipewire/introspect.c5
-rw-r--r--src/pipewire/introspect.h5
-rw-r--r--src/pipewire/link.c27
-rw-r--r--src/pipewire/link.h3
-rw-r--r--src/pipewire/module.c30
-rw-r--r--src/pipewire/module.h5
-rw-r--r--src/pipewire/node.c32
-rw-r--r--src/pipewire/node.h3
-rw-r--r--src/pipewire/protocol.c51
-rw-r--r--src/pipewire/protocol.h29
-rw-r--r--src/pipewire/proxy.c30
-rw-r--r--src/pipewire/proxy.h27
-rw-r--r--src/pipewire/remote.c22
-rw-r--r--src/pipewire/remote.h2
-rw-r--r--src/pipewire/resource.c15
-rw-r--r--src/pipewire/resource.h17
-rw-r--r--src/pipewire/stream.c26
-rw-r--r--src/pipewire/type.c10
-rw-r--r--src/pipewire/type.h35
-rw-r--r--src/tools/pipewire-monitor.c65
34 files changed, 644 insertions, 580 deletions
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
index ca0072a7..53038f7a 100644
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -780,7 +780,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
-INPUT = "@top_srcdir@/src/"
+INPUT = "@top_srcdir@/src/pipewire"
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
diff --git a/src/extensions/client-node.h b/src/extensions/client-node.h
index b238d1a3..2c7bed60 100644
--- a/src/extensions/client-node.h
+++ b/src/extensions/client-node.h
@@ -32,7 +32,7 @@ extern "C" {
#include <pipewire/proxy.h>
-typedef struct pw_proxy pw_client_node_proxy_t;
+struct pw_client_node_proxy { struct pw_proxy proxy; };
#define PW_TYPE_INTERFACE__ClientNode PW_TYPE_INTERFACE_BASE "ClientNode"
@@ -120,26 +120,26 @@ struct pw_client_node_methods {
};
static inline void
-pw_client_node_proxy_done(pw_client_node_proxy_t *p, int seq, int res)
+pw_client_node_proxy_done(struct pw_client_node_proxy *p, int seq, int res)
{
- pw_proxy_do(p, struct pw_client_node_methods, done, seq, res);
+ pw_proxy_do(&p->proxy, struct pw_client_node_methods, done, seq, res);
}
static inline void
-pw_client_node_proxy_update(pw_client_node_proxy_t *p,
+pw_client_node_proxy_update(struct pw_client_node_proxy *p,
uint32_t change_mask,
uint32_t max_input_ports,
uint32_t max_output_ports,
const struct spa_props *props)
{
- pw_proxy_do(p, struct pw_client_node_methods, update, change_mask,
+ pw_proxy_do(&p->proxy, struct pw_client_node_methods, update, change_mask,
max_input_ports,
max_output_ports,
props);
}
static inline void
-pw_client_node_proxy_port_update(pw_client_node_proxy_t *p,
+pw_client_node_proxy_port_update(struct pw_client_node_proxy *p,
enum spa_direction direction,
uint32_t port_id,
uint32_t change_mask,
@@ -150,7 +150,7 @@ pw_client_node_proxy_port_update(pw_client_node_proxy_t *p,
const struct spa_param **params,
const struct spa_port_info *info)
{
- pw_proxy_do(p, struct pw_client_node_methods, port_update, direction,
+ pw_proxy_do(&p->proxy, struct pw_client_node_methods, port_update, direction,
port_id,
change_mask,
n_possible_formats,
@@ -162,15 +162,15 @@ pw_client_node_proxy_port_update(pw_client_node_proxy_t *p,
}
static inline void
-pw_client_node_proxy_event(pw_client_node_proxy_t *p, struct spa_event *event)
+pw_client_node_proxy_event(struct pw_client_node_proxy *p, struct spa_event *event)
{
- pw_proxy_do(p, struct pw_client_node_methods, event, event);
+ pw_proxy_do(&p->proxy, struct pw_client_node_methods, event, event);
}
static inline void
-pw_client_node_proxy_destroy(pw_client_node_proxy_t *p)
+pw_client_node_proxy_destroy(struct pw_client_node_proxy *p)
{
- pw_proxy_do_na(p, struct pw_client_node_methods, destroy);
+ pw_proxy_do_na(&p->proxy, struct pw_client_node_methods, destroy);
}
@@ -338,10 +338,12 @@ struct pw_client_node_events {
};
static inline void
-pw_client_node_proxy_add_listener(pw_client_node_proxy_t *p, void *object,
- const struct pw_client_node_events *listener, pw_destroy_t destroy)
+pw_client_node_proxy_add_listener(struct pw_client_node_proxy *p,
+ struct pw_interface_listener *listener,
+ void *object,
+ const struct pw_client_node_events *events)
{
- pw_proxy_add_listener(p, object, listener, destroy);
+ pw_proxy_add_listener(&p->proxy, listener, object, events);
}
#define pw_client_node_resource_transport(r,...) pw_resource_notify(r,struct pw_client_node_events,transport,__VA_ARGS__)
diff --git a/src/gst/gstpipewiredeviceprovider.c b/src/gst/gstpipewiredeviceprovider.c
index 87ebbd86..4085634b 100644
--- a/src/gst/gstpipewiredeviceprovider.c
+++ b/src/gst/gstpipewiredeviceprovider.c
@@ -193,7 +193,7 @@ enum
};
static GstDevice *
-new_node (GstPipeWireDeviceProvider *self, const struct pw_node_info *info)
+new_node (GstPipeWireDeviceProvider *self, const struct pw_node_info *info, uint32_t id)
{
GstCaps *caps = NULL;
GstStructure *props;
@@ -234,7 +234,7 @@ new_node (GstPipeWireDeviceProvider *self, const struct pw_node_info *info)
if (klass == NULL)
klass = "unknown/unknown";
- return gst_pipewire_device_new (info->id,
+ return gst_pipewire_device_new (id,
info->name,
caps,
klass,
@@ -295,18 +295,25 @@ on_sync_reply (struct pw_listener *listener, struct pw_remote *remote, uint32_t
{
GstPipeWireDeviceProvider *self = SPA_CONTAINER_OF (listener, GstPipeWireDeviceProvider, on_sync_reply);
if (seq == 1)
- pw_core_proxy_sync(self->registry->remote->core_proxy, 2);
+ pw_core_proxy_sync(self->remote->core_proxy, 2);
else if (seq == 2)
self->end = true;
}
+struct node_data {
+ struct pw_interface_listener node_listener;
+ GstPipeWireDeviceProvider *self;
+ uint32_t id;
+};
+
static void node_event_info(void *object, struct pw_node_info *info)
{
struct pw_proxy *proxy = object;
- GstPipeWireDeviceProvider *self = proxy->object;
+ struct node_data *node_data = proxy->user_data;
+ GstPipeWireDeviceProvider *self = node_data->self;
GstDevice *dev;
- dev = new_node (self, info);
+ dev = new_node (self, info, node_data->id);
if (dev) {
if(self->list_only)
*self->devices = g_list_prepend (*self->devices, gst_object_ref_sink (dev));
@@ -320,23 +327,29 @@ static const struct pw_node_events node_events = {
&node_event_info
};
-static void registry_event_global(void *object, uint32_t id, uint32_t type,
+
+static void registry_event_global(void *object, uint32_t id,
uint32_t n_ifaces, const struct pw_interface_info *ifaces)
{
- pw_registry_proxy_t *registry = object;
- GstPipeWireDeviceProvider *self = registry->object;
- struct pw_remote *remote = registry->remote;
+ struct pw_registry_proxy *registry = object;
+ GstPipeWireDeviceProvider *self = registry->proxy.user_data;
+ struct pw_remote *remote = self->remote;
struct pw_core *core = remote->core;
- pw_node_proxy_t *node = NULL;
+ struct pw_node_proxy *node;
+ struct node_data *data;
- if (type != core->type.node)
+ if (pw_interface_info_find(n_ifaces, ifaces, PW_TYPE_INTERFACE__Node) == NULL)
return;
- node = pw_registry_proxy_bind(registry, id, PW_TYPE_INTERFACE__Node, PW_VERSION_NODE, 0);
+ node = pw_registry_proxy_bind(registry, id, PW_TYPE_INTERFACE__Node, PW_VERSION_NODE,
+ sizeof(struct node_data), NULL);
if (node == NULL)
goto no_mem;
- pw_node_proxy_add_listener(node, self, &node_events, NULL);
+ data = node->proxy.user_data;
+ data->id = id;
+ data->self = self;
+ pw_node_proxy_add_listener(node, &data->node_listener, node, &node_events);
return;
no_mem:
@@ -346,8 +359,8 @@ no_mem:
static void registry_event_global_remove(void *object, uint32_t id)
{
- struct pw_proxy *registry = object;
- GstPipeWireDeviceProvider *self = registry->object;
+ struct pw_registry_proxy *registry = object;
+ GstPipeWireDeviceProvider *self = registry->proxy.user_data;
GstDeviceProvider *provider = GST_DEVICE_PROVIDER (self);
GstPipeWireDevice *dev;
@@ -371,7 +384,8 @@ gst_pipewire_device_provider_probe (GstDeviceProvider * provider)
struct pw_loop *l = NULL;
struct pw_core *c = NULL;
struct pw_remote *r = NULL;
- pw_registry_proxy_t *reg = NULL;
+ struct pw_registry_proxy *reg = NULL;
+ struct pw_interface_listener listener;
GST_DEBUG_OBJECT (self, "starting probe");
@@ -412,8 +426,9 @@ gst_pipewire_device_provider_probe (GstDeviceProvider * provider)
self->list_only = TRUE;
self->devices = NULL;
- reg = pw_core_proxy_get_registry(r->core_proxy, PW_VERSION_REGISTRY, 0);
- pw_proxy_add_listener(reg, self, &registry_events, NULL);
+ reg = pw_core_proxy_get_registry(r->core_proxy, PW_VERSION_REGISTRY, 0, NULL);
+ reg->proxy.user_data = self;
+ pw_registry_proxy_add_listener(reg, &listener, reg, &registry_events);
pw_core_proxy_sync(r->core_proxy, 1);
for (;;) {
@@ -516,8 +531,9 @@ gst_pipewire_device_provider_start (GstDeviceProvider * provider)
GST_DEBUG_OBJECT (self, "connected");
get_core_info (self->remote, self);
- self->registry = pw_core_proxy_get_registry(self->remote->core_proxy, PW_VERSION_REGISTRY, 0);
- pw_proxy_add_listener(self->registry, self, &registry_events, NULL);
+ self->registry = pw_core_proxy_get_registry(self->remote->core_proxy, PW_VERSION_REGISTRY, 0, NULL);
+ self->registry->proxy.user_data = self;
+ pw_registry_proxy_add_listener(self->registry, &self->registry_listener, self->registry, &registry_events);
pw_core_proxy_sync(self->remote->core_proxy, 1);
pw_thread_loop_unlock (self->main_loop);
diff --git a/src/gst/gstpipewiredeviceprovider.h b/src/gst/gstpipewiredeviceprovider.h
index 21bc6020..8c7197d6 100644
--- a/src/gst/gstpipewiredeviceprovider.h
+++ b/src/gst/gstpipewiredeviceprovider.h
@@ -86,7 +86,8 @@ struct _GstPipeWireDeviceProvider {
struct pw_core *core;
struct pw_remote *remote;
- pw_registry_proxy_t *registry;
+ struct pw_registry_proxy *registry;
+ struct pw_interface_listener registry_listener;
gboolean end;
gboolean list_only;
GList **devices;
diff --git a/src/gst/gstpipewiresrc.c b/src/gst/gstpipewiresrc.c
index 482ff60b..aef9a8da 100644
--- a/src/gst/gstpipewiresrc.c
+++ b/src/gst/gstpipewiresrc.c
@@ -554,9 +554,6 @@ gst_pipewire_src_stream_start (GstPipeWireSrc *pwsrc)
}
parse_stream_properties (pwsrc, pwsrc->stream->properties);
- pw_thread_loop_unlock (pwsrc->main_loop);
-
- pw_thread_loop_lock (pwsrc->main_loop);
GST_DEBUG_OBJECT (pwsrc, "signal started");
pwsrc->started = TRUE;
pw_thread_loop_signal (pwsrc->main_loop, FALSE);
diff --git a/src/modules/module-client-node/protocol-native.c b/src/modules/module-client-node/protocol-native.c
index 0070f3c9..d6eb28b2 100644
--- a/src/modules/module-client-node/protocol-native.c
+++ b/src/modules/module-client-node/protocol-native.c
@@ -769,7 +769,7 @@ static bool client_node_demarshal_destroy(void *object, void *data, size_t size)
return true;
}
-static const struct pw_client_node_methods pw_protocol_native_client_client_node_methods = {
+static const struct pw_client_node_methods pw_protocol_native_client_node_method_marshal = {
PW_VERSION_CLIENT_NODE_METHODS,
&client_node_marshal_done,
&client_node_marshal_update,
@@ -778,28 +778,7 @@ static const struct pw_client_node_methods pw_protocol_native_client_client_node
&client_node_marshal_destroy
};
-static const demarshal_func_t pw_protocol_native_client_client_node_demarshal[] = {
- &client_node_demarshal_transport,
- &client_node_demarshal_set_props,
- &client_node_demarshal_event_event,
- &client_node_demarshal_add_port,
- &client_node_demarshal_remove_port,
- &client_node_demarshal_set_format,
- &client_node_demarshal_set_param,
- &client_node_demarshal_add_mem,
- &client_node_demarshal_use_buffers,
- &client_node_demarshal_node_command,
- &client_node_demarshal_port_command,
-};
-
-static const struct pw_interface pw_protocol_native_client_client_node_interface = {
- PW_TYPE_INTERFACE__ClientNode,
- PW_VERSION_CLIENT_NODE,
- PW_CLIENT_NODE_METHOD_NUM, &pw_protocol_native_client_client_node_methods,
- PW_CLIENT_NODE_EVENT_NUM, pw_protocol_native_client_client_node_demarshal,
-};
-
-static const demarshal_func_t pw_protocol_native_server_client_node_demarshal[] = {
+static const demarshal_func_t pw_protocol_native_client_node_method_demarshal[] = {
&client_node_demarshal_done,
&client_node_demarshal_update,
&client_node_demarshal_port_update,
@@ -807,7 +786,7 @@ static const demarshal_func_t pw_protocol_native_server_client_node_demarshal[]
&client_node_demarshal_destroy,
};
-static const struct pw_client_node_events pw_protocol_native_server_client_node_events = {
+static const struct pw_client_node_events pw_protocol_native_client_node_event_marshal = {
PW_VERSION_CLIENT_NODE_EVENTS,
&client_node_marshal_transport,
&client_node_marshal_set_props,
@@ -822,11 +801,29 @@ static const struct pw_client_node_events pw_protocol_native_server_client_node_
&client_node_marshal_port_command,
};
-const struct pw_interface pw_protocol_native_server_client_node_interface = {
+static const demarshal_func_t pw_protocol_native_client_node_event_demarshal[] = {
+ &client_node_demarshal_transport,
+ &client_node_demarshal_set_props,
+ &client_node_demarshal_event_event,
+ &client_node_demarshal_add_port,
+ &client_node_demarshal_remove_port,
+ &client_node_demarshal_set_format,
+ &client_node_demarshal_set_param,
+ &client_node_demarshal_add_mem,
+ &client_node_demarshal_use_buffers,
+ &client_node_demarshal_node_command,
+ &client_node_demarshal_port_command,
+};
+
+const struct pw_protocol_marshal pw_protocol_native_client_node_marshal = {
PW_TYPE_INTERFACE__ClientNode,
PW_VERSION_CLIENT_NODE,
- PW_CLIENT_NODE_METHOD_NUM, &pw_protocol_native_server_client_node_demarshal,
- PW_CLIENT_NODE_EVENT_NUM, &pw_protocol_native_server_client_node_events,
+ PW_CLIENT_NODE_METHOD_NUM,
+ &pw_protocol_native_client_node_method_marshal,
+ &pw_protocol_native_client_node_method_demarshal,
+ PW_CLIENT_NODE_EVENT_NUM,
+ &pw_protocol_native_client_node_event_marshal,
+ pw_protocol_native_client_node_event_demarshal,
};
struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_core *core)
@@ -838,9 +835,7 @@ struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_core *core
if (protocol == NULL)
return NULL;
- pw_protocol_add_interfaces(protocol,
- &pw_protocol_native_client_client_node_interface,
- &pw_protocol_native_server_client_node_interface);
+ pw_protocol_add_marshal(protocol, &pw_protocol_native_client_node_marshal);
return protocol;
}
diff --git a/src/modules/module-flatpak.c b/src/modules/module-flatpak.c
index 6031be2a..23540716 100644
--- a/src/modules/module-flatpak.c
+++ b/src/modules/module-flatpak.c
@@ -221,20 +221,24 @@ check_global_owner(struct pw_core *core, struct pw_client *client, struct pw_glo
static bool
do_global_filter(struct pw_global *global, struct pw_client *client, void *data)
{
- if (global->type == client->core->type.link) {
- struct pw_link *link = global->object;
+ struct pw_global_info *info;
- /* we must be able to see both nodes */
- if (link->output
- && !check_global_owner(client->core, client, link->output->node->global))
- return false;
+ spa_list_for_each(info, &global->info_list, link) {
+ if (strcmp(info->iface.type, PW_TYPE_INTERFACE__Link) == 0) {
+ struct pw_link *link = info->object;
- if (link->input
- && !check_global_owner(client->core, client, link->input->node->global))
- return false;
- } else if (!check_global_owner(client->core, client, global))
- return false;
+ /* we must be able to see both nodes */
+ if (link->output
+ && !check_global_owner(client->core, client, link->output->node->global))
+ return false;
+ if (link->input
+ && !check_global_owner(client->core, client, link->input->node->global))
+ return false;
+ }
+ else if (!check_global_owner(client->core, client, global))
+ return false;
+ }
return true;
}
@@ -439,9 +443,9 @@ static void on_resource_impl(struct pw_listener *listener,
struct client_info *cinfo = SPA_CONTAINER_OF(listener, struct client_info, resource_impl);
if (strcmp(resource->type, PW_TYPE_INTERFACE__Core) == 0) {
- cinfo->old_methods = resource->implementation;
+ cinfo->old_methods = resource->iface.methods;
cinfo->core_methods = *cinfo->old_methods;
- resource->implementation = &cinfo->core_methods;
+ resource->iface.methods = &cinfo->core_methods;
resource->access_private = cinfo;
cinfo->core_methods.create_node = do_create_node;
cinfo->core_methods.create_link = do_create_link;
diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c
index 45449fbe..a2b424b3 100644
--- a/src/modules/module-protocol-native.c
+++ b/src/modules/module-protocol-native.c
@@ -116,13 +116,13 @@ process_messages(struct pw_client *client)
client->protocol, id);
continue;
}
- if (opcode >= resource->iface->n_methods) {
+ if (opcode >= resource->marshal->n_methods) {
pw_log_error("protocol-native %p: invalid method %u %u", client->protocol,
id, opcode);
pw_client_destroy(client);
break;
}
- demarshal = resource->iface->methods;
+ demarshal = resource->marshal->method_demarshal;
if (!demarshal[opcode] || !demarshal[opcode] (resource, message, size)) {
pw_log_error("protocol-native %p: invalid message received %u %u",
client->protocol, id, opcode);
@@ -449,13 +449,13 @@ on_remote_data(struct spa_loop_utils *utils,
pw_log_error("protocol-native %p: could not find proxy %u", this, id);
continue;
}
- if (opcode >= proxy->iface->n_events) {
+ if (opcode >= proxy->marshal->n_events) {
pw_log_error("protocol-native %p: invalid method %u for %u", this, opcode,
id);
continue;
}
- demarshal = proxy->iface->events;
+ demarshal = proxy->marshal->event_demarshal;
if (demarshal[opcode]) {
if (!demarshal[opcode] (proxy, message, size))
pw_log_error
diff --git a/src/modules/module-protocol-native/protocol-native.c b/src/modules/module-protocol-native/protocol-native.c
index 207d4ffb..6c013782 100644
--- a/src/modules/module-protocol-native/protocol-native.c
+++ b/src/modules/module-protocol-native/protocol-native.c
@@ -194,7 +194,6 @@ static bool core_demarshal_info(void *object, void *data, size_t size)
if (!spa_pod_iter_struct(&it, data, size) ||
!spa_pod_iter_get(&it,
- SPA_POD_TYPE_INT, &info.id,
SPA_POD_TYPE_LONG, &info.change_mask,
SPA_POD_TYPE_STRING, &info.user_name,
SPA_POD_TYPE_STRING, &info.host_name,
@@ -294,7 +293,6 @@ static void core_marshal_info(void *object, struct pw_core_info *info)
spa_pod_builder_add(b,
SPA_POD_TYPE_STRUCT, &f,
- SPA_POD_TYPE_INT, info->id,
SPA_POD_TYPE_LONG, info->change_mask,
SPA_POD_TYPE_STRING, info->user_name,
SPA_POD_TYPE_STRING, info->host_name,
@@ -601,7 +599,6 @@ static void module_marshal_info(void *object, struct pw_module_info *info)
spa_pod_builder_add(b,
SPA_POD_TYPE_STRUCT, &f,
- SPA_POD_TYPE_INT, info->id,
SPA_POD_TYPE_LONG, info->change_mask,
SPA_POD_TYPE_STRING, info->name,
SPA_POD_TYPE_STRING, info->filename,
@@ -627,7 +624,6 @@ static bool module_demarshal_info(void *object, void *data, size_t size)
if (!spa_pod_iter_struct(&it, data, size) ||
!spa_pod_iter_get(&it,
- SPA_POD_TYPE_INT, &info.id,
SPA_POD_TYPE_LONG, &info.change_mask,
SPA_POD_TYPE_STRING, &info.name,
SPA_POD_TYPE_STRING, &info.filename,
@@ -657,7 +653,6 @@ static void node_marshal_info(void *object, struct pw_node_info *info)
spa_pod_builder_add(b,
SPA_POD_TYPE_STRUCT, &f,
- SPA_POD_TYPE_INT, info->id,
SPA_POD_TYPE_LONG, info->change_mask,
SPA_POD_TYPE_STRING, info->name,
SPA_POD_TYPE_INT, info->max_input_ports,
@@ -702,7 +697,6 @@ static bool node_demarshal_info(void *object, void *data, size_t size)
if (!spa_pod_iter_struct(&it, data, size) ||
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->remote->types) ||
!spa_pod_iter_get(&it,
- SPA_POD_TYPE_INT, &info.id,
SPA_POD_TYPE_LONG, &info.change_mask,
SPA_POD_TYPE_STRING, &info.name,
SPA_POD_TYPE_INT, &info.max_input_ports,
@@ -757,7 +751,6 @@ static void client_marshal_info(void *object, struct pw_client_info *info)
spa_pod_builder_add(b,
SPA_POD_TYPE_STRUCT, &f,
- SPA_POD_TYPE_INT, info->id,
SPA_POD_TYPE_LONG, info->change_mask, SPA_POD_TYPE_INT, n_items, 0);
for (i = 0; i < n_items; i++) {
@@ -780,7 +773,6 @@ static bool client_demarshal_info(void *object, void *data, size_t size)
if (!spa_pod_iter_struct(&it, data, size) ||
!spa_pod_iter_get(&it,
- SPA_POD_TYPE_INT, &info.id,
SPA_POD_TYPE_LONG, &info.change_mask,
SPA_POD_TYPE_INT, &props.n_items, 0))
return false;
@@ -806,7 +798,6 @@ static void link_marshal_info(void *object, struct pw_link_info *info)
b = pw_protocol_native_begin_resource(resource, PW_LINK_EVENT_INFO);
spa_pod_builder_struct(b, &f,
- SPA_POD_TYPE_INT, info->id,
SPA_POD_TYPE_LONG, info->change_mask,
SPA_POD_TYPE_INT, info->output_node_id,
SPA_POD_TYPE_INT, info->output_port_id,
@@ -826,7 +817,6 @@ static bool link_demarshal_info(void *object, void *data, size_t size)
if (!spa_pod_iter_struct(&it, data, size) ||
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->remote->types) ||
!spa_pod_iter_get(&it,
- SPA_POD_TYPE_INT, &info.id,
SPA_POD_TYPE_LONG, &info.change_mask,
SPA_POD_TYPE_INT, &info.output_node_id,
SPA_POD_TYPE_INT, &info.output_port_id,
@@ -898,7 +888,7 @@ static void registry_marshal_bind(void *object, uint32_t id,
pw_protocol_native_end_proxy(proxy, b);
}
-static const struct pw_core_methods pw_protocol_native_client_core_methods = {
+static const struct pw_core_methods pw_protocol_native_core_method_marshal = {
PW_VERSION_CORE_METHODS,
&core_marshal_update_types_client,
&core_marshal_sync,
@@ -908,83 +898,7 @@ static const struct pw_core_methods pw_protocol_native_client_core_methods = {
&core_marshal_create_link
};
-static const demarshal_func_t pw_protocol_native_client_core_demarshal[PW_CORE_EVENT_NUM] = {
- &core_demarshal_update_types_client,
- &core_demarshal_done,
- &core_demarshal_error,
- &core_demarshal_remove_id,
- &core_demarshal_info
-};
-
-static const struct pw_interface pw_protocol_native_client_core_interface = {
- PW_TYPE_INTERFACE__Core,
- PW_VERSION_CORE,
- PW_CORE_METHOD_NUM, &pw_protocol_native_client_core_methods,
- PW_CORE_EVENT_NUM, pw_protocol_native_client_core_demarshal
-};
-
-static const struct pw_registry_methods pw_protocol_native_client_registry_methods = {
- PW_VERSION_REGISTRY_METHODS,
- &registry_marshal_bind
-};
-
-static const demarshal_func_t pw_protocol_native_client_registry_demarshal[] = {
- &registry_demarshal_global,
- &registry_demarshal_global_remove,
-};
-
-static const struct pw_interface pw_protocol_native_client_registry_interface = {
- PW_TYPE_INTERFACE__Registry,
- PW_VERSION_REGISTRY,
- PW_REGISTRY_METHOD_NUM, &pw_protocol_native_client_registry_methods,
- PW_REGISTRY_EVENT_NUM, pw_protocol_native_client_registry_demarshal,
-};
-
-static const demarshal_func_t pw_protocol_native_client_module_demarshal[] = {
- &module_demarshal_info,
-};
-
-static const struct pw_interface pw_protocol_native_client_module_interface = {
- PW_TYPE_INTERFACE__Module,
- PW_VERSION_MODULE,
- 0, NULL,
- PW_MODULE_EVENT_NUM, pw_protocol_native_client_module_demarshal,
-};
-
-static const demarshal_func_t pw_protocol_native_client_node_demarshal[] = {
- &node_demarshal_info,
-};
-
-static const struct pw_interface pw_protocol_native_client_node_interface = {
- PW_TYPE_INTERFACE__Node,
- PW_VERSION_NODE,
- 0, NULL,
- PW_NODE_EVENT_NUM, pw_protocol_native_client_node_demarshal,
-};
-
-static const demarshal_func_t pw_protocol_native_client_client_demarshal[] = {
- &client_demarshal_info,
-};
-
-static const struct pw_interface pw_protocol_native_client_client_interface = {
- PW_TYPE_INTERFACE__Client,
- PW_VERSION_CLIENT,
- 0, NULL,
- PW_CLIENT_EVENT_NUM, pw_protocol_native_client_client_demarshal,
-};
-
-static const demarshal_func_t pw_protocol_native_client_link_demarshal[] = {
- &link_demarshal_info,
-};
-
-static const struct pw_interface pw_protocol_native_client_link_interface = {
- PW_TYPE_INTERFACE__Link,
- PW_VERSION_LINK,
- 0, NULL,
- PW_LINK_EVENT_NUM, pw_protocol_native_client_link_demarshal,
-};
-
-static const demarshal_func_t pw_protocol_native_server_core_demarshal[PW_CORE_METHOD_NUM] = {
+static const demarshal_func_t pw_protocol_native_core_method_demarshal[PW_CORE_METHOD_NUM] = {
&core_demarshal_update_types_server,
&core_demarshal_sync,
&core_demarshal_get_registry,
@@ -993,7 +907,7 @@ static const demarshal_func_t pw_protocol_native_server_core_demarshal[PW_CORE_M
&core_demarshal_create_link
};
-static const struct pw_core_events pw_protocol_native_server_core_events = {
+static const struct pw_core_events pw_protocol_native_core_event_marshal = {
PW_VERSION_CORE_EVENTS,
&core_marshal_update_types_server,
&core_marshal_done,
@@ -1002,97 +916,134 @@ static const struct pw_core_events pw_protocol_native_server_core_events = {
&core_marshal_info
};
-const struct pw_interface pw_protocol_native_server_core_interface = {
+static const demarshal_func_t pw_protocol_native_core_event_demarshal[PW_CORE_EVENT_NUM] = {
+ &core_demarshal_update_types_client,
+ &core_demarshal_done,
+ &core_demarshal_error,
+ &core_demarshal_remove_id,
+ &core_demarshal_info
+};
+
+static const struct pw_protocol_marshal pw_protocol_native_core_marshal = {
PW_TYPE_INTERFACE__Core,
PW_VERSION_CORE,
- PW_CORE_METHOD_NUM, pw_protocol_native_server_core_demarshal,
- PW_CORE_EVENT_NUM, &pw_protocol_native_server_core_events,
+ PW_CORE_METHOD_NUM,
+ &pw_protocol_native_core_method_marshal,
+ pw_protocol_native_core_method_demarshal,
+ PW_CORE_EVENT_NUM,
+ &pw_protocol_native_core_event_marshal,
+ pw_protocol_native_core_event_demarshal
};
-static const demarshal_func_t pw_protocol_native_server_registry_demarshal[] = {
+static const struct pw_registry_methods pw_protocol_native_registry_method_marshal = {
+ PW_VERSION_REGISTRY_METHODS,
+ &registry_marshal_bind
+};
+
+static const demarshal_func_t pw_protocol_native_registry_method_demarshal[] = {
&registry_demarshal_bind,
};
-static const struct pw_registry_events pw_protocol_native_server_registry_events = {
+static const struct pw_registry_events pw_protocol_native_registry_event_marshal = {
PW_VERSION_REGISTRY_EVENTS,
&registry_marshal_global,
&registry_marshal_global_remove,
};
-const struct pw_interface pw_protocol_native_server_registry_interface = {
+static const demarshal_func_t pw_protocol_native_registry_event_demarshal[] = {
+ &registry_demarshal_global,
+ &registry_demarshal_global_remove,
+};
+
+const struct pw_protocol_marshal pw_protocol_native_registry_marshal = {
PW_TYPE_INTERFACE__Registry,
PW_VERSION_REGISTRY,
- PW_REGISTRY_METHOD_NUM, pw_protocol_native_server_registry_demarshal,
- PW_REGISTRY_EVENT_NUM, &pw_protocol_native_server_registry_events,
+ PW_REGISTRY_METHOD_NUM,
+ &pw_protocol_native_registry_method_marshal,
+ pw_protocol_native_registry_method_demarshal,
+ PW_REGISTRY_EVENT_NUM,
+ &pw_protocol_native_registry_event_marshal,
+ pw_protocol_native_registry_event_demarshal,
};
-static const struct pw_module_events pw_protocol_native_server_module_events = {
+static const struct pw_module_events pw_protocol_native_module_event_marshal = {
PW_VERSION_MODULE_EVENTS,
&module_marshal_info,
};
-const struct pw_interface pw_protocol_native_server_module_interface = {
+static const demarshal_func_t pw_protocol_native_module_event_demarshal[] = {
+ &module_demarshal_info,
+};
+
+const struct pw_protocol_marshal pw_protocol_native_module_marshal = {
PW_TYPE_INTERFACE__Module,
PW_VERSION_MODULE,
- 0, NULL,
- PW_MODULE_EVENT_NUM, &pw_protocol_native_server_module_events,
+ 0, NULL, NULL,
+ PW_MODULE_EVENT_NUM,
+ &pw_protocol_native_module_event_marshal,
+ pw_protocol_native_module_event_demarshal,
};
-static const struct pw_node_events pw_protocol_native_server_node_events = {
+static const struct pw_node_events pw_protocol_native_node_event_marshal = {
PW_VERSION_NODE_EVENTS,
&node_marshal_info,
};
-const struct pw_interface pw_protocol_native_server_node_interface = {
+static const demarshal_func_t pw_protocol_native_node_event_demarshal[] = {
+ &node_demarshal_info,
+};
+
+static const struct pw_protocol_marshal pw_protocol_native_node_marshal = {
PW_TYPE_INTERFACE__Node,
PW_VERSION_NODE,
- 0, NULL,
- PW_NODE_EVENT_NUM, &pw_protocol_native_server_node_events,
+ 0, NULL, NULL,
+ PW_NODE_EVENT_NUM,
+ &pw_protocol_native_node_event_marshal,
+ pw_protocol_native_node_event_demarshal,
};
-static const struct pw_client_events pw_protocol_native_server_client_events = {
+static const struct pw_client_events pw_protocol_native_client_event_marshal = {
PW_VERSION_CLIENT_EVENTS,
&client_marshal_info,
};
-const struct pw_interface pw_protocol_native_server_client_interface = {
+static const demarshal_func_t pw_protocol_native_client_event_demarshal[] = {
+ &client_demarshal_info,
+};
+
+static const struct pw_protocol_marshal pw_protocol_native_client_marshal = {
PW_TYPE_INTERFACE__Client,
PW_VERSION_CLIENT,
- 0, NULL,
- PW_CLIENT_EVENT_NUM, &pw_protocol_native_server_client_events,
+ 0, NULL, NULL,
+ PW_CLIENT_EVENT_NUM,
+ &pw_protocol_native_client_event_marshal,
+ pw_protocol_native_client_event_demarshal,
};
-static const struct pw_link_events pw_protocol_native_server_link_events = {
+static const struct pw_link_events pw_protocol_native_link_event_marshal = {
PW_VERSION_LINK_EVENTS,
&link_marshal_info,
};
-const struct pw_interface pw_protocol_native_server_link_interface = {
+static const demarshal_func_t pw_protocol_native_link_event_demarshal[] = {
+ &link_demarshal_info,
+};
+
+static const struct pw_protocol_marshal pw_protocol_native_link_marshal = {
PW_TYPE_INTERFACE__Link,
PW_VERSION_LINK,
- 0, NULL,
- PW_LINK_EVENT_NUM, &pw_protocol_native_server_link_events,
+ 0, NULL, NULL,
+ PW_LINK_EVENT_NUM,
+ &pw_protocol_native_link_event_marshal,
+ pw_protocol_native_link_event_demarshal,
};
void pw_protocol_native_init(struct pw_protocol *protocol)
{
- pw_protocol_add_interfaces(protocol,
- &pw_protocol_native_client_core_interface,
- &pw_protocol_native_server_core_interface);
- pw_protocol_add_interfaces(protocol,
- &pw_protocol_native_client_registry_interface,
- &pw_protocol_native_server_registry_interface);
- pw_protocol_add_interfaces(protocol,
- &pw_protocol_native_client_module_interface,
- &pw_protocol_native_server_module_interface);
- pw_protocol_add_interfaces(protocol,
- &pw_protocol_native_client_node_interface,
- &pw_protocol_native_server_node_interface);
- pw_protocol_add_interfaces(protocol,
- &pw_protocol_native_client_client_interface,
- &pw_protocol_native_server_client_interface);
- pw_protocol_add_interfaces(protocol,
- &pw_protocol_native_client_link_interface,
- &pw_protocol_native_server_link_interface);
-
+ pw_protocol_add_marshal(protocol, &pw_protocol_native_core_marshal);
+ pw_protocol_add_marshal(protocol, &pw_protocol_native_registry_marshal);
+ pw_protocol_add_marshal(protocol, &pw_protocol_native_module_marshal);
+ pw_protocol_add_marshal(protocol, &pw_protocol_native_node_marshal);
+ pw_protocol_add_marshal(protocol, &pw_protocol_native_client_marshal);
+ pw_protocol_add_marshal(protocol, &pw_protocol_native_link_marshal);
}
diff --git a/src/pipewire/client.c b/src/pipewire/client.c
index 5afe30a3..fb889009 100644
--- a/src/pipewire/client.c
+++ b/src/pipewire/client.c
@@ -28,6 +28,8 @@
/** \cond */
struct impl {
struct pw_client this;
+
+ struct pw_global_info global_info[1];
};
/** \endcond */
@@ -38,24 +40,27 @@ static void client_unbind_func(void *data)
}
static int
-client_bind_func(struct pw_global *global, struct pw_client *client,
- const char *type, uint32_t version, uint32_t id)
+client_bind_func(struct pw_global *global,
+ struct pw_global_info *info,
+ struct pw_client *client,
+ uint32_t version, uint32_t id)
{
- struct pw_client *this = global->object;
+ struct pw_client *this = info->object;
struct pw_resource *resource;
- resource = pw_resource_new(client, id, type, version, 0);
+ resource = pw_resource_new(client, id, info->iface.type, version, 0);
if (resource == NULL)
goto no_mem;
- pw_resource_set_implementation(resource, global->object, NULL, client_unbind_func);
+ pw_resource_set_implementation(resource, info->object, NULL, client_unbind_func);
- pw_log_debug("client %p: bound to %d", global->object, resource->id);
+ pw_log_debug("client %p: bound to %d", this, resource->id);
spa_list_insert(this->resource_list.prev, &resource->link);
this->info.change_mask = ~0;
pw_client_resource_info(resource, &this->info);
+ this->info.change_mask = 0;
return SPA_RESULT_OK;
@@ -66,10 +71,6 @@ client_bind_func(struct pw_global *global, struct pw_client *client,
return SPA_RESULT_NO_MEMORY;
}
-static const struct pw_interface_info client_ifaces[] = {
- { PW_TYPE_INTERFACE__Client, PW_VERSION_CLIENT },
-};
-
/** Make a new client object
*
* \param core a \ref pw_core object to register the client with
@@ -115,12 +116,20 @@ struct pw_client *pw_client_new(struct pw_core *core,
spa_list_insert(core->client_list.prev, &this->link);
+ this->n_global_info = 1;
+ this->global_info = impl->global_info;
+ impl->global_info[0].iface.type = PW_TYPE_INTERFACE__Client;
+ impl->global_info[0].iface.version = PW_VERSION_CLIENT;
+ impl->global_info[0].bind = client_bind_func;
+ impl->global_info[0].object = this;
+
+#if 0
pw_core_add_global(core, NULL, core->type.client,
SPA_N_ELEMENTS(client_ifaces),
client_ifaces,
this, client_bind_func, &this->global);
+#endif
- this->info.id = this->global->id;
this->info.props = this->properties ? &this->properties->dict : NULL;
return this;
diff --git a/src/pipewire/client.h b/src/pipewire/client.h
index 0d6827ad..b0356c11 100644
--- a/src/pipewire/client.h
+++ b/src/pipewire/client.h
@@ -84,6 +84,9 @@ struct pw_client {
struct spa_list link; /**< link in core object client list */
struct pw_global *global; /**< global object created for this client */
+ uint32_t n_global_info;
+ struct pw_global_info *global_info;
+
struct pw_properties *properties; /**< Client properties */
/** Emited when the properties changed */
PW_SIGNAL(properties_changed, (struct pw_listener *listener, struct pw_client *client));
diff --git a/src/pipewire/core.c b/src/pipewire/core.c
index 0a2b669f..c640f367 100644
--- a/src/pipewire/core.c
+++ b/src/pipewire/core.c
@@ -32,6 +32,8 @@
/** \cond */
struct global_impl {
struct pw_global this;
+ uint32_t n_info;
+ const struct pw_interface_info **info;
};
struct impl {
@@ -39,6 +41,8 @@ struct impl {
struct spa_support support[4];
struct pw_data_loop *data_loop;
+
+ struct pw_global_info global_info[1];
};
/** \endcond */
@@ -135,12 +139,13 @@ static void core_get_registry(void *object, uint32_t version, uint32_t new_id)
spa_list_insert(this->registry_resource_list.prev, &registry_resource->link);
spa_list_for_each(global, &this->global_list, link) {
- if (pw_global_is_visible(global, client))
- pw_registry_resource_global(registry_resource,
+ if (pw_global_is_visible(global, client)) {
+ struct global_impl *impl = SPA_CONTAINER_OF(global, struct global_impl, this);
+ pw_registry_resource_global(registry_resource,
global->id,
- global->type,
- global->n_ifaces,
- global->ifaces);
+ impl->n_info,
+ impl->info);
+ }
}
return;
@@ -257,22 +262,25 @@ static void core_unbind_func(void *data)
}
static int
-core_bind_func(struct pw_global *global, struct pw_client *client,
- const char *type, uint32_t version, uint32_t id)
+core_bind_func(struct pw_global *global,
+ struct pw_global_info *info,
+ struct pw_client *client,
+ uint32_t version,
+ uint32_t id)
{
- struct pw_core *this = global->object;
+ struct pw_core *this = info->object;
struct pw_resource *resource;
- resource = pw_resource_new(client, id, type, version, 0);
+ resource = pw_resource_new(client, id, info->iface.type, version, 0);
if (resource == NULL)
goto no_mem;
- pw_resource_set_implementation(resource, global->object, &core_methods, core_unbind_func);
+ pw_resource_set_implementation(resource, info->object, &core_methods, core_unbind_func);
spa_list_insert(this->resource_list.prev, &resource->link);
client->core_resource = resource;
- pw_log_debug("core %p: bound to %d", global->object, resource->id);
+ pw_log_debug("core %p: bound to %d", this, resource->id);
this->info.change_mask = PW_CORE_CHANGE_MASK_ALL;
pw_core_resource_info(resource, &this->info);
@@ -285,10 +293,6 @@ core_bind_func(struct pw_global *global, struct pw_client *client,
return SPA_RESULT_NO_MEMORY;
}
-const struct pw_interface_info core_ifaces[] = {
- { PW_TYPE_INTERFACE__Core, PW_VERSION_CORE },
-};
-
/** Create a new core object
*
* \param main_loop the main loop to use
@@ -330,6 +334,13 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro
this->support = impl->support;
this->n_support = 4;
+ this->n_global_info = 1;
+ this->global_info = impl->global_info;
+ impl->global_info[0].iface.type = PW_TYPE_INTERFACE__Core;
+ impl->global_info[0].iface.version = PW_VERSION_CORE;
+ impl->global_info[0].bind = core_bind_func;
+ impl->global_info[0].object = this;
+
pw_data_loop_start(impl->data_loop);
spa_list_init(&this->protocol_list);
@@ -346,11 +357,12 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro
pw_signal_init(&this->global_added);
pw_signal_init(&this->global_removed);
+#if 0
pw_core_add_global(this, NULL, this->type.core,
SPA_N_ELEMENTS(core_ifaces), core_ifaces,
this, core_bind_func, &this->global);
+#endif
- this->info.id = this->global->id;
this->info.change_mask = 0;
this->info.user_name = pw_get_user_name();
this->info.host_name = pw_get_host_name();
@@ -397,6 +409,28 @@ void pw_core_destroy(struct pw_core *core)
free(impl);
}
+struct pw_global *
+pw_global_new(struct pw_core *core,
+ struct pw_resource *owner)
+{
+ struct global_impl *impl;
+ struct pw_global *this;
+
+ impl = calloc(1, sizeof(struct global_impl));
+ if (impl == NULL)
+ return NULL;
+
+ this = &impl->this;
+ this->core = core;
+ this->owner = owner;
+ spa_list_init(&this->info_list);
+
+ pw_signal_init(&this->destroy_signal);
+ pw_log_debug("global %p: new owner %p", this, owner);
+
+ return this;
+}
+
/** Create and add a new global to the core
*
* \param core a core
@@ -411,50 +445,59 @@ void pw_core_destroy(struct pw_core *core)
*
* \memberof pw_core
*/
-bool
-pw_core_add_global(struct pw_core *core,
- struct pw_resource *owner,
- uint32_t type,
- uint32_t n_ifaces,
- const struct pw_interface_info *ifaces,
- void *object,
- pw_bind_func_t bind,
- struct pw_global **global)
+void
+pw_global_add_info(struct pw_global *global,
+ uint32_t n_info,
+ struct pw_global_info *info)
{
- struct global_impl *impl;
- struct pw_global *this;
- struct pw_resource *registry;
-
- impl = calloc(1, sizeof(struct global_impl));
- if (impl == NULL)
- return false;
+ struct global_impl *impl = SPA_CONTAINER_OF(global, struct global_impl, this);
+ int i;
- this = &impl->this;
+ for (i = 0; i < n_info; i++) {
+ info[i].global = global;
+ spa_list_insert(global->info_list.prev, &info[i].link);
+ }
+ impl->n_info += n_info;
+}
- this->core = core;
- this->owner = owner;
- this->type = type;
- this->n_ifaces = n_ifaces;
- this->ifaces = ifaces;
- this->bind = bind;
- this->object = object;
- *global = this;
+void
+pw_global_add(struct pw_global *global)
+{
+ struct global_impl *impl = SPA_CONTAINER_OF(global, struct global_impl, this);
+ struct pw_resource *registry;
+ struct pw_core *core = global->core;
+ struct pw_global_info *info;
+ int i;
- pw_signal_init(&this->destroy_signal);
+ global->id = pw_map_insert_new(&core->objects, global);
- this->id = pw_map_insert_new(&core->objects, this);
+ spa_list_insert(core->global_list.prev, &global->link);
+ pw_signal_emit(&core->global_added, core, global);
- spa_list_insert(core->global_list.prev, &this->link);
- pw_signal_emit(&core->global_added, core, this);
+ pw_log_debug("global %p: added %u", global, global->id);
- pw_log_debug("global %p: new %u %d, owner %p", this, this->id, this->type, owner);
+ impl->info = calloc(impl->n_info, sizeof(struct pw_interface_info *));
+ i = 0;
+ spa_list_for_each(info, &global->info_list, link)
+ impl->info[i++] = &info->iface;
spa_list_for_each(registry, &core->registry_resource_list, link)
- if (pw_global_is_visible(this, registry->client))
- pw_registry_resource_global(registry, this->id, this->type,
- this->n_ifaces, this->ifaces);
+ if (pw_global_is_visible(global, registry->client)) {
+ struct global_impl *impl = SPA_CONTAINER_OF(global, struct global_impl, this);
+ pw_registry_resource_global(registry, global->id,
+ impl->n_info,
+ impl->info);
+ }
+}
- return true;
+static struct pw_global_info *find_info(struct pw_global *global, const char *type)
+{
+ struct pw_global_info *info;
+ spa_list_for_each(info, &global->info_list, link) {
+ if (strcmp(info->iface.type, type) == 0)
+ return info;
+ }
+ return NULL;
}
/** Bind to a global
@@ -475,18 +518,18 @@ pw_global_bind(struct pw_global *global, struct pw_client *client,
const char *type, uint32_t version, uint32_t id)
{
int res;
- const struct pw_interface_info *iface;
+ struct pw_global_info *info;
- if (global->bind == NULL)
- goto no_bind;
-
- if ((iface = pw_interface_info_find(global->n_ifaces, global->ifaces, type)) == NULL)
+ if ((info = find_info(global, type)) == NULL)
goto no_interface;
- if (iface->version < version)
+ if (info->bind == NULL)
+ goto no_bind;
+
+ if (info->iface.version < version)
goto wrong_version;
- res = global->bind(global, client, type, version, id);
+ res = info->bind(global, info, client, version, id);
return res;
@@ -495,19 +538,19 @@ pw_global_bind(struct pw_global *global, struct pw_client *client,
pw_core_resource_error(client->core_resource,
client->core_resource->id,
res, "id %d: interface %s version %d < %d",
- id, type, iface->version, version);
+ id, type, info->iface.version, version);
return res;
- no_interface:
- res = SPA_RESULT_UNKNOWN_INTERFACE;
+ no_bind:
+ res = SPA_RESULT_NOT_IMPLEMENTED;
pw_core_resource_error(client->core_resource,
client->core_resource->id,
- res, "id %d: unknown interface %s", id, type);
+ res, "can't bind object id %d to interface %s", id, type);
return res;
- no_bind:
- res = SPA_RESULT_NOT_IMPLEMENTED;
+ no_interface:
+ res = SPA_RESULT_UNKNOWN_INTERFACE;
pw_core_resource_error(client->core_resource,
client->core_resource->id,
- res, "can't bind object id %d", id);
+ res, "id %d: unknown interface %s", id, type);
return res;
}
diff --git a/src/pipewire/core.h b/src/pipewire/core.h
index 573d92a6..a6fa381c 100644
--- a/src/pipewire/core.h
+++ b/src/pipewire/core.h
@@ -28,6 +28,7 @@ extern "C" {
#include <spa/graph-scheduler3.h>
struct pw_global;
+struct pw_global_info;
#include <pipewire/type.h>
#include <pipewire/loop.h>
@@ -37,9 +38,6 @@ struct pw_global;
#include <pipewire/node.h>
#include <pipewire/node-factory.h>
-#define PW_TYPE__Core PW_TYPE_OBJECT_BASE "Core"
-#define PW_TYPE__CORE_BASE PW_TYPE__Core ":"
-
/** \page page_server_api Server API
*
* \section page_server_overview Overview
@@ -94,10 +92,10 @@ struct pw_global;
* the object.
*/
typedef int (*pw_bind_func_t) (struct pw_global *global, /**< the global to bind */
+ struct pw_global_info *info, /**< global info */
struct pw_client *client, /**< client that binds */
- const char *type, /**< interface to bind */
- uint32_t version, /**< interface version */
- uint32_t id); /**< remote proxy id */
+ uint32_t version, /**< client interface version */
+ uint32_t id); /**< client proxy id */
typedef bool (*pw_global_filter_func_t) (struct pw_global *global,
struct pw_client *client, void *data);
@@ -115,6 +113,16 @@ typedef bool (*pw_global_filter_func_t) (struct pw_global *global,
* A client can bind to a global to send methods or receive events from
* the global.
*/
+
+struct pw_global_info {
+ struct spa_list link; /**< link in global info_list */
+ struct pw_global *global; /**< global this info is added to */
+ uint32_t type; /**< type of interface */
+ uint32_t version; /**< version of interface */
+ pw_bind_func_t bind; /**< function to bind to the interface */
+ void *object; /**< object associated with the interface */
+};
+
/** \class pw_global
*
* \brief A global object visible to all clients
@@ -131,13 +139,8 @@ struct pw_global {
struct spa_list link; /**< link in core list of globals */
uint32_t id; /**< server id of the object */
- uint32_t type; /**< type of the object */
-
- uint32_t n_ifaces; /**< number of interfaces */
- const struct pw_interface_info *ifaces; /**< interfaces types and version */
- pw_bind_func_t bind; /**< function to bind to the global */
- void *object; /**< object associated with the global */
+ struct spa_list info_list; /**< list of global_info */
/** Emited when the global is destroyed */
PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_global *global));
@@ -155,6 +158,9 @@ struct pw_global {
struct pw_core {
struct pw_global *global; /**< the global of the core */
+ uint32_t n_global_info;
+ struct pw_global_info *global_info;
+
struct pw_core_info info; /**< info about the core */
/** Emited when the core info is updated */
PW_SIGNAL(info_changed, (struct pw_listener *listener, struct pw_core *core));
@@ -209,15 +215,18 @@ pw_core_destroy(struct pw_core *core);
void
pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict);
-bool
-pw_core_add_global(struct pw_core *core,
- struct pw_resource *owner,
- uint32_t type,
- uint32_t n_ifaces,
- const struct pw_interface_info *ifaces,
- void *object,
- pw_bind_func_t bind,
- struct pw_global **global);
+
+struct pw_global *
+pw_global_new(struct pw_core *core,
+ struct pw_resource *owner);
+
+void
+pw_global_add_info(struct pw_global *global,
+ uint32_t n_info,
+ struct pw_global_info *info);
+
+void
+pw_global_add(struct pw_global *global);
int
pw_global_bind(struct pw_global *global,
diff --git a/src/pipewire/interfaces.h b/src/pipewire/interfaces.h
index afeb92f5..c91cc658 100644
--- a/src/pipewire/interfaces.h
+++ b/src/pipewire/interfaces.h
@@ -30,17 +30,17 @@ extern "C" {
#include <spa/param-alloc.h>
#include <spa/node.h>
-typedef struct pw_proxy pw_core_proxy_t;
-typedef struct pw_proxy pw_registry_proxy_t;
-typedef struct pw_proxy pw_module_proxy_t;
-typedef struct pw_proxy pw_node_proxy_t;
-typedef struct pw_proxy pw_client_proxy_t;
-typedef struct pw_proxy pw_link_proxy_t;
-
#include <pipewire/type.h>
#include <pipewire/introspect.h>
#include <pipewire/proxy.h>
+struct pw_core_proxy { struct pw_proxy proxy; };
+struct pw_registry_proxy { struct pw_proxy proxy; };
+struct pw_module_proxy { struct pw_proxy proxy; };
+struct pw_node_proxy { struct pw_proxy proxy; };
+struct pw_client_proxy { struct pw_proxy proxy; };
+struct pw_link_proxy { struct pw_proxy proxy; };
+
/**
* \page page_pipewire_protocol The PipeWire protocol
* \section page_ifaces_pipewire Interfaces
@@ -165,60 +165,62 @@ struct pw_core_methods {
};
static inline void
-pw_core_proxy_update_types(pw_core_proxy_t *core, uint32_t first_id, uint32_t n_types, const char **types)
+pw_core_proxy_update_types(struct pw_core_proxy *core, uint32_t first_id, uint32_t n_types, const char **types)
{
- pw_proxy_do(core, struct pw_core_methods, update_types, first_id, n_types, types);
+ pw_proxy_do(&core->proxy, struct pw_core_methods, update_types, first_id, n_types, types);
}
static inline void
-pw_core_proxy_sync(pw_core_proxy_t *core, uint32_t seq)
+pw_core_proxy_sync(struct pw_core_proxy *core, uint32_t seq)
{
- pw_proxy_do(core, struct pw_core_methods, sync, seq);
+ pw_proxy_do(&core->proxy, struct pw_core_methods, sync, seq);
}
-static inline pw_registry_proxy_t *
-pw_core_proxy_get_registry(pw_core_proxy_t *core, uint32_t version, size_t user_data_size)
+static inline struct pw_registry_proxy *
+pw_core_proxy_get_registry(struct pw_core_proxy *core, uint32_t version, size_t user_data_size, pw_destroy_t destroy)
{
- struct pw_proxy *p = pw_proxy_new(core->remote, SPA_ID_INVALID, PW_TYPE_INTERFACE__Registry,
- user_data_size);
- pw_proxy_do(core, struct pw_core_methods, get_registry, version, p->id);
- return p;
+ struct pw_proxy *p = pw_proxy_new(core->proxy.remote, SPA_ID_INVALID, PW_TYPE_INTERFACE__Registry,
+ user_data_size, destroy);
+ pw_proxy_do(&core->proxy, struct pw_core_methods, get_registry, version, p->id);
+ return (struct pw_registry_proxy *) p;
}
static inline void
-pw_core_proxy_client_update(pw_core_proxy_t *core, const struct spa_dict *props)
+pw_core_proxy_client_update(struct pw_core_proxy *core, const struct spa_dict *props)
{
- pw_proxy_do(core, struct pw_core_methods, client_update, props);
+ pw_proxy_do(&core->proxy, struct pw_core_methods, client_update, props);
}
-static inline struct pw_proxy *
-pw_core_proxy_create_node(pw_core_proxy_t *core,
+static inline void *
+pw_core_proxy_create_node(struct pw_core_proxy *core,
const char *factory_name,
const char *name,
const char *type,
uint32_t version,
const struct spa_dict *props,
- size_t user_data_size)
+ size_t user_data_size,
+ pw_destroy_t destroy)
{
- struct pw_proxy *p = pw_proxy_new(core->remote, SPA_ID_INVALID, type, user_data_size);
- pw_proxy_do(core, struct pw_core_methods, create_node, factory_name,
+ struct pw_proxy *p = pw_proxy_new(core->proxy.remote, SPA_ID_INVALID, type, user_data_size, destroy);
+ pw_proxy_do(&core->proxy, struct pw_core_methods, create_node, factory_name,
name, type, version, props, p->id);
return p;
}
static inline struct pw_link_proxy *
-pw_core_proxy_create_link(pw_core_proxy_t *core,
+pw_core_proxy_create_link(struct pw_core_proxy *core,
uint32_t output_node_id,
uint32_t output_port_id,
uint32_t input_node_id,
uint32_t input_port_id,
const struct spa_format *filter,
const struct spa_dict *prop,
- size_t user_data_size)
+ size_t user_data_size,
+ pw_destroy_t destroy)
{
- struct pw_proxy *p = pw_proxy_new(core->remote, SPA_ID_INVALID, PW_TYPE_INTERFACE__Link,
- user_data_size);
- pw_proxy_do(core, struct pw_core_methods, create_link, output_node_id, output_port_id,
+ struct pw_proxy *p = pw_proxy_new(core->proxy.remote, SPA_ID_INVALID, PW_TYPE_INTERFACE__Link,
+ user_data_size, destroy);
+ pw_proxy_do(&core->proxy, struct pw_core_methods, create_link, output_node_id, output_port_id,
input_node_id, input_port_id, filter, prop, p->id);
return (struct pw_link_proxy*) p;
}
@@ -292,10 +294,11 @@ struct pw_core_events {
};
static inline void
-pw_core_proxy_add_listener(pw_core_proxy_t *core, void *object,
- const struct pw_core_events *listener, pw_destroy_t destroy)
+pw_core_proxy_add_listener(struct pw_core_proxy *core,
+ struct pw_interface_listener *listener,
+ void *object, const struct pw_core_events *events)
{
- pw_proxy_add_listener(core, object, listener, destroy);
+ pw_proxy_add_listener(&core->proxy, listener, object, events);
}
@@ -309,8 +312,8 @@ pw_core_proxy_add_listener(pw_core_proxy_t *core, void *object,
#define PW_VERSION_REGISTRY 0
-#define PW_REGISTRY_METHOD_BIND 0
-#define PW_REGISTRY_METHOD_NUM 1
+#define PW_REGISTRY_METHOD_BIND 0
+#define PW_REGISTRY_METHOD_NUM 1
/** Registry methods */
struct pw_registry_methods {
@@ -324,21 +327,22 @@ struct pw_registry_methods {
* send to the remote global object and events can be received
*
* \param id the global id to bind to
- * \param iface the interface to bind to
+ * \param type the interface type to bind to
* \param version the interface version to use
* \param new_id the client proxy to use
*/
- void (*bind) (void *object, uint32_t id, const char *iface, uint32_t version, uint32_t new_id);
+ void (*bind) (void *object, uint32_t id, uint32_t type, uint32_t version, uint32_t new_id);
};
/** Registry */
-static inline struct pw_proxy *
-pw_registry_proxy_bind(pw_registry_proxy_t *registry,
- uint32_t id, const char *iface, uint32_t version,
- size_t user_data_size)
+static inline void *
+pw_registry_proxy_bind(struct pw_registry_proxy *registry,
+ uint32_t id, uint32_t type, uint32_t version,
+ size_t user_data_size, pw_destroy_t destroy)
{
- struct pw_proxy *p = pw_proxy_new(registry->remote, SPA_ID_INVALID, iface, user_data_size);
- pw_proxy_do(registry, struct pw_registry_methods, bind, id, iface, version, p->id);
+ struct pw_proxy *p = pw_proxy_new(registry->proxy.remote, SPA_ID_INVALID,
+ type, user_data_size, destroy);
+ pw_proxy_do(&registry->proxy, struct pw_registry_methods, bind, id, iface, version, p->id);
return p;
}
@@ -361,8 +365,8 @@ struct pw_registry_events {
* \param n_ifaces the number of interfaces
* \param ifaces interfaces available on the global
*/
- void (*global) (void *object, uint32_t id, uint32_t type,
- uint32_t n_ifaces, const struct pw_interface_info *ifaces);
+ void (*global) (void *object, uint32_t id,
+ uint32_t n_ifaces, const struct pw_interface_info **ifaces);
/**
* Notify of a global object removal
*
@@ -376,10 +380,11 @@ struct pw_registry_events {
};
static inline void
-pw_registry_proxy_add_listener(pw_registry_proxy_t *registry, void *object,
- const struct pw_registry_events *listener, pw_destroy_t destroy)
+pw_registry_proxy_add_listener(struct pw_registry_proxy *registry,
+ struct pw_interface_listener *listener,
+ void *object, const struct pw_registry_events *events)
{
- pw_proxy_add_listener(registry, object, listener, destroy);
+ pw_proxy_add_listener(&registry->proxy, listener, object, events);
}
#define pw_registry_resource_global(r,...) pw_resource_notify(r,struct pw_registry_events,global,__VA_ARGS__)
@@ -404,10 +409,11 @@ struct pw_module_events {
};
static inline void
-pw_module_proxy_add_listener(pw_module_proxy_t *module, void *object,
- const struct pw_module_events *listener, pw_destroy_t destroy)
+pw_module_proxy_add_listener(struct pw_module_proxy *module,
+ struct pw_interface_listener *listener,
+ void *object, const struct pw_module_events *events)
{
- pw_proxy_add_listener(module, object, listener, destroy);
+ pw_proxy_add_listener(&module->proxy, listener, object, events);
}
#define pw_module_resource_info(r,...) pw_resource_notify(r,struct pw_module_events,info,__VA_ARGS__)
@@ -430,10 +436,11 @@ struct pw_node_events {
};
static inline void
-pw_node_proxy_add_listener(pw_node_proxy_t *node, void *object,
- const struct pw_node_events *listener, pw_destroy_t destroy)
+pw_node_proxy_add_listener(struct pw_node_proxy *node,
+ struct pw_interface_listener *listener,
+ void *object, const struct pw_node_events *events)
{
- pw_proxy_add_listener(node, object, listener, destroy);
+ pw_proxy_add_listener(&node->proxy, listener, object, events);
}
#define pw_node_resource_info(r,...) pw_resource_notify(r,struct pw_node_events,info,__VA_ARGS__)
@@ -457,10 +464,11 @@ struct pw_client_events {
/** Client */
static inline void
-pw_client_proxy_add_listener(pw_client_proxy_t *client, void *object,
- const struct pw_client_events *listener, pw_destroy_t destroy)
+pw_client_proxy_add_listener(struct pw_client_proxy *client,
+ struct pw_interface_listener *listener,
+ void *object, const struct pw_client_events *events)
{
- pw_proxy_add_listener(client, object, listener, destroy);
+ pw_proxy_add_listener(&client->proxy, listener, object, events);
}
#define pw_client_resource_info(r,...) pw_resource_notify(r,struct pw_client_events,info,__VA_ARGS__)
@@ -485,10 +493,11 @@ struct pw_link_events {
/** Link */
static inline void
-pw_link_proxy_add_listener(pw_link_proxy_t *link, void *object,
- const struct pw_link_events *listener, pw_destroy_t destroy)
+pw_link_proxy_add_listener(struct pw_link_proxy *link,
+ struct pw_interface_listener *listener,
+ void *object, const struct pw_link_events *events)
{
- pw_proxy_add_listener(link, object, listener, destroy);
+ pw_proxy_add_listener(&link->proxy, listener, object, events);
}
#define pw_link_resource_info(r,...) pw_resource_notify(r,struct pw_link_events,info,__VA_ARGS__)
diff --git a/src/pipewire/introspect.c b/src/pipewire/introspect.c
index 02e4b811..e6d0d7cc 100644
--- a/src/pipewire/introspect.c
+++ b/src/pipewire/introspect.c
@@ -125,7 +125,6 @@ struct pw_core_info *pw_core_info_update(struct pw_core_info *info,
if (info == NULL)
return NULL;
}
- info->id = update->id;
info->change_mask = update->change_mask;
if (update->change_mask & (1 << 0)) {
@@ -186,7 +185,6 @@ struct pw_node_info *pw_node_info_update(struct pw_node_info *info,
if (info == NULL)
return NULL;
}
- info->id = update->id;
info->change_mask = update->change_mask;
if (update->change_mask & (1 << 0)) {
@@ -283,7 +281,6 @@ struct pw_module_info *pw_module_info_update(struct pw_module_info *info,
if (info == NULL)
return NULL;
}
- info->id = update->id;
info->change_mask = update->change_mask;
if (update->change_mask & (1 << 0)) {
@@ -334,7 +331,6 @@ struct pw_client_info *pw_client_info_update(struct pw_client_info *info,
if (info == NULL)
return NULL;
}
- info->id = update->id;
info->change_mask = update->change_mask;
if (update->change_mask & (1 << 0)) {
@@ -363,7 +359,6 @@ struct pw_link_info *pw_link_info_update(struct pw_link_info *info,
if (info == NULL)
return NULL;
}
- info->id = update->id;
info->change_mask = update->change_mask;
if (update->change_mask & (1 << 0))
diff --git a/src/pipewire/introspect.h b/src/pipewire/introspect.h
index dd0d772e..68e272d0 100644
--- a/src/pipewire/introspect.h
+++ b/src/pipewire/introspect.h
@@ -74,7 +74,6 @@ const char * pw_link_state_as_string(enum pw_link_state state);
/** The core information. Extra information can be added in later versions \memberof pw_introspect */
struct pw_core_info {
- uint32_t id; /**< server side id of the core */
#define PW_CORE_CHANGE_MASK_USER_NAME (1 << 0)
#define PW_CORE_CHANGE_MASK_HOST_NAME (1 << 1)
#define PW_CORE_CHANGE_MASK_VERSION (1 << 2)
@@ -101,7 +100,6 @@ void pw_core_info_free(struct pw_core_info *info);
/** The module information. Extra information can be added in later versions \memberof pw_introspect */
struct pw_module_info {
- uint32_t id; /**< server side id of the module */
uint64_t change_mask; /**< bitfield of changed fields since last call */
const char *name; /**< name of the module */
const char *filename; /**< filename of the module */
@@ -119,7 +117,6 @@ void pw_module_info_free(struct pw_module_info *info);
/** The client information. Extra information can be added in later versions \memberof pw_introspect */
struct pw_client_info {
- uint32_t id; /**< server side id of the client */
uint64_t change_mask; /**< bitfield of changed fields since last call */
struct spa_dict *props; /**< extra properties */
};
@@ -135,7 +132,6 @@ void pw_client_info_free(struct pw_client_info *info);
/** The node information. Extra information can be added in later versions \memberof pw_introspect */
struct pw_node_info {
- uint32_t id; /**< server side id of the node */
uint64_t change_mask; /**< bitfield of changed fields since last call */
const char *name; /**< name the node, suitable for display */
uint32_t max_input_ports; /**< maximum number of inputs */
@@ -161,7 +157,6 @@ pw_node_info_free(struct pw_node_info *info);
/** The link information. Extra information can be added in later versions \memberof pw_introspect */
struct pw_link_info {
- uint32_t id; /**< server side id of the link */
uint64_t change_mask; /**< bitfield of changed fields since last call */
uint32_t output_node_id; /**< server side output node id */
uint32_t output_port_id; /**< output port id */
diff --git a/src/pipewire/link.c b/src/pipewire/link.c
index 445feb26..cd139bc6 100644
--- a/src/pipewire/link.c
+++ b/src/pipewire/link.c
@@ -38,6 +38,8 @@
struct impl {
struct pw_link this;
+ struct pw_global_info global_info[1];
+
bool active;
struct pw_work_queue *work;
@@ -939,25 +941,28 @@ static void link_unbind_func(void *data)
}
static int
-link_bind_func(struct pw_global *global, struct pw_client *client,
- const char *type, uint32_t version, uint32_t id)
+link_bind_func(struct pw_global *global,
+ struct pw_global_info *info,
+ struct pw_client *client,
+ uint32_t version, uint32_t id)
{
- struct pw_link *this = global->object;
+ struct pw_link *this = info->object;
struct pw_resource *resource;
- resource = pw_resource_new(client, id, type, version, 0);
+ resource = pw_resource_new(client, id, info->iface.type, version, 0);
if (resource == NULL)
goto no_mem;
- pw_resource_set_implementation(resource, global->object, NULL, link_unbind_func);
+ pw_resource_set_implementation(resource, info->object, NULL, link_unbind_func);
- pw_log_debug("link %p: bound to %d", global->object, resource->id);
+ pw_log_debug("link %p: bound to %d", this, resource->id);
spa_list_insert(this->resource_list.prev, &resource->link);
this->info.change_mask = ~0;
pw_link_resource_info(resource, &this->info);
+ this->info.change_mask = 0;
return SPA_RESULT_OK;
@@ -1058,14 +1063,22 @@ struct pw_link *pw_link_new(struct pw_core *core,
spa_list_insert(core->link_list.prev, &this->link);
+#if 0
pw_core_add_global(core, NULL, core->type.link,
SPA_N_ELEMENTS(link_ifaces),
link_ifaces,
this,
link_bind_func,
&this->global);
+#endif
+
+ this->n_global_info = 1;
+ this->global_info = impl->global_info;
+ impl->global_info[0].iface.type = PW_TYPE_INTERFACE__Link;
+ impl->global_info[0].iface.version = PW_VERSION_LINK;
+ impl->global_info[0].bind = link_bind_func;
+ impl->global_info[0].object = this;
- this->info.id = this->global->id;
this->info.output_node_id = output ? output_node->global->id : -1;
this->info.output_port_id = output ? output->port_id : -1;
this->info.input_node_id = input ? input_node->global->id : -1;
diff --git a/src/pipewire/link.h b/src/pipewire/link.h
index dbd6e564..301c0ae7 100644
--- a/src/pipewire/link.h
+++ b/src/pipewire/link.h
@@ -57,6 +57,9 @@ struct pw_link {
struct spa_list link; /**< link in core link_list */
struct pw_global *global; /**< global for this link */
+ uint32_t n_global_info;
+ struct pw_global_info *global_info;
+
struct pw_properties *properties; /**< extra link properties */
struct pw_link_info info; /**< introspectable link info */
diff --git a/src/pipewire/module.c b/src/pipewire/module.c
index a78e780e..ec09bd4f 100644
--- a/src/pipewire/module.c
+++ b/src/pipewire/module.c
@@ -37,6 +37,7 @@
struct impl {
struct pw_module this;
void *hnd;
+ struct pw_global_info global_info[1];
};
/** \endcond */
@@ -88,22 +89,25 @@ static char *find_module(const char *path, const char *name)
}
static int
-module_bind_func(struct pw_global *global, struct pw_client *client,
- const char *type, uint32_t version, uint32_t id)
+module_bind_func(struct pw_global *global,
+ struct pw_global_info *info,
+ struct pw_client *client,
+ uint32_t version, uint32_t id)
{
- struct pw_module *this = global->object;
+ struct pw_module *this = info->object;
struct pw_resource *resource;
- resource = pw_resource_new(client, id, type, version, 0);
+ resource = pw_resource_new(client, id, info->iface.type, version, 0);
if (resource == NULL)
goto no_mem;
- pw_resource_set_implementation(resource, global->object, NULL, NULL);
+ pw_resource_set_implementation(resource, info->object, NULL, NULL);
- pw_log_debug("module %p: bound to %d", global->object, resource->id);
+ pw_log_debug("module %p: bound to %d", this, resource->id);
this->info.change_mask = ~0;
pw_module_resource_info(resource, &this->info);
+ this->info.change_mask = 0;
return SPA_RESULT_OK;
@@ -114,10 +118,6 @@ module_bind_func(struct pw_global *global, struct pw_client *client,
return SPA_RESULT_NO_MEMORY;
}
-static const struct pw_interface_info module_ifaces[] = {
- { PW_TYPE_INTERFACE__Module, PW_VERSION_MODULE }
-};
-
/** Load a module
*
* \param core a \ref pw_core
@@ -185,12 +185,20 @@ struct pw_module *pw_module_load(struct pw_core *core,
if (!init_func(this, (char *) args))
goto init_failed;
+#if 0
pw_core_add_global(core, NULL, core->type.module,
SPA_N_ELEMENTS(module_ifaces),
module_ifaces,
impl, module_bind_func, &this->global);
+#endif
+
+ this->n_global_info = 1;
+ this->global_info = impl->global_info;
+ impl->global_info[0].iface.type = PW_TYPE_INTERFACE__Module;
+ impl->global_info[0].iface.version = PW_VERSION_MODULE;
+ impl->global_info[0].bind = module_bind_func;
+ impl->global_info[0].object = this;
- this->info.id = this->global->id;
this->info.name = name ? strdup(name) : NULL;
this->info.filename = filename;
this->info.args = args ? strdup(args) : NULL;
diff --git a/src/pipewire/module.h b/src/pipewire/module.h
index 7dab7b4c..ac5f8341 100644
--- a/src/pipewire/module.h
+++ b/src/pipewire/module.h
@@ -39,7 +39,10 @@ extern "C" {
struct pw_module {
struct pw_core *core; /**< the core object */
struct spa_list link; /**< link in the core module_list */
- struct pw_global *global; /**< global object for this module */
+// struct pw_global *global; /**< global object for this module */
+
+ uint32_t n_global_info;
+ struct pw_global_info *global_info;
struct pw_module_info info; /**< introspectable module info */
diff --git a/src/pipewire/node.c b/src/pipewire/node.c
index 7805062c..3bb13c74 100644
--- a/src/pipewire/node.c
+++ b/src/pipewire/node.c
@@ -39,6 +39,8 @@ struct impl {
struct pw_listener on_event;
bool exported;
+
+ struct pw_global_info global_info[1];
};
/** \endcond */
@@ -151,7 +153,6 @@ static void node_unbind_func(void *data)
static void
update_info(struct pw_node *this)
{
- this->info.id = this->global->id;
this->info.input_formats = NULL;
if (!spa_list_is_empty(&this->input_ports)) {
@@ -211,17 +212,19 @@ clear_info(struct pw_node *this)
}
static int
-node_bind_func(struct pw_global *global, struct pw_client *client,
- const char *type, uint32_t version, uint32_t id)
+node_bind_func(struct pw_global *global,
+ struct pw_global_info *info,
+ struct pw_client *client,
+ uint32_t version, uint32_t id)
{
- struct pw_node *this = global->object;
+ struct pw_node *this = info->object;
struct pw_resource *resource;
- resource = pw_resource_new(client, id, type, version, 0);
+ resource = pw_resource_new(client, id, info->type, version, 0);
if (resource == NULL)
goto no_mem;
- pw_resource_set_implementation(resource, global->object, NULL, node_unbind_func);
+ pw_resource_set_implementation(resource, info->object, NULL, node_unbind_func);
pw_log_debug("node %p: bound to %d", this, resource->id);
@@ -252,10 +255,6 @@ do_node_add(struct spa_loop *loop,
}
-static const struct pw_interface_info node_ifaces[] = {
- { PW_TYPE_INTERFACE__Node, PW_VERSION_NODE }
-};
-
void pw_node_export(struct pw_node *this)
{
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
@@ -264,10 +263,19 @@ void pw_node_export(struct pw_node *this)
spa_list_insert(this->core->node_list.prev, &this->link);
+#if 0
pw_core_add_global(this->core, this->owner, this->core->type.node,
SPA_N_ELEMENTS(node_ifaces),
node_ifaces,
this, node_bind_func, &this->global);
+#endif
+
+ this->n_global_info = 1;
+ this->global_info = impl->global_info;
+ impl->global_info[0].type = PW_TYPE_INTERFACE__Node;
+ impl->global_info[0].version = PW_VERSION_NODE;
+ impl->global_info[0].bind = node_bind_func;
+ impl->global_info[0].object = this;
pw_loop_invoke(this->data_loop, do_node_add, 1, 0, NULL, false, this);
@@ -394,8 +402,8 @@ void pw_node_destroy(struct pw_node *node)
if (impl->exported) {
spa_list_remove(&node->link);
- pw_global_destroy(node->global);
- node->global = NULL;
+ //pw_global_destroy(node->global);
+ //node->global = NULL;
}
spa_list_for_each_safe(resource, tmp, &node->resource_list, link)
diff --git a/src/pipewire/node.h b/src/pipewire/node.h
index 20e3b9c1..94fd4543 100644
--- a/src/pipewire/node.h
+++ b/src/pipewire/node.h
@@ -79,6 +79,9 @@ struct pw_node {
struct spa_list link; /**< link in core node_list */
struct pw_global *global; /**< global for this node */
+ uint32_t n_global_info;
+ struct pw_global_info *global_info;
+
struct pw_resource *owner; /**< owner resource if any */
struct pw_properties *properties; /**< properties of the node */
diff --git a/src/pipewire/protocol.c b/src/pipewire/protocol.c
index bf256425..8c7bba7e 100644
--- a/src/pipewire/protocol.c
+++ b/src/pipewire/protocol.c
@@ -23,6 +23,11 @@ struct impl {
struct pw_protocol this;
};
+struct marshal {
+ struct spa_list link;
+ const struct pw_protocol_marshal *marshal;
+};
+
struct pw_protocol *pw_protocol_new(struct pw_core *core,
const char *name,
size_t user_data_size)
@@ -36,7 +41,7 @@ struct pw_protocol *pw_protocol_new(struct pw_core *core,
protocol->core = core;
protocol->name = strdup(name);
- spa_list_init(&protocol->iface_list);
+ spa_list_init(&protocol->marshal_list);
spa_list_init(&protocol->connection_list);
spa_list_init(&protocol->listener_list);
@@ -55,7 +60,7 @@ struct pw_protocol *pw_protocol_new(struct pw_core *core,
void pw_protocol_destroy(struct pw_protocol *protocol)
{
struct impl *impl = SPA_CONTAINER_OF(protocol, struct impl, this);
- struct pw_protocol_iface *iface, *t1;
+ struct marshal *marshal, *t1;
struct pw_protocol_listener *listener, *t2;
struct pw_protocol_connection *connection, *t3;
@@ -64,8 +69,8 @@ void pw_protocol_destroy(struct pw_protocol *protocol)
spa_list_remove(&protocol->link);
- spa_list_for_each_safe(iface, t1, &protocol->iface_list, link)
- free(iface);
+ spa_list_for_each_safe(marshal, t1, &protocol->marshal_list, link)
+ free(marshal);
spa_list_for_each_safe(listener, t2, &protocol->listener_list, link)
pw_protocol_listener_destroy(listener);
@@ -82,41 +87,31 @@ void pw_protocol_destroy(struct pw_protocol *protocol)
}
void
-pw_protocol_add_interfaces(struct pw_protocol *protocol,
- const struct pw_interface *client_iface,
- const struct pw_interface *server_iface)
+pw_protocol_add_marshal(struct pw_protocol *protocol,
+ const struct pw_protocol_marshal *marshal)
{
- struct pw_protocol_iface *iface;
- const char *type;
- uint32_t version;
-
- iface = calloc(1, sizeof(struct pw_protocol_iface));
- iface->client_iface = client_iface;
- iface->server_iface = server_iface;
+ struct marshal *impl;
- spa_list_insert(protocol->iface_list.prev, &iface->link);
+ impl = calloc(1, sizeof(struct marshal));
+ impl->marshal = marshal;
- type = client_iface ? client_iface->type : server_iface->type;
- version = client_iface ? client_iface->version : server_iface->version;
+ spa_list_insert(protocol->marshal_list.prev, &impl->link);
- pw_log_info("Add iface %s:%d to protocol %s", type, version, protocol->name);
+ pw_log_info("Add marshal %s:%d to protocol %s", marshal->type, marshal->version, protocol->name);
}
-const struct pw_interface *
-pw_protocol_get_interface(struct pw_protocol *protocol,
- const char *type,
- bool server)
+const struct pw_protocol_marshal *
+pw_protocol_get_marshal(struct pw_protocol *protocol,
+ const char *type)
{
- struct pw_protocol_iface *protocol_iface;
+ struct marshal *marshal;
if (protocol == NULL)
return NULL;
- spa_list_for_each(protocol_iface, &protocol->iface_list, link) {
- const struct pw_interface *iface = server ? protocol_iface->server_iface :
- protocol_iface->client_iface;
- if (strcmp(iface->type, type) == 0)
- return iface;
+ spa_list_for_each(marshal, &protocol->marshal_list, link) {
+ if (strcmp(marshal->marshal->type, type) == 0)
+ return marshal->marshal;
}
return NULL;
}
diff --git a/src/pipewire/protocol.h b/src/pipewire/protocol.h
index 8d383c08..126ea18d 100644
--- a/src/pipewire/protocol.h
+++ b/src/pipewire/protocol.h
@@ -63,10 +63,15 @@ struct pw_protocol_listener {
#define pw_protocol_listener_destroy(l) ((l)->destroy(l))
-struct pw_protocol_iface {
- struct spa_list link;
- const struct pw_interface *client_iface;
- const struct pw_interface *server_iface;
+struct pw_protocol_marshal {
+ const char *type; /**< interface type */
+ uint32_t version; /**< version */
+ uint32_t n_methods; /**< number of methods in the interface */
+ const void *method_marshal;
+ const void *method_demarshal;
+ uint32_t n_events; /**< number of events in the interface */
+ const void *event_marshal;
+ const void *event_demarshal;
};
struct pw_protocol_implementaton {
@@ -86,7 +91,7 @@ struct pw_protocol {
char *name; /**< type name of the protocol */
- struct spa_list iface_list; /**< list of supported interfaces */
+ struct spa_list marshal_list; /**< list of marshallers for supported interfaces */
struct spa_list connection_list; /**< list of current connections */
struct spa_list listener_list; /**< list of current listeners */
@@ -104,9 +109,7 @@ struct pw_protocol {
#define pw_protocol_new_connection(p,...) ((p)->implementation->new_connection(p,__VA_ARGS__))
#define pw_protocol_add_listener(p,...) ((p)->implementation->add_listener(p,__VA_ARGS__))
-#define pw_protocol_ext(p,type,method,...) ((type*)(p)->extension)->method( __VA_ARGS__)
-#define pw_protocol_connection_ext(c,type,method,...) ((type*)(c)->protocol->extension)->method( __VA_ARGS__)
-#define pw_protocol_listener_ext(l,type,method,...) ((type*)(l)->protocol->extension)->method( __VA_ARGS__)
+#define pw_protocol_ext(p,type,method,...) (((type*)(p)->extension)->method( __VA_ARGS__))
struct pw_protocol *pw_protocol_new(struct pw_core *core, const char *name, size_t user_data_size);
@@ -114,13 +117,11 @@ struct pw_protocol *pw_protocol_new(struct pw_core *core, const char *name, size
*
* \brief Manages protocols and their implementation
*/
-void
-pw_protocol_add_interfaces(struct pw_protocol *protocol,
- const struct pw_interface *client_iface,
- const struct pw_interface *server_iface);
+void pw_protocol_add_marshal(struct pw_protocol *protocol,
+ const struct pw_protocol_marshal *marshal);
-const struct pw_interface *
-pw_protocol_get_interface(struct pw_protocol *protocol, const char *type, bool server);
+const struct pw_protocol_marshal *
+pw_protocol_get_marshal(struct pw_protocol *protocol, const char *type);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/src/pipewire/proxy.c b/src/pipewire/proxy.c
index c6a44f84..60523da6 100644
--- a/src/pipewire/proxy.c
+++ b/src/pipewire/proxy.c
@@ -25,6 +25,7 @@
/** \cond */
struct proxy {
struct pw_proxy this;
+ struct pw_interface_listener listener;
};
/** \endcond */
@@ -44,8 +45,9 @@ struct proxy {
*/
struct pw_proxy *pw_proxy_new(struct pw_remote *remote,
uint32_t id,
- const char *type,
- size_t user_data_size)
+ uint32_t type,
+ size_t user_data_size,
+ pw_destroy_t destroy)
{
struct proxy *impl;
struct pw_proxy *this;
@@ -65,11 +67,19 @@ struct pw_proxy *pw_proxy_new(struct pw_remote *remote,
goto in_use;
this->id = id;
+ this->destroy = destroy;
if (user_data_size > 0)
this->user_data = SPA_MEMBER(impl, sizeof(struct proxy), void);
- this->iface = pw_protocol_get_interface(remote->conn->protocol, type, false);
+ this->marshal = pw_protocol_get_marshal(remote->conn->protocol,
+ spa_type_map_get_type(remote->core->map, type));
+
+ pw_interface_init(&this->iface,
+ type,
+ this->marshal->version,
+ this->marshal->n_methods, this->marshal->method_marshal,
+ this->marshal->n_events);
spa_list_insert(&this->remote->proxy_list, &this->link);
@@ -83,15 +93,13 @@ struct pw_proxy *pw_proxy_new(struct pw_remote *remote,
return NULL;
}
-int pw_proxy_add_listener(struct pw_proxy *proxy,
- void *object,
- const void *listener,
- pw_destroy_t destroy)
+void pw_proxy_add_listener(struct pw_proxy *proxy,
+ struct pw_interface_listener *listener,
+ void *object, const void *events)
{
- proxy->object = object;
- proxy->listener = listener;
- proxy->destroy = destroy;
- return SPA_RESULT_OK;
+ listener->object = object;
+ listener->events = events;
+ pw_interface_add_listener(&proxy->iface, listener);
}
/** Destroy a proxy object
diff --git a/src/pipewire/proxy.h b/src/pipewire/proxy.h
index 1ed2182f..41e1a756 100644
--- a/src/pipewire/proxy.h
+++ b/src/pipewire/proxy.h
@@ -26,6 +26,7 @@ extern "C" {
#include <pipewire/type.h>
#include <pipewire/utils.h>
+#include <pipewire/object.h>
struct pw_remote;
@@ -92,16 +93,15 @@ struct pw_proxy {
struct spa_list link; /**< link in the remote */
uint32_t id; /**< client side id */
- const struct pw_interface *iface; /**< methods/events marshal/demarshal functions */
+ struct pw_interface iface; /**< interface */
- void *object; /**< client side object */
- const void *listener; /**< event handler listener */
- pw_destroy_t destroy; /**< optional destroy function to clean up the object */
+ const struct pw_protocol_marshal *marshal;
/** destroy is emited when the proxy is destroyed */
PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_proxy *proxy));
void *user_data; /**< extra user data */
+ pw_destroy_t destroy; /**< optional destroy function to clean up the user_data */
};
/** Make a new proxy object. The id can be used to bind to a remote object. */
@@ -109,20 +109,21 @@ struct pw_proxy *
pw_proxy_new(struct pw_remote *remote, /**< remote this proxy is from */
uint32_t id, /**< local id, SPA_ID_INVALID to have one automatically
* allocated for you */
- const char *type, /**< interface type */
- size_t user_data_size /**< size of user data */);
+ uint32_t type, /**< interface type id */
+ size_t user_data_size, /**< size of user data */
+ pw_destroy_t destroy /**< destroy function for user data */);
-int
+void
pw_proxy_add_listener(struct pw_proxy *proxy,
- void *object, const void *listener,
- pw_destroy_t destroy);
+ struct pw_interface_listener *listener,
+ void *object, const void *events);
void pw_proxy_destroy(struct pw_proxy *proxy);
-#define pw_proxy_notify(p,type,event,...) ((type*) (p)->listener)->event(p, __VA_ARGS__)
-#define pw_proxy_notify_na(p,type,event) ((type*) (p)->listener)->event(p)
-#define pw_proxy_do(p,type,method,...) ((type*) (p)->iface->methods)->method(p, __VA_ARGS__)
-#define pw_proxy_do_na(p,type,method) ((type*) (p)->iface->methods)->method(p)
+#define pw_proxy_notify(p,type,event,...) pw_interface_notify(&(p)->iface,type,event,__VA_ARGS__)
+#define pw_proxy_notify_na(p,type,event) pw_interface_notify_na(&(p)->iface,type,event)
+#define pw_proxy_do(p,type,method,...) pw_interface_call(&(p)->iface,p,type,method,__VA_ARGS__)
+#define pw_proxy_do_na(p,type,method) pw_interface_call_na(&(p)->iface,p,type,method)
#ifdef __cplusplus
}
diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c
index 38459535..bf9a11b7 100644
--- a/src/pipewire/remote.c
+++ b/src/pipewire/remote.c
@@ -38,6 +38,7 @@
/** \cond */
struct remote {
struct pw_remote this;
+ struct pw_interface_listener core_events;
};
/** \endcond */
@@ -86,8 +87,7 @@ remote_update_state(struct pw_remote *remote, enum pw_remote_state state, const
static void core_event_info(void *object, struct pw_core_info *info)
{
- struct pw_proxy *proxy = object;
- struct pw_remote *this = proxy->remote;
+ struct pw_remote *this = object;
pw_log_debug("got core info");
this->info = pw_core_info_update(this->info, info);
@@ -96,8 +96,7 @@ static void core_event_info(void *object, struct pw_core_info *info)
static void core_event_done(void *object, uint32_t seq)
{
- struct pw_proxy *proxy = object;
- struct pw_remote *this = proxy->remote;
+ struct pw_remote *this = object;
pw_log_debug("core event done %d", seq);
if (seq == 0)
@@ -108,15 +107,13 @@ static void core_event_done(void *object, uint32_t seq)
static void core_event_error(void *object, uint32_t id, int res, const char *error, ...)
{
- struct pw_proxy *proxy = object;
- struct pw_remote *this = proxy->remote;
+ struct pw_remote *this = object;
remote_update_state(this, PW_REMOTE_STATE_ERROR, error);
}
static void core_event_remove_id(void *object, uint32_t id)
{
- struct pw_proxy *core_proxy = object;
- struct pw_remote *this = core_proxy->remote;
+ struct pw_remote *this = object;
struct pw_proxy *proxy;
proxy = pw_map_lookup(&this->objects, id);
@@ -129,8 +126,7 @@ static void core_event_remove_id(void *object, uint32_t id)
static void
core_event_update_types(void *object, uint32_t first_id, uint32_t n_types, const char **types)
{
- struct pw_proxy *proxy = object;
- struct pw_remote *this = proxy->remote;
+ struct pw_remote *this = object;
int i;
for (i = 0; i < n_types; i++, first_id++) {
@@ -231,11 +227,13 @@ void pw_remote_destroy(struct pw_remote *remote)
static int do_connect(struct pw_remote *remote)
{
- remote->core_proxy = pw_proxy_new(remote, 0, PW_TYPE_INTERFACE__Core, 0);
+ struct remote *impl = SPA_CONTAINER_OF(remote, struct remote, this);
+
+ remote->core_proxy = (struct pw_core_proxy*)pw_proxy_new(remote, 0, PW_TYPE_INTERFACE__Core, 0, NULL);
if (remote->core_proxy == NULL)
goto no_proxy;
- pw_proxy_add_listener(remote->core_proxy, remote, &core_events, NULL);
+ pw_proxy_add_listener((struct pw_proxy*)remote->core_proxy, &impl->core_events, remote, &core_events);
pw_core_proxy_client_update(remote->core_proxy, &remote->properties->dict);
pw_core_proxy_sync(remote->core_proxy, 0);
diff --git a/src/pipewire/remote.h b/src/pipewire/remote.h
index fb1abca5..885ee3e8 100644
--- a/src/pipewire/remote.h
+++ b/src/pipewire/remote.h
@@ -124,7 +124,7 @@ struct pw_remote {
struct spa_list link; /**< link in core remote_list */
struct pw_properties *properties; /**< extra properties */
- pw_core_proxy_t *core_proxy; /**< proxy for the core object */
+ struct pw_core_proxy *core_proxy; /**< proxy for the core object */
struct pw_map objects; /**< map of client side proxy objects
* indexed with the client id */
struct pw_core_info *info; /**< info about the remote core */
diff --git a/src/pipewire/resource.c b/src/pipewire/resource.c
index addcc070..99f166f5 100644
--- a/src/pipewire/resource.c
+++ b/src/pipewire/resource.c
@@ -26,6 +26,8 @@
/** \cond */
struct impl {
struct pw_resource this;
+
+ struct pw_interface_listener listener;
};
/** \endcond */
@@ -60,7 +62,16 @@ struct pw_resource *pw_resource_new(struct pw_client *client,
if (user_data_size > 0)
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
- this->iface = pw_protocol_get_interface(client->protocol, type, true);
+ this->marshal = pw_protocol_get_marshal(client->protocol, type);
+ pw_interface_init(&this->iface,
+ this->marshal->type,
+ this->marshal->version,
+ this->marshal->n_methods, NULL,
+ this->marshal->n_events);
+
+ impl->listener.events = this->marshal->event_marshal;
+ impl->listener.object = this;
+ pw_interface_add_listener(&this->iface, &impl->listener);
pw_log_debug("resource %p: new for client %p id %u", this, client, id);
pw_signal_emit(&client->resource_added, client, this);
@@ -82,7 +93,7 @@ pw_resource_set_implementation(struct pw_resource *resource,
struct pw_client *client = resource->client;
resource->object = object;
- resource->implementation = implementation;
+ resource->iface.methods = implementation;
resource->destroy = destroy;
pw_signal_emit(&client->resource_impl, client, resource);
diff --git a/src/pipewire/resource.h b/src/pipewire/resource.h
index 91153e29..052351da 100644
--- a/src/pipewire/resource.h
+++ b/src/pipewire/resource.h
@@ -32,6 +32,7 @@ extern "C" {
#include <pipewire/sig.h>
#include <pipewire/utils.h>
#include <pipewire/core.h>
+#include <pipewire/object.h>
/** \page page_resource Resource
*
@@ -66,12 +67,14 @@ struct pw_resource {
uint32_t id; /**< per client unique id, index in client objects */
const char *type; /**< interface of the resource */
uint32_t version; /**< version of the client interface */
- const struct pw_interface *iface; /**< protocol specific interface functions */
+ struct pw_interface iface; /**< protocol specific interface functions */
+
+ void *object;
- void *object; /**< pointer to the object */
- const void *implementation; /**< method implementation */
pw_destroy_t destroy; /**< function to clean up the object */
+ const struct pw_protocol_marshal *marshal;
+
/** Emited when the resource is destroyed */
PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_resource *resource));
@@ -96,10 +99,10 @@ pw_resource_set_implementation(struct pw_resource *resource,
void
pw_resource_destroy(struct pw_resource *resource);
-#define pw_resource_do(r,type,method,...) ((type*) r->implementation)->method(r, __VA_ARGS__)
-#define pw_resource_do_na(r,type,method) ((type*) r->implementation)->method(r)
-#define pw_resource_notify(r,type,event,...) ((type*) r->iface->events)->event(r, __VA_ARGS__)
-#define pw_resource_notify_na(r,type,event) ((type*) r->iface->events)->event(r)
+#define pw_resource_do(r,type,method,...) pw_interface_call(&(r)->iface,r,type,method,__VA_ARGS__)
+#define pw_resource_do_na(r,type,method) pw_interface_call_na(&(r)->iface,r,type,method)
+#define pw_resource_notify(r,type,event,...) pw_interface_notify(&(r)->iface,type,event,__VA_ARGS__)
+#define pw_resource_notify_na(r,type,event) pw_interface_notify_na(&(r)->iface,type,event)
#ifdef __cplusplus
}
diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c
index e6aa1140..76e5c862 100644
--- a/src/pipewire/stream.c
+++ b/src/pipewire/stream.c
@@ -62,6 +62,8 @@ struct buffer_id {
struct stream {
struct pw_stream this;
+ struct pw_interface_listener listener;
+
uint32_t n_possible_formats;
struct spa_format **possible_formats;
@@ -80,7 +82,7 @@ struct stream {
int rtwritefd;
struct spa_source *rtsocket_source;
- pw_client_node_proxy_t *node_proxy;
+ struct pw_client_node_proxy *node_proxy;
bool disconnecting;
struct pw_listener node_proxy_destroy;
struct pw_listener node_proxy_sync_done;
@@ -640,8 +642,7 @@ client_node_set_format(void *object,
enum spa_direction direction,
uint32_t port_id, uint32_t flags, const struct spa_format *format)
{
- struct pw_proxy *proxy = object;
- struct pw_stream *stream = proxy->object;
+ struct pw_stream *stream = object;
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
pw_log_debug("stream %p: format changed %d", stream, seq);
@@ -676,8 +677,7 @@ client_node_add_mem(void *object,
uint32_t mem_id,
uint32_t type, int memfd, uint32_t flags, uint32_t offset, uint32_t size)
{
- struct pw_proxy *proxy = object;
- struct pw_stream *stream = proxy->object;
+ struct pw_stream *stream = object;
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
struct mem_id *m;
@@ -705,8 +705,7 @@ client_node_use_buffers(void *object,
enum spa_direction direction,
uint32_t port_id, uint32_t n_buffers, struct pw_client_node_buffer *buffers)
{
- struct pw_proxy *proxy = object;
- struct pw_stream *stream = proxy->object;
+ struct pw_stream *stream = object;
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
struct buffer_id *bid;
uint32_t i, j, len;
@@ -817,8 +816,7 @@ client_node_use_buffers(void *object,
static void client_node_node_command(void *object, uint32_t seq, const struct spa_command *command)
{
- struct pw_proxy *proxy = object;
- struct pw_stream *stream = proxy->object;
+ struct pw_stream *stream = object;
handle_node_command(stream, seq, command);
}
@@ -834,8 +832,7 @@ client_node_port_command(void *object,
static void client_node_transport(void *object, uint32_t node_id,
int readfd, int writefd, int memfd, uint32_t offset, uint32_t size)
{
- struct pw_proxy *proxy = object;
- struct pw_stream *stream = proxy->object;
+ struct pw_stream *stream = object;
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
struct pw_transport_info info;
@@ -916,13 +913,14 @@ pw_stream_connect(struct pw_stream *stream,
"client-node",
PW_TYPE_INTERFACE__ClientNode,
PW_VERSION_CLIENT_NODE,
- &stream->properties->dict, 0);
+ &stream->properties->dict, 0, NULL);
if (impl->node_proxy == NULL)
return false;
- pw_client_node_proxy_add_listener(impl->node_proxy, stream, &client_node_events, NULL);
+ pw_client_node_proxy_add_listener(impl->node_proxy, &impl->listener,
+ stream, &client_node_events);
- pw_signal_add(&impl->node_proxy->destroy_signal,
+ pw_signal_add(&impl->node_proxy->proxy.destroy_signal,
&impl->node_proxy_destroy, on_node_proxy_destroy);
do_node_init(stream);
diff --git a/src/pipewire/type.c b/src/pipewire/type.c
index 4355e3b3..6fedddd4 100644
--- a/src/pipewire/type.c
+++ b/src/pipewire/type.c
@@ -39,12 +39,12 @@ void pw_type_init(struct pw_type *type)
{
type->map = pw_get_support_interface(SPA_TYPE__TypeMap);
- type->core = spa_type_map_get_id(type->map, PW_TYPE__Core);
- type->node = spa_type_map_get_id(type->map, PW_TYPE__Node);
+ type->core = spa_type_map_get_id(type->map, PW_TYPE_INTERFACE__Core);
+ type->node = spa_type_map_get_id(type->map, PW_TYPE_INTERFACE__Node);
type->node_factory = spa_type_map_get_id(type->map, PW_TYPE__NodeFactory);
- type->link = spa_type_map_get_id(type->map, PW_TYPE__Link);
- type->client = spa_type_map_get_id(type->map, PW_TYPE__Client);
- type->module = spa_type_map_get_id(type->map, PW_TYPE__Module);
+ type->link = spa_type_map_get_id(type->map, PW_TYPE_INTERFACE__Link);
+ type->client = spa_type_map_get_id(type->map, PW_TYPE_INTERFACE__Client);
+ type->module = spa_type_map_get_id(type->map, PW_TYPE_INTERFACE__Module);
type->spa_log = spa_type_map_get_id(type->map, SPA_TYPE__Log);
type->spa_node = spa_type_map_get_id(type->map, SPA_TYPE__Node);
diff --git a/src/pipewire/type.h b/src/pipewire/type.h
index 628fe520..819db567 100644
--- a/src/pipewire/type.h
+++ b/src/pipewire/type.h
@@ -43,40 +43,21 @@ extern "C" {
/** An interface name and version */
struct pw_interface_info {
- const char *type; /**< interface type */
- uint32_t version; /**< interface version */
+ const char *type; /**< interface type */
+ uint32_t version; /**< interface version */
};
static inline const struct pw_interface_info *
pw_interface_info_find(uint32_t n_ifaces, const struct pw_interface_info *ifaces, const char *type)
{
- int i;
- for (i = 0; i < n_ifaces; i++) {
- if (strcmp(ifaces[i].type, type) == 0)
- return &ifaces[i];
- }
- return NULL;
+ int i;
+ for (i = 0; i < n_ifaces; i++) {
+ if (strcmp(ifaces[i].type, type) == 0)
+ return &ifaces[i];
+ }
+ return NULL;
}
-/** \class pw_interface
- * \brief The interface definition
- *
- * The interface implements the methods and events for a \ref
- * pw_proxy. It typically implements marshal functions for the
- * methods and calls the user installed implementation after
- * demarshalling the events.
- *
- * \sa pw_proxy, pw_resource
- */
-struct pw_interface {
- const char *type; /**< interface type */
- uint32_t version; /**< version */
- uint32_t n_methods; /**< number of methods in the interface */
- const void *methods; /**< method implementations of the interface */
- uint32_t n_events; /**< number of events in the interface */
- const void *events; /**< event implementations of the interface */
-};
-
/** \class pw_type
* \brief PipeWire type support struct
*
diff --git a/src/tools/pipewire-monitor.c b/src/tools/pipewire-monitor.c
index 830a91d3..974d6836 100644
--- a/src/tools/pipewire-monitor.c
+++ b/src/tools/pipewire-monitor.c
@@ -31,14 +31,17 @@ struct data {
struct pw_loop *loop;
struct pw_core *core;
struct pw_remote *remote;
- pw_registry_proxy_t *registry_proxy;
+ struct pw_registry_proxy *registry_proxy;
struct pw_listener on_info_changed;
struct pw_listener on_state_changed;
+
+ struct pw_interface_listener registry_listener;
};
struct proxy_data {
void *info;
+ struct pw_interface_listener proxy_listener;
};
static void print_properties(struct spa_dict *props, char mark)
@@ -61,7 +64,6 @@ static void on_info_changed(struct pw_listener *listener, struct pw_remote *remo
struct pw_core_info *info = remote->info;
bool print_all = true, print_mark = false;
- printf("\tid: %u\n", info->id);
printf("\ttype: %s\n", PW_TYPE_INTERFACE__Core);
if (print_all) {
printf("%c\tuser-name: \"%s\"\n", MARK_CHANGE(0), info->user_name);
@@ -91,7 +93,6 @@ static void module_event_info(void *object, struct pw_module_info *info)
info = data->info = pw_module_info_update(data->info, info);
- printf("\tid: %u\n", info->id);
printf("\ttype: %s\n", PW_TYPE_INTERFACE__Module);
if (print_all) {
printf("%c\tname: \"%s\"\n", MARK_CHANGE(0), info->name);
@@ -124,7 +125,6 @@ static void node_event_info(void *object, struct pw_node_info *info)
info = data->info = pw_node_info_update(data->info, info);
- printf("\tid: %u\n", info->id);
printf("\ttype: %s\n", PW_TYPE_INTERFACE__Node);
if (print_all) {
int i;
@@ -172,7 +172,6 @@ static void client_event_info(void *object, struct pw_client_info *info)
info = data->info = pw_client_info_update(data->info, info);
- printf("\tid: %u\n", info->id);
printf("\ttype: %s\n", PW_TYPE_INTERFACE__Client);
if (print_all) {
print_properties(info->props, MARK_CHANGE(0));
@@ -202,7 +201,6 @@ static void link_event_info(void *object, struct pw_link_info *info)
info = data->info = pw_link_info_update(data->info, info);
- printf("\tid: %u\n", info->id);
printf("\ttype: %s\n", PW_TYPE_INTERFACE__Link);
if (print_all) {
printf("%c\toutput-node-id: %u\n", MARK_CHANGE(0), info->output_node_id);
@@ -231,63 +229,64 @@ destroy_proxy (void *data)
if (user_data->info == NULL)
return;
- if (strcmp(proxy->iface->type, PW_TYPE_INTERFACE__Core) == 0) {
+ if (strcmp(proxy->iface.type, PW_TYPE_INTERFACE__Core) == 0) {
pw_core_info_free (user_data->info);
- } else if (strcmp(proxy->iface->type, PW_TYPE_INTERFACE__Node) == 0) {
+ } else if (strcmp(proxy->iface.type, PW_TYPE_INTERFACE__Node) == 0) {
pw_node_info_free (user_data->info);
- } else if (strcmp(proxy->iface->type, PW_TYPE_INTERFACE__Module) == 0) {
+ } else if (strcmp(proxy->iface.type, PW_TYPE_INTERFACE__Module) == 0) {
pw_module_info_free (user_data->info);
- } else if (strcmp(proxy->iface->type, PW_TYPE_INTERFACE__Client) == 0) {
+ } else if (strcmp(proxy->iface.type, PW_TYPE_INTERFACE__Client) == 0) {
pw_client_info_free (user_data->info);
- } else if (strcmp(proxy->iface->type, PW_TYPE_INTERFACE__Link) == 0) {
+ } else if (strcmp(proxy->iface.type, PW_TYPE_INTERFACE__Link) == 0) {
pw_link_info_free (user_data->info);
}
user_data->info = NULL;
}
-static void registry_event_global(void *object, uint32_t id, uint32_t type,
- uint32_t n_ifaces, const struct pw_interface_info *ifaces)
+static void registry_event_global(void *object, uint32_t id,
+ uint32_t n_ifaces, const struct pw_interface_info **ifaces)
{
- pw_registry_proxy_t *registry_proxy = object;
- struct data *data = registry_proxy->object;
- struct pw_core *core = data->core;
+ struct data *data = object;
struct pw_proxy *proxy = NULL;
uint32_t i, client_version;
- const void *implementation;
+ const void *events;
+ struct proxy_data *proxy_data;
printf("Global:\n");
printf("\tid: %u\n", id);
- printf("\ttype: %s\n", spa_type_map_get_type(core->type.map, type));
printf("\tn_ifaces: %d\n", n_ifaces);
for (i = 0; i < n_ifaces; i++) {
- printf("\t %s (version %d)\n", ifaces[i].type, ifaces[i].version);
- if (strcmp(ifaces[i].type, PW_TYPE_INTERFACE__Node) == 0) {
- implementation = &node_events;
+ const struct pw_interface_info *iface = ifaces[i];
+
+ printf("\t %s (version %d)\n", iface->type, iface->version);
+ if (strcmp(iface->type, PW_TYPE_INTERFACE__Node) == 0) {
+ events = &node_events;
client_version = PW_VERSION_NODE;
}
- else if (strcmp(ifaces[i].type, PW_TYPE_INTERFACE__Module) == 0) {
- implementation = &module_events;
+ else if (strcmp(iface->type, PW_TYPE_INTERFACE__Module) == 0) {
+ events = &module_events;
client_version = PW_VERSION_MODULE;
}
- else if (strcmp(ifaces[i].type, PW_TYPE_INTERFACE__Client) == 0) {
- implementation = &client_events;
+ else if (strcmp(iface->type, PW_TYPE_INTERFACE__Client) == 0) {
+ events = &client_events;
client_version = PW_VERSION_CLIENT;
}
- else if (strcmp(ifaces[i].type, PW_TYPE_INTERFACE__Link) == 0) {
- implementation = &link_events;
+ else if (strcmp(iface->type, PW_TYPE_INTERFACE__Link) == 0) {
+ events = &link_events;
client_version = PW_VERSION_LINK;
}
else
continue;
- proxy = pw_registry_proxy_bind(registry_proxy, id, ifaces[i].type,
- client_version, sizeof(struct proxy_data));
+ proxy = pw_registry_proxy_bind(data->registry_proxy, id, iface->type,
+ client_version, sizeof(struct proxy_data), destroy_proxy);
if (proxy == NULL)
goto no_mem;
- pw_proxy_add_listener(proxy, data, implementation, destroy_proxy);
+ proxy_data = proxy->user_data;
+ pw_proxy_add_listener(proxy, &proxy_data->proxy_listener, proxy, events);
}
return;
@@ -322,8 +321,10 @@ static void on_state_changed(struct pw_listener *listener, struct pw_remote *rem
printf("remote state: \"%s\"\n", pw_remote_state_as_string(remote->state));
data->registry_proxy = pw_core_proxy_get_registry(data->remote->core_proxy,
- PW_VERSION_REGISTRY, 0);
- pw_registry_proxy_add_listener(data->registry_proxy, data, &registry_events, NULL);
+ PW_VERSION_REGISTRY, 0, NULL);
+ pw_registry_proxy_add_listener(data->registry_proxy,
+ &data->registry_listener,
+ data, &registry_events);
break;
default: