mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
protocol: add flags to protocol marshal
Allows us to to select marshallers for implementation and binding.
This commit is contained in:
parent
d1e331e268
commit
8ddf579cc0
11 changed files with 150 additions and 92 deletions
|
|
@ -527,12 +527,13 @@ pw_protocol_native_device_event_demarshal[SPA_DEVICE_EVENT_NUM] =
|
|||
static const struct pw_protocol_marshal pw_protocol_native_client_device_marshal = {
|
||||
SPA_TYPE_INTERFACE_Device,
|
||||
SPA_VERSION_DEVICE,
|
||||
PW_PROTOCOL_MARSHAL_FLAG_IMPL,
|
||||
SPA_DEVICE_EVENT_NUM,
|
||||
SPA_DEVICE_METHOD_NUM,
|
||||
&pw_protocol_native_device_event_marshal,
|
||||
pw_protocol_native_device_event_demarshal,
|
||||
&pw_protocol_native_device_method_marshal,
|
||||
pw_protocol_native_device_method_demarshal,
|
||||
.client_marshal = &pw_protocol_native_device_event_marshal,
|
||||
.server_demarshal = pw_protocol_native_device_event_demarshal,
|
||||
.server_marshal = &pw_protocol_native_device_method_marshal,
|
||||
.client_demarshal = pw_protocol_native_device_method_demarshal,
|
||||
};
|
||||
|
||||
struct pw_protocol *pw_protocol_native_ext_client_device_init(struct pw_core *core)
|
||||
|
|
|
|||
|
|
@ -1150,12 +1150,13 @@ pw_protocol_native_client_node_event_demarshal[PW_CLIENT_NODE_PROXY_EVENT_NUM] =
|
|||
static const struct pw_protocol_marshal pw_protocol_native_client_node_marshal = {
|
||||
PW_TYPE_INTERFACE_ClientNode,
|
||||
PW_VERSION_CLIENT_NODE,
|
||||
0,
|
||||
PW_CLIENT_NODE_PROXY_METHOD_NUM,
|
||||
PW_CLIENT_NODE_PROXY_EVENT_NUM,
|
||||
&pw_protocol_native_client_node_method_marshal,
|
||||
&pw_protocol_native_client_node_method_demarshal,
|
||||
&pw_protocol_native_client_node_event_marshal,
|
||||
pw_protocol_native_client_node_event_demarshal,
|
||||
.client_marshal = &pw_protocol_native_client_node_method_marshal,
|
||||
.server_demarshal = &pw_protocol_native_client_node_method_demarshal,
|
||||
.server_marshal = &pw_protocol_native_client_node_event_marshal,
|
||||
.client_demarshal = pw_protocol_native_client_node_event_demarshal,
|
||||
};
|
||||
|
||||
struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_core *core)
|
||||
|
|
|
|||
|
|
@ -496,9 +496,10 @@ static const struct pw_protocol_marshal pw_protocol_native_client_node_marshal =
|
|||
PW_VERSION_CLIENT_NODE0,
|
||||
PW_CLIENT_NODE0_PROXY_METHOD_NUM,
|
||||
PW_CLIENT_NODE0_PROXY_EVENT_NUM,
|
||||
0,
|
||||
NULL,
|
||||
&pw_protocol_native_client_node_method_demarshal,
|
||||
&pw_protocol_native_client_node_event_marshal,
|
||||
.server_demarshal = &pw_protocol_native_client_node_method_demarshal,
|
||||
.server_marshal = &pw_protocol_native_client_node_event_marshal,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -170,10 +170,10 @@ process_messages(struct client_data *data)
|
|||
}
|
||||
|
||||
marshal = pw_resource_get_marshal(resource);
|
||||
if (marshal == NULL || msg->opcode >= marshal->n_methods)
|
||||
if (marshal == NULL || msg->opcode >= marshal->n_client_methods)
|
||||
goto invalid_method;
|
||||
|
||||
demarshal = marshal->method_demarshal;
|
||||
demarshal = marshal->server_demarshal;
|
||||
if (!demarshal[msg->opcode].func) {
|
||||
res = -ENOENT;
|
||||
goto invalid_message;
|
||||
|
|
@ -633,14 +633,14 @@ on_remote_data(void *data, int fd, uint32_t mask)
|
|||
}
|
||||
|
||||
marshal = pw_proxy_get_marshal(proxy);
|
||||
if (marshal == NULL || msg->opcode >= marshal->n_events) {
|
||||
if (marshal == NULL || msg->opcode >= marshal->n_server_methods) {
|
||||
pw_log_error(NAME" %p: invalid method %u for %u (%d)",
|
||||
this, msg->opcode, msg->id,
|
||||
marshal ? marshal->n_events : (uint32_t)-1);
|
||||
marshal ? marshal->n_server_methods : (uint32_t)-1);
|
||||
continue;
|
||||
}
|
||||
|
||||
demarshal = marshal->event_demarshal;
|
||||
demarshal = marshal->client_demarshal;
|
||||
if (!demarshal[msg->opcode].func) {
|
||||
pw_log_error(NAME" %p: function %d not implemented on %u",
|
||||
this, msg->opcode, msg->id);
|
||||
|
|
|
|||
|
|
@ -1914,12 +1914,13 @@ pw_protocol_native_core_event_demarshal[PW_CORE_PROXY_EVENT_NUM] =
|
|||
static const struct pw_protocol_marshal pw_protocol_native_core_marshal = {
|
||||
PW_TYPE_INTERFACE_Core,
|
||||
PW_VERSION_CORE_PROXY,
|
||||
0,
|
||||
PW_CORE_PROXY_METHOD_NUM,
|
||||
PW_CORE_PROXY_EVENT_NUM,
|
||||
&pw_protocol_native_core_method_marshal,
|
||||
pw_protocol_native_core_method_demarshal,
|
||||
&pw_protocol_native_core_event_marshal,
|
||||
pw_protocol_native_core_event_demarshal,
|
||||
.client_marshal = &pw_protocol_native_core_method_marshal,
|
||||
.server_demarshal = pw_protocol_native_core_method_demarshal,
|
||||
.server_marshal = &pw_protocol_native_core_event_marshal,
|
||||
.client_demarshal = pw_protocol_native_core_event_demarshal,
|
||||
};
|
||||
|
||||
static const struct pw_registry_proxy_methods pw_protocol_native_registry_method_marshal = {
|
||||
|
|
@ -1953,12 +1954,13 @@ pw_protocol_native_registry_event_demarshal[PW_REGISTRY_PROXY_EVENT_NUM] =
|
|||
const struct pw_protocol_marshal pw_protocol_native_registry_marshal = {
|
||||
PW_TYPE_INTERFACE_Registry,
|
||||
PW_VERSION_REGISTRY_PROXY,
|
||||
0,
|
||||
PW_REGISTRY_PROXY_METHOD_NUM,
|
||||
PW_REGISTRY_PROXY_EVENT_NUM,
|
||||
&pw_protocol_native_registry_method_marshal,
|
||||
pw_protocol_native_registry_method_demarshal,
|
||||
&pw_protocol_native_registry_event_marshal,
|
||||
pw_protocol_native_registry_event_demarshal,
|
||||
.client_marshal = &pw_protocol_native_registry_method_marshal,
|
||||
.server_demarshal = pw_protocol_native_registry_method_demarshal,
|
||||
.server_marshal = &pw_protocol_native_registry_event_marshal,
|
||||
.client_demarshal = pw_protocol_native_registry_event_demarshal,
|
||||
};
|
||||
|
||||
static const struct pw_module_proxy_events pw_protocol_native_module_event_marshal = {
|
||||
|
|
@ -1987,12 +1989,13 @@ pw_protocol_native_module_method_demarshal[PW_MODULE_PROXY_METHOD_NUM] =
|
|||
const struct pw_protocol_marshal pw_protocol_native_module_marshal = {
|
||||
PW_TYPE_INTERFACE_Module,
|
||||
PW_VERSION_MODULE_PROXY,
|
||||
0,
|
||||
PW_MODULE_PROXY_METHOD_NUM,
|
||||
PW_MODULE_PROXY_EVENT_NUM,
|
||||
&pw_protocol_native_module_method_marshal,
|
||||
pw_protocol_native_module_method_demarshal,
|
||||
&pw_protocol_native_module_event_marshal,
|
||||
pw_protocol_native_module_event_demarshal,
|
||||
.client_marshal = &pw_protocol_native_module_method_marshal,
|
||||
.server_demarshal = pw_protocol_native_module_method_demarshal,
|
||||
.server_marshal = &pw_protocol_native_module_event_marshal,
|
||||
.client_demarshal = pw_protocol_native_module_event_demarshal,
|
||||
};
|
||||
|
||||
static const struct pw_factory_proxy_events pw_protocol_native_factory_event_marshal = {
|
||||
|
|
@ -2020,12 +2023,13 @@ pw_protocol_native_factory_method_demarshal[PW_FACTORY_PROXY_METHOD_NUM] =
|
|||
const struct pw_protocol_marshal pw_protocol_native_factory_marshal = {
|
||||
PW_TYPE_INTERFACE_Factory,
|
||||
PW_VERSION_FACTORY_PROXY,
|
||||
0,
|
||||
PW_FACTORY_PROXY_METHOD_NUM,
|
||||
PW_FACTORY_PROXY_EVENT_NUM,
|
||||
&pw_protocol_native_factory_method_marshal,
|
||||
pw_protocol_native_factory_method_demarshal,
|
||||
&pw_protocol_native_factory_event_marshal,
|
||||
pw_protocol_native_factory_event_demarshal,
|
||||
.client_marshal = &pw_protocol_native_factory_method_marshal,
|
||||
.server_demarshal = pw_protocol_native_factory_method_demarshal,
|
||||
.server_marshal = &pw_protocol_native_factory_event_marshal,
|
||||
.client_demarshal = pw_protocol_native_factory_event_demarshal,
|
||||
};
|
||||
|
||||
static const struct pw_device_proxy_methods pw_protocol_native_device_method_marshal = {
|
||||
|
|
@ -2057,12 +2061,13 @@ pw_protocol_native_device_event_demarshal[PW_DEVICE_PROXY_EVENT_NUM] = {
|
|||
static const struct pw_protocol_marshal pw_protocol_native_device_marshal = {
|
||||
PW_TYPE_INTERFACE_Device,
|
||||
PW_VERSION_DEVICE_PROXY,
|
||||
0,
|
||||
PW_DEVICE_PROXY_METHOD_NUM,
|
||||
PW_DEVICE_PROXY_EVENT_NUM,
|
||||
&pw_protocol_native_device_method_marshal,
|
||||
pw_protocol_native_device_method_demarshal,
|
||||
&pw_protocol_native_device_event_marshal,
|
||||
pw_protocol_native_device_event_demarshal,
|
||||
.client_marshal = &pw_protocol_native_device_method_marshal,
|
||||
.server_demarshal = pw_protocol_native_device_method_demarshal,
|
||||
.server_marshal = &pw_protocol_native_device_event_marshal,
|
||||
.client_demarshal = pw_protocol_native_device_event_demarshal,
|
||||
};
|
||||
|
||||
static const struct pw_node_proxy_methods pw_protocol_native_node_method_marshal = {
|
||||
|
|
@ -2099,12 +2104,13 @@ pw_protocol_native_node_event_demarshal[PW_NODE_PROXY_EVENT_NUM] = {
|
|||
static const struct pw_protocol_marshal pw_protocol_native_node_marshal = {
|
||||
PW_TYPE_INTERFACE_Node,
|
||||
PW_VERSION_NODE_PROXY,
|
||||
0,
|
||||
PW_NODE_PROXY_METHOD_NUM,
|
||||
PW_NODE_PROXY_EVENT_NUM,
|
||||
&pw_protocol_native_node_method_marshal,
|
||||
pw_protocol_native_node_method_demarshal,
|
||||
&pw_protocol_native_node_event_marshal,
|
||||
pw_protocol_native_node_event_demarshal,
|
||||
.client_marshal = &pw_protocol_native_node_method_marshal,
|
||||
.server_demarshal = pw_protocol_native_node_method_demarshal,
|
||||
.server_marshal = &pw_protocol_native_node_event_marshal,
|
||||
.client_demarshal = pw_protocol_native_node_event_demarshal,
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -2139,12 +2145,13 @@ pw_protocol_native_port_event_demarshal[PW_PORT_PROXY_EVENT_NUM] =
|
|||
static const struct pw_protocol_marshal pw_protocol_native_port_marshal = {
|
||||
PW_TYPE_INTERFACE_Port,
|
||||
PW_VERSION_PORT_PROXY,
|
||||
0,
|
||||
PW_PORT_PROXY_METHOD_NUM,
|
||||
PW_PORT_PROXY_EVENT_NUM,
|
||||
&pw_protocol_native_port_method_marshal,
|
||||
pw_protocol_native_port_method_demarshal,
|
||||
&pw_protocol_native_port_event_marshal,
|
||||
pw_protocol_native_port_event_demarshal,
|
||||
.client_marshal = &pw_protocol_native_port_method_marshal,
|
||||
.server_demarshal = pw_protocol_native_port_method_demarshal,
|
||||
.server_marshal = &pw_protocol_native_port_event_marshal,
|
||||
.client_demarshal = pw_protocol_native_port_event_demarshal,
|
||||
};
|
||||
|
||||
static const struct pw_client_proxy_methods pw_protocol_native_client_method_marshal = {
|
||||
|
|
@ -2182,12 +2189,13 @@ pw_protocol_native_client_event_demarshal[PW_CLIENT_PROXY_EVENT_NUM] =
|
|||
static const struct pw_protocol_marshal pw_protocol_native_client_marshal = {
|
||||
PW_TYPE_INTERFACE_Client,
|
||||
PW_VERSION_CLIENT_PROXY,
|
||||
0,
|
||||
PW_CLIENT_PROXY_METHOD_NUM,
|
||||
PW_CLIENT_PROXY_EVENT_NUM,
|
||||
&pw_protocol_native_client_method_marshal,
|
||||
pw_protocol_native_client_method_demarshal,
|
||||
&pw_protocol_native_client_event_marshal,
|
||||
pw_protocol_native_client_event_demarshal,
|
||||
.client_marshal = &pw_protocol_native_client_method_marshal,
|
||||
.server_demarshal = pw_protocol_native_client_method_demarshal,
|
||||
.server_marshal = &pw_protocol_native_client_event_marshal,
|
||||
.client_demarshal = pw_protocol_native_client_event_demarshal,
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -2216,12 +2224,13 @@ pw_protocol_native_link_event_demarshal[PW_LINK_PROXY_EVENT_NUM] =
|
|||
static const struct pw_protocol_marshal pw_protocol_native_link_marshal = {
|
||||
PW_TYPE_INTERFACE_Link,
|
||||
PW_VERSION_LINK_PROXY,
|
||||
0,
|
||||
PW_LINK_PROXY_METHOD_NUM,
|
||||
PW_LINK_PROXY_EVENT_NUM,
|
||||
&pw_protocol_native_link_method_marshal,
|
||||
pw_protocol_native_link_method_demarshal,
|
||||
&pw_protocol_native_link_event_marshal,
|
||||
pw_protocol_native_link_event_demarshal,
|
||||
.client_marshal = &pw_protocol_native_link_method_marshal,
|
||||
.server_demarshal = pw_protocol_native_link_method_demarshal,
|
||||
.server_marshal = &pw_protocol_native_link_event_marshal,
|
||||
.client_demarshal = pw_protocol_native_link_event_demarshal,
|
||||
};
|
||||
|
||||
void pw_protocol_native_init(struct pw_protocol *protocol)
|
||||
|
|
|
|||
|
|
@ -1042,6 +1042,7 @@ static const struct pw_protocol_marshal pw_protocol_native_core_marshal = {
|
|||
PW_VERSION_CORE_V0,
|
||||
PW_CORE_PROXY_V0_METHOD_NUM,
|
||||
PW_CORE_PROXY_EVENT_NUM,
|
||||
0,
|
||||
NULL,
|
||||
pw_protocol_native_core_method_demarshal,
|
||||
&pw_protocol_native_core_event_marshal,
|
||||
|
|
@ -1063,6 +1064,7 @@ static const struct pw_protocol_marshal pw_protocol_native_registry_marshal = {
|
|||
PW_VERSION_REGISTRY_V0,
|
||||
PW_REGISTRY_PROXY_V0_METHOD_NUM,
|
||||
PW_REGISTRY_PROXY_EVENT_NUM,
|
||||
0,
|
||||
NULL,
|
||||
pw_protocol_native_registry_method_demarshal,
|
||||
&pw_protocol_native_registry_event_marshal,
|
||||
|
|
@ -1079,6 +1081,7 @@ static const struct pw_protocol_marshal pw_protocol_native_module_marshal = {
|
|||
PW_VERSION_MODULE_V0,
|
||||
0,
|
||||
PW_MODULE_PROXY_EVENT_NUM,
|
||||
0,
|
||||
NULL, NULL,
|
||||
&pw_protocol_native_module_event_marshal,
|
||||
NULL
|
||||
|
|
@ -1094,6 +1097,7 @@ static const struct pw_protocol_marshal pw_protocol_native_factory_marshal = {
|
|||
PW_VERSION_FACTORY_V0,
|
||||
0,
|
||||
PW_FACTORY_PROXY_EVENT_NUM,
|
||||
0,
|
||||
NULL, NULL,
|
||||
&pw_protocol_native_factory_event_marshal,
|
||||
NULL,
|
||||
|
|
@ -1114,6 +1118,7 @@ static const struct pw_protocol_marshal pw_protocol_native_node_marshal = {
|
|||
PW_VERSION_NODE_V0,
|
||||
PW_NODE_PROXY_V0_METHOD_NUM,
|
||||
PW_NODE_PROXY_EVENT_NUM,
|
||||
0,
|
||||
NULL,
|
||||
pw_protocol_native_node_method_demarshal,
|
||||
&pw_protocol_native_node_event_marshal,
|
||||
|
|
@ -1136,6 +1141,7 @@ static const struct pw_protocol_marshal pw_protocol_native_port_marshal = {
|
|||
PW_VERSION_PORT_V0,
|
||||
PW_PORT_PROXY_V0_METHOD_NUM,
|
||||
PW_PORT_PROXY_EVENT_NUM,
|
||||
0,
|
||||
NULL,
|
||||
pw_protocol_native_port_method_demarshal,
|
||||
&pw_protocol_native_port_event_marshal,
|
||||
|
|
@ -1153,6 +1159,7 @@ static const struct pw_protocol_marshal pw_protocol_native_client_marshal = {
|
|||
PW_VERSION_CLIENT_V0,
|
||||
0,
|
||||
PW_CLIENT_PROXY_EVENT_NUM,
|
||||
0,
|
||||
NULL, NULL,
|
||||
&pw_protocol_native_client_event_marshal,
|
||||
NULL,
|
||||
|
|
@ -1168,6 +1175,7 @@ static const struct pw_protocol_marshal pw_protocol_native_link_marshal = {
|
|||
PW_VERSION_LINK_V0,
|
||||
0,
|
||||
PW_LINK_PROXY_EVENT_NUM,
|
||||
0,
|
||||
NULL, NULL,
|
||||
&pw_protocol_native_link_event_marshal,
|
||||
NULL
|
||||
|
|
|
|||
|
|
@ -703,6 +703,7 @@ struct pw_proxy {
|
|||
struct pw_remote *remote; /**< the owner remote of this proxy */
|
||||
|
||||
uint32_t id; /**< client side id */
|
||||
uint32_t type; /**< type of the interface */
|
||||
uint32_t version; /**< client side version */
|
||||
int refcount;
|
||||
unsigned int zombie:1; /**< proxy is removed locally and waiting to
|
||||
|
|
@ -885,6 +886,9 @@ pw_core_find_port(struct pw_core *core,
|
|||
|
||||
const struct pw_export_type *pw_core_find_export_type(struct pw_core *core, uint32_t type);
|
||||
|
||||
int pw_proxy_install_marshal(struct pw_proxy *proxy, bool implementor);
|
||||
int pw_resource_install_marshal(struct pw_resource *resource, bool implementor);
|
||||
|
||||
int pw_core_recalc_graph(struct pw_core *core);
|
||||
|
||||
/** Create a new port \memberof pw_port
|
||||
|
|
|
|||
|
|
@ -152,14 +152,19 @@ pw_protocol_add_marshal(struct pw_protocol *protocol,
|
|||
|
||||
SPA_EXPORT
|
||||
const struct pw_protocol_marshal *
|
||||
pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type, uint32_t version)
|
||||
pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type, uint32_t version, uint32_t flags)
|
||||
{
|
||||
struct marshal *impl;
|
||||
|
||||
spa_list_for_each(impl, &protocol->marshal_list, link) {
|
||||
if (impl->marshal->type == type && impl->marshal->version == version)
|
||||
if (impl->marshal->type == type &&
|
||||
impl->marshal->version == version &&
|
||||
(impl->marshal->flags & flags) == flags)
|
||||
return impl->marshal;
|
||||
}
|
||||
pw_log_debug(NAME" %p: No marshal %d/%s:%d for protocol %s", protocol,
|
||||
type, spa_debug_type_find_name(pw_type_info(), type),
|
||||
version, protocol->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,14 +73,16 @@ struct pw_protocol_server {
|
|||
#define pw_protocol_server_destroy(l) ((l)->destroy(l))
|
||||
|
||||
struct pw_protocol_marshal {
|
||||
uint32_t type; /**< interface type */
|
||||
uint32_t version; /**< version */
|
||||
uint32_t n_methods; /**< number of methods in the interface */
|
||||
uint32_t n_events; /**< number of events in the interface */
|
||||
const void *method_marshal;
|
||||
const void *method_demarshal;
|
||||
const void *event_marshal;
|
||||
const void *event_demarshal;
|
||||
uint32_t type; /**< interface type */
|
||||
uint32_t version; /**< version */
|
||||
#define PW_PROTOCOL_MARSHAL_FLAG_IMPL (1 << 0) /**< marshal for implementations */
|
||||
uint32_t flags; /**< version */
|
||||
uint32_t n_client_methods; /**< number of client methods */
|
||||
uint32_t n_server_methods; /**< number of server methods */
|
||||
const void *client_marshal;
|
||||
const void *server_demarshal;
|
||||
const void *server_marshal;
|
||||
const void *client_demarshal;
|
||||
};
|
||||
|
||||
struct pw_protocol_implementaton {
|
||||
|
|
@ -132,7 +134,7 @@ int pw_protocol_add_marshal(struct pw_protocol *protocol,
|
|||
const struct pw_protocol_marshal *marshal);
|
||||
|
||||
const struct pw_protocol_marshal *
|
||||
pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type, uint32_t version);
|
||||
pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type, uint32_t version, uint32_t flags);
|
||||
|
||||
struct pw_protocol * pw_core_find_protocol(struct pw_core *core, const char *name);
|
||||
|
||||
|
|
|
|||
|
|
@ -71,17 +71,9 @@ struct pw_proxy *pw_proxy_new(struct pw_proxy *factory,
|
|||
this = &impl->this;
|
||||
this->remote = remote;
|
||||
this->refcount = 1;
|
||||
this->type = type;
|
||||
this->version = version;
|
||||
|
||||
this->marshal = pw_protocol_get_marshal(remote->conn->protocol, type, version);
|
||||
if (this->marshal == NULL) {
|
||||
pw_log_error(NAME" %p: no marshal for type %s/%d", this,
|
||||
spa_debug_type_find_name(pw_type_info(), type),
|
||||
version);
|
||||
res = -EPROTO;
|
||||
goto error_clean;
|
||||
}
|
||||
|
||||
this->id = pw_map_insert_new(&remote->objects, this);
|
||||
if (this->id == SPA_ID_INVALID) {
|
||||
res = -errno;
|
||||
|
|
@ -92,19 +84,20 @@ struct pw_proxy *pw_proxy_new(struct pw_proxy *factory,
|
|||
spa_hook_list_init(&this->listener_list);
|
||||
spa_hook_list_init(&this->object_listener_list);
|
||||
|
||||
if ((res = pw_proxy_install_marshal(this, false)) < 0) {
|
||||
pw_log_error(NAME" %p: no marshal for type %s/%d", this,
|
||||
spa_debug_type_find_name(pw_type_info(), type),
|
||||
version);
|
||||
goto error_clean;
|
||||
}
|
||||
|
||||
if (user_data_size > 0)
|
||||
this->user_data = SPA_MEMBER(impl, sizeof(struct proxy), void);
|
||||
|
||||
this->impl = SPA_INTERFACE_INIT(
|
||||
type,
|
||||
this->marshal->version,
|
||||
this->marshal->method_marshal, this);
|
||||
|
||||
pw_log_debug(NAME" %p: new %u type %s/%d remote:%p, marshal:%p",
|
||||
this, this->id,
|
||||
spa_debug_type_find_name(pw_type_info(), type), version,
|
||||
remote, this->marshal);
|
||||
|
||||
return this;
|
||||
|
||||
error_clean:
|
||||
|
|
@ -113,6 +106,26 @@ error_clean:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
int pw_proxy_install_marshal(struct pw_proxy *this, bool implementor)
|
||||
{
|
||||
struct pw_remote *remote = this->remote;
|
||||
const struct pw_protocol_marshal *marshal;
|
||||
|
||||
marshal = pw_protocol_get_marshal(remote->conn->protocol,
|
||||
this->type, this->version,
|
||||
implementor ? PW_PROTOCOL_MARSHAL_FLAG_IMPL : 0);
|
||||
if (marshal == NULL)
|
||||
return -EPROTO;
|
||||
|
||||
this->marshal = marshal;
|
||||
this->impl = SPA_INTERFACE_INIT(
|
||||
this->type,
|
||||
this->marshal->version,
|
||||
this->marshal->client_marshal, this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
void *pw_proxy_get_user_data(struct pw_proxy *proxy)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,15 +66,6 @@ struct pw_resource *pw_resource_new(struct pw_client *client,
|
|||
spa_hook_list_init(&this->listener_list);
|
||||
spa_hook_list_init(&this->object_listener_list);
|
||||
|
||||
this->marshal = pw_protocol_get_marshal(client->protocol, type, version);
|
||||
if (this->marshal == NULL) {
|
||||
pw_log_error(NAME" %p: no marshal for type %s/%d", this,
|
||||
spa_debug_type_find_name(pw_type_info(), type),
|
||||
version);
|
||||
res = -EPROTO;
|
||||
goto error_clean;
|
||||
}
|
||||
|
||||
if (id == SPA_ID_INVALID) {
|
||||
res = -EINVAL;
|
||||
goto error_clean;
|
||||
|
|
@ -86,21 +77,24 @@ struct pw_resource *pw_resource_new(struct pw_client *client,
|
|||
this, id, client);
|
||||
goto error_clean;
|
||||
}
|
||||
|
||||
this->id = id;
|
||||
|
||||
if ((res = pw_resource_install_marshal(this, false)) < 0) {
|
||||
pw_log_error(NAME" %p: no marshal for type %s/%d", this,
|
||||
spa_debug_type_find_name(pw_type_info(), type),
|
||||
version);
|
||||
goto error_clean;
|
||||
}
|
||||
|
||||
|
||||
if (user_data_size > 0)
|
||||
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
||||
|
||||
this->impl = SPA_INTERFACE_INIT(
|
||||
type,
|
||||
this->marshal->version,
|
||||
this->marshal->event_marshal, this);
|
||||
|
||||
pw_log_debug(NAME" %p: new %u type %s/%d client:%p marshal:%p",
|
||||
this, id,
|
||||
spa_debug_type_find_name(pw_type_info(), type), version,
|
||||
client, this->marshal);
|
||||
|
||||
pw_client_emit_resource_added(client, this);
|
||||
|
||||
return this;
|
||||
|
|
@ -111,6 +105,26 @@ error_clean:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
int pw_resource_install_marshal(struct pw_resource *this, bool implementor)
|
||||
{
|
||||
struct pw_client *client = this->client;
|
||||
const struct pw_protocol_marshal *marshal;
|
||||
|
||||
marshal = pw_protocol_get_marshal(client->protocol,
|
||||
this->type, this->version,
|
||||
implementor ? PW_PROTOCOL_MARSHAL_FLAG_IMPL : 0);
|
||||
if (marshal == NULL)
|
||||
return -EPROTO;
|
||||
|
||||
this->marshal = marshal;
|
||||
this->impl = SPA_INTERFACE_INIT(
|
||||
this->type,
|
||||
this->marshal->version,
|
||||
this->marshal->server_marshal, this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
struct pw_client *pw_resource_get_client(struct pw_resource *resource)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue