remote: add option for extra user data for proxy

When doing an export, make it possible to add extra data to the
resulting proxy for user data.
This commit is contained in:
Wim Taymans 2019-05-30 16:11:31 +02:00
parent 11393ce9dd
commit e1cbdaed0b
12 changed files with 30 additions and 21 deletions

View file

@ -469,7 +469,7 @@ static void make_node(struct data *data)
SPA_TYPE_INTERFACE_Node, SPA_TYPE_INTERFACE_Node,
SPA_VERSION_NODE, SPA_VERSION_NODE,
&impl_node, data); &impl_node, data);
pw_remote_export(data->remote, SPA_TYPE_INTERFACE_Node, props, &data->impl_node); pw_remote_export(data->remote, SPA_TYPE_INTERFACE_Node, props, &data->impl_node, 0);
} }
static void on_state_changed(void *_data, enum pw_remote_state old, enum pw_remote_state state, const char *error) static void on_state_changed(void *_data, enum pw_remote_state old, enum pw_remote_state state, const char *error)

View file

@ -477,7 +477,7 @@ static void make_node(struct data *data)
SPA_TYPE_INTERFACE_Node, SPA_TYPE_INTERFACE_Node,
SPA_VERSION_NODE, SPA_VERSION_NODE,
&impl_node, data); &impl_node, data);
pw_remote_export(data->remote, SPA_TYPE_INTERFACE_Node, props, &data->impl_node); pw_remote_export(data->remote, SPA_TYPE_INTERFACE_Node, props, &data->impl_node, 0);
} }
static void on_state_changed(void *_data, enum pw_remote_state old, static void on_state_changed(void *_data, enum pw_remote_state old,

View file

@ -64,7 +64,7 @@ static int make_device(struct data *data)
props, SPA_ID_INVALID); props, SPA_ID_INVALID);
pw_remote_export(data->remote, SPA_TYPE_INTERFACE_Device, NULL, pw_remote_export(data->remote, SPA_TYPE_INTERFACE_Device, NULL,
pw_device_get_implementation(data->device)); pw_device_get_implementation(data->device), 0);
return 0; return 0;
} }

View file

@ -70,7 +70,7 @@ static int make_node(struct data *data)
pw_node_set_active(data->node, true); pw_node_set_active(data->node, true);
pw_remote_export(data->remote, PW_TYPE_INTERFACE_Node, NULL, data->node); pw_remote_export(data->remote, PW_TYPE_INTERFACE_Node, NULL, data->node, 0);
return 0; return 0;
} }

View file

@ -40,7 +40,8 @@ static const struct spa_dict_item module_props[] = {
}; };
struct pw_proxy *pw_remote_spa_device_export(struct pw_remote *remote, struct pw_proxy *pw_remote_spa_device_export(struct pw_remote *remote,
uint32_t type, struct pw_properties *props, void *object); uint32_t type, struct pw_properties *props, void *object,
size_t user_data_size);
struct pw_protocol *pw_protocol_native_ext_client_device_init(struct pw_core *core); struct pw_protocol *pw_protocol_native_ext_client_device_init(struct pw_core *core);

View file

@ -56,7 +56,8 @@ static const struct pw_proxy_events proxy_events = {
}; };
struct pw_proxy *pw_remote_spa_device_export(struct pw_remote *remote, struct pw_proxy *pw_remote_spa_device_export(struct pw_remote *remote,
uint32_t type, struct pw_properties *props, void *object) uint32_t type, struct pw_properties *props, void *object,
size_t user_data_size)
{ {
struct spa_device *device = object; struct spa_device *device = object;
struct spa_interface *iface; struct spa_interface *iface;
@ -68,11 +69,12 @@ struct pw_proxy *pw_remote_spa_device_export(struct pw_remote *remote,
SPA_TYPE_INTERFACE_Device, SPA_TYPE_INTERFACE_Device,
SPA_VERSION_DEVICE, SPA_VERSION_DEVICE,
&props->dict, &props->dict,
sizeof(struct device_data)); user_data_size + sizeof(struct device_data));
if (proxy == NULL) if (proxy == NULL)
return NULL; return NULL;
data = pw_proxy_get_user_data(proxy); data = pw_proxy_get_user_data(proxy);
data = SPA_MEMBER(data, user_data_size, struct device_data);
data->remote = remote; data->remote = remote;
data->device = device; data->device = device;
data->core = pw_remote_get_core(remote); data->core = pw_remote_get_core(remote);

View file

@ -41,9 +41,9 @@ static const struct spa_dict_item module_props[] = {
}; };
struct pw_proxy *pw_remote_node_export(struct pw_remote *remote, struct pw_proxy *pw_remote_node_export(struct pw_remote *remote,
uint32_t type, struct pw_properties *props, void *object); uint32_t type, struct pw_properties *props, void *object, size_t user_data_size);
struct pw_proxy *pw_remote_spa_node_export(struct pw_remote *remote, struct pw_proxy *pw_remote_spa_node_export(struct pw_remote *remote,
uint32_t type, struct pw_properties *props, void *object); uint32_t type, struct pw_properties *props, void *object, size_t user_data_size);
struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_core *core); struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_core *core);

View file

@ -1170,7 +1170,8 @@ static const struct spa_node_callbacks node_callbacks = {
.reuse_buffer = node_reuse_buffer .reuse_buffer = node_reuse_buffer
}; };
static struct pw_proxy *node_export(struct pw_remote *remote, void *object, bool do_free) static struct pw_proxy *node_export(struct pw_remote *remote, void *object, bool do_free,
size_t user_data_size)
{ {
struct pw_node *node = object; struct pw_node *node = object;
struct pw_proxy *proxy; struct pw_proxy *proxy;
@ -1218,19 +1219,21 @@ static struct pw_proxy *node_export(struct pw_remote *remote, void *object, bool
do_node_init(proxy); do_node_init(proxy);
data->proxy = (struct pw_proxy*) pw_client_node_proxy_get_node(data->node_proxy, data->proxy = (struct pw_proxy*) pw_client_node_proxy_get_node(data->node_proxy,
PW_VERSION_NODE_PROXY, 0); PW_VERSION_NODE_PROXY, user_data_size);
return data->proxy; return data->proxy;
} }
struct pw_proxy *pw_remote_node_export(struct pw_remote *remote, struct pw_proxy *pw_remote_node_export(struct pw_remote *remote,
uint32_t type, struct pw_properties *props, void *object) uint32_t type, struct pw_properties *props, void *object,
size_t user_data_size)
{ {
return node_export(remote, object, false); return node_export(remote, object, false, user_data_size);
} }
struct pw_proxy *pw_remote_spa_node_export(struct pw_remote *remote, struct pw_proxy *pw_remote_spa_node_export(struct pw_remote *remote,
uint32_t type, struct pw_properties *props, void *object) uint32_t type, struct pw_properties *props, void *object,
size_t user_data_size)
{ {
struct pw_node *node; struct pw_node *node;
@ -1242,5 +1245,5 @@ struct pw_proxy *pw_remote_spa_node_export(struct pw_remote *remote,
pw_node_register(node, NULL, NULL, NULL); pw_node_register(node, NULL, NULL, NULL);
pw_node_set_active(node, true); pw_node_set_active(node, true);
return node_export(remote, node, true); return node_export(remote, node, true, user_data_size);
} }

View file

@ -442,7 +442,8 @@ int pw_remote_disconnect(struct pw_remote *remote)
SPA_EXPORT SPA_EXPORT
struct pw_proxy *pw_remote_export(struct pw_remote *remote, struct pw_proxy *pw_remote_export(struct pw_remote *remote,
uint32_t type, struct pw_properties *props, void *object) uint32_t type, struct pw_properties *props, void *object,
size_t user_data_size)
{ {
struct pw_proxy *proxy; struct pw_proxy *proxy;
const struct pw_export_type *t; const struct pw_export_type *t;
@ -454,7 +455,7 @@ struct pw_proxy *pw_remote_export(struct pw_remote *remote,
if (t == NULL) if (t == NULL)
goto no_export_type; goto no_export_type;
proxy = t->func(remote, type, props, object); proxy = t->func(remote, type, props, object, user_data_size);
if (proxy == NULL) if (proxy == NULL)
goto proxy_failed; goto proxy_failed;

View file

@ -201,14 +201,16 @@ int pw_remote_disconnect(struct pw_remote *remote);
struct pw_proxy *pw_remote_export(struct pw_remote *remote, /**< the remote */ struct pw_proxy *pw_remote_export(struct pw_remote *remote, /**< the remote */
uint32_t type, /**< the type of object */ uint32_t type, /**< the type of object */
struct pw_properties *properties, /**< extra properties */ struct pw_properties *properties, /**< extra properties */
void *object /**< object to export */); void *object, /**< object to export */
size_t user_data_size /**< extra user data */);
/** data for registering export functions */ /** data for registering export functions */
struct pw_export_type { struct pw_export_type {
struct spa_list link; struct spa_list link;
uint32_t type; uint32_t type;
struct pw_proxy * (*func) (struct pw_remote *remote, struct pw_proxy * (*func) (struct pw_remote *remote,
uint32_t type, struct pw_properties *properties, void *object); uint32_t type, struct pw_properties *properties, void *object,
size_t user_data_size);
}; };
/** register a type that can be exported on a remote. This is usually used by /** register a type that can be exported on a remote. This is usually used by

View file

@ -982,7 +982,7 @@ static int handle_connect(struct pw_stream *stream)
pw_log_debug("stream %p: export node %p", stream, impl->node); pw_log_debug("stream %p: export node %p", stream, impl->node);
stream->proxy = pw_remote_export(stream->remote, stream->proxy = pw_remote_export(stream->remote,
PW_TYPE_INTERFACE_Node, NULL, impl->node); PW_TYPE_INTERFACE_Node, NULL, impl->node, 0);
if (stream->proxy == NULL) if (stream->proxy == NULL)
goto no_proxy; goto no_proxy;

View file

@ -1149,7 +1149,7 @@ static bool do_export_node(struct data *data, const char *cmd, char *args, char
return false; return false;
} }
node = pw_global_get_object(global); node = pw_global_get_object(global);
proxy = pw_remote_export(rd->remote, PW_TYPE_INTERFACE_Node, NULL, node); proxy = pw_remote_export(rd->remote, PW_TYPE_INTERFACE_Node, NULL, node, 0);
id = pw_map_insert_new(&data->vars, proxy); id = pw_map_insert_new(&data->vars, proxy);
fprintf(stdout, "%d = @proxy:%d\n", id, pw_proxy_get_id((struct pw_proxy*)proxy)); fprintf(stdout, "%d = @proxy:%d\n", id, pw_proxy_get_id((struct pw_proxy*)proxy));