mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
clean up proxy and resource api
Remove override for resources, it can't work in general. Rename method to add_object_listener to add a listener for events/methods from the remote object. Rename some methods to _call to call the interface and _notify to notify the listeners. Remove unused client event to be notified of resource implementations.
This commit is contained in:
parent
b1ea91fa1d
commit
e9ecc47696
25 changed files with 196 additions and 249 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit af61dcebbfd05fa853cf15aa3798a98b4a087a92
|
||||
Subproject commit 531185845afd0844ee1e513e9c941e4f1501ef2d
|
||||
|
|
@ -492,7 +492,7 @@ handle_node(struct impl *impl, uint32_t id, uint32_t parent_id,
|
|||
node->obj.proxy = p;
|
||||
spa_list_init(&node->port_list);
|
||||
pw_proxy_add_listener(p, &node->obj.listener, &node_proxy_events, node);
|
||||
pw_proxy_add_proxy_listener(p, &node->listener, &node_events, node);
|
||||
pw_proxy_add_object_listener(p, &node->listener, &node_events, node);
|
||||
add_object(impl, &node->obj);
|
||||
spa_list_append(&impl->node_list, &node->l);
|
||||
node->type = NODE_TYPE_UNKNOWN;
|
||||
|
|
@ -675,7 +675,7 @@ handle_port(struct impl *impl, uint32_t id, uint32_t parent_id, uint32_t type,
|
|||
port->flags |= PORT_FLAG_SKIP;
|
||||
|
||||
pw_proxy_add_listener(p, &port->obj.listener, &port_proxy_events, port);
|
||||
pw_proxy_add_proxy_listener(p, &port->listener, &port_events, port);
|
||||
pw_proxy_add_object_listener(p, &port->listener, &port_events, port);
|
||||
add_object(impl, &port->obj);
|
||||
|
||||
spa_list_append(&node->port_list, &port->l);
|
||||
|
|
@ -748,7 +748,7 @@ handle_client(struct impl *impl, uint32_t id, uint32_t parent_id,
|
|||
client->obj.proxy = p;
|
||||
|
||||
pw_proxy_add_listener(p, &client->obj.listener, &client_proxy_events, client);
|
||||
pw_proxy_add_proxy_listener(p, &client->listener, &client_events, client);
|
||||
pw_proxy_add_object_listener(p, &client->listener, &client_events, client);
|
||||
add_object(impl, &client->obj);
|
||||
spa_list_append(&impl->client_list, &client->l);
|
||||
|
||||
|
|
@ -1264,7 +1264,7 @@ static void rescan_session(struct impl *impl, struct session *sess)
|
|||
0);
|
||||
pw_properties_free(props);
|
||||
|
||||
pw_proxy_add_proxy_listener(sess->dsp_proxy, &sess->listener, &dsp_node_events, sess);
|
||||
pw_proxy_add_object_listener(sess->dsp_proxy, &sess->listener, &dsp_node_events, sess);
|
||||
|
||||
spa_pod_builder_init(&b, buf, sizeof(buf));
|
||||
param = spa_format_audio_raw_build(&b, SPA_PARAM_Format, &info);
|
||||
|
|
|
|||
|
|
@ -30,24 +30,6 @@
|
|||
|
||||
#include <extensions/protocol-native.h>
|
||||
|
||||
#if 0
|
||||
static void push_dict(struct spa_pod_builder *b, const struct spa_dict *dict)
|
||||
{
|
||||
uint32_t i, n_items;
|
||||
struct spa_pod_frame f;
|
||||
|
||||
n_items = dict ? dict->n_items : 0;
|
||||
|
||||
spa_pod_builder_push_struct(b, &f);
|
||||
spa_pod_builder_int(b, n_items);
|
||||
for (i = 0; i < n_items; i++) {
|
||||
spa_pod_builder_string(b, dict->items[i].key);
|
||||
spa_pod_builder_string(b, dict->items[i].value);
|
||||
}
|
||||
spa_pod_builder_pop(b, &f);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int device_marshal_add_listener(void *object,
|
||||
struct spa_hook *listener,
|
||||
const struct spa_device_events *events,
|
||||
|
|
@ -254,7 +236,7 @@ static int device_demarshal_info(void *object,
|
|||
else {
|
||||
infop = NULL;
|
||||
}
|
||||
pw_resource_do(resource, struct spa_device_events, info, 0, infop);
|
||||
pw_resource_notify(resource, struct spa_device_events, info, 0, infop);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -332,7 +314,7 @@ static int device_demarshal_result(void *object,
|
|||
break;
|
||||
}
|
||||
|
||||
pw_resource_do(resource, struct spa_device_events, result, 0, seq, res, type, result);
|
||||
pw_resource_notify(resource, struct spa_device_events, result, 0, seq, res, type, result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -364,7 +346,7 @@ static int device_demarshal_event(void *object,
|
|||
SPA_POD_PodObject(&event)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct spa_device_events, event, 0, event);
|
||||
pw_resource_notify(resource, struct spa_device_events, event, 0, event);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -458,7 +440,7 @@ static int device_demarshal_object_info(void *object,
|
|||
infop = NULL;
|
||||
}
|
||||
|
||||
pw_resource_do(resource, struct spa_device_events, object_info, 0, id, infop);
|
||||
pw_resource_notify(resource, struct spa_device_events, object_info, 0, id, infop);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,71 +44,6 @@ struct device_data {
|
|||
struct spa_hook proxy_listener;
|
||||
};
|
||||
|
||||
static void device_event_info(void *_data, const struct spa_device_info *info)
|
||||
{
|
||||
struct device_data *data = _data;
|
||||
struct spa_interface *iface = (struct spa_interface*)data->proxy;
|
||||
pw_log_debug("%p", data);
|
||||
spa_interface_call(iface, struct spa_device_events, info, 0, info);
|
||||
}
|
||||
|
||||
static void device_event_result(void *_data, int seq, int res, uint32_t type, const void *result)
|
||||
{
|
||||
struct device_data *data = _data;
|
||||
struct spa_interface *iface = (struct spa_interface*)data->proxy;
|
||||
pw_log_debug("%p", data);
|
||||
spa_interface_call(iface, struct spa_device_events, result, 0, seq, res, type, result);
|
||||
}
|
||||
|
||||
static void device_event_event(void *_data, const struct spa_event *event)
|
||||
{
|
||||
struct device_data *data = _data;
|
||||
struct spa_interface *iface = (struct spa_interface*)data->proxy;
|
||||
pw_log_debug("%p", data);
|
||||
spa_interface_call(iface, struct spa_device_events, event, 0, event);
|
||||
}
|
||||
|
||||
static void device_event_object_info(void *_data, uint32_t id,
|
||||
const struct spa_device_object_info *info)
|
||||
{
|
||||
struct device_data *data = _data;
|
||||
struct spa_interface *iface = (struct spa_interface*)data->proxy;
|
||||
pw_log_debug("%p", data);
|
||||
spa_interface_call(iface, struct spa_device_events, object_info, 0, id, info);
|
||||
}
|
||||
|
||||
static const struct spa_device_events device_events = {
|
||||
SPA_VERSION_DEVICE_EVENTS,
|
||||
.info = device_event_info,
|
||||
.result = device_event_result,
|
||||
.event = device_event_event,
|
||||
.object_info = device_event_object_info,
|
||||
};
|
||||
|
||||
static int device_method_enum_params(void *object, int seq,
|
||||
uint32_t id, uint32_t index, uint32_t max,
|
||||
const struct spa_pod *filter)
|
||||
{
|
||||
struct device_data *data = object;
|
||||
pw_log_debug("%p", data);
|
||||
return spa_device_enum_params(data->device, seq, id, index, max, filter);
|
||||
}
|
||||
|
||||
static int device_method_set_param(void *object,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
{
|
||||
struct device_data *data = object;
|
||||
pw_log_debug("%p", data);
|
||||
return spa_device_set_param(data->device, id, flags, param);
|
||||
}
|
||||
|
||||
static const struct spa_device_methods device_methods = {
|
||||
SPA_VERSION_DEVICE_METHODS,
|
||||
.enum_params = device_method_enum_params,
|
||||
.set_param = device_method_set_param,
|
||||
};
|
||||
|
||||
static void device_proxy_destroy(void *_data)
|
||||
{
|
||||
struct device_data *data = _data;
|
||||
|
|
@ -124,6 +59,7 @@ struct pw_proxy *pw_remote_spa_device_export(struct pw_remote *remote,
|
|||
uint32_t type, struct pw_properties *props, void *object)
|
||||
{
|
||||
struct spa_device *device = object;
|
||||
struct spa_interface *iface;
|
||||
struct pw_proxy *proxy;
|
||||
struct device_data *data;
|
||||
|
||||
|
|
@ -142,9 +78,14 @@ struct pw_proxy *pw_remote_spa_device_export(struct pw_remote *remote,
|
|||
data->core = pw_remote_get_core(remote);
|
||||
data->proxy = proxy;
|
||||
|
||||
iface = (struct spa_interface*)proxy;
|
||||
|
||||
pw_proxy_add_listener(proxy, &data->proxy_listener, &proxy_events, data);
|
||||
pw_proxy_add_proxy_listener(proxy, &data->device_methods, &device_methods, data);
|
||||
spa_device_add_listener(device, &data->device_listener, &device_events, data);
|
||||
|
||||
pw_proxy_add_object_listener(proxy, &data->device_methods,
|
||||
device->iface.cb.funcs, device->iface.cb.data);
|
||||
spa_device_add_listener(device, &data->device_listener,
|
||||
iface->cb.funcs, iface->cb.data);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,13 +49,14 @@ struct impl {
|
|||
|
||||
struct pw_resource *resource;
|
||||
struct spa_hook resource_listener;
|
||||
struct spa_hook implementation_listener;
|
||||
|
||||
struct pw_global *parent;
|
||||
unsigned int registered:1;
|
||||
};
|
||||
|
||||
#define pw_device_resource(r,m,v,...) \
|
||||
pw_resource_notify_res(r,struct spa_device_methods,m,v,__VA_ARGS__)
|
||||
pw_resource_call_res(r,struct spa_device_methods,m,v,__VA_ARGS__)
|
||||
|
||||
#define pw_device_resource_enum_params(r,...) \
|
||||
pw_device_resource(r,enum_params,0,__VA_ARGS__)
|
||||
|
|
@ -161,6 +162,7 @@ static void device_resource_destroy(void *data)
|
|||
impl->resource = NULL;
|
||||
spa_hook_remove(&impl->device_listener);
|
||||
spa_hook_remove(&impl->resource_listener);
|
||||
spa_hook_remove(&impl->implementation_listener);
|
||||
pw_device_destroy(impl->device);
|
||||
}
|
||||
|
||||
|
|
@ -185,6 +187,7 @@ static void device_destroy(void *data)
|
|||
impl->device = NULL;
|
||||
spa_hook_remove(&impl->device_listener);
|
||||
spa_hook_remove(&impl->resource_listener);
|
||||
spa_hook_remove(&impl->implementation_listener);
|
||||
pw_resource_destroy(impl->resource);
|
||||
}
|
||||
|
||||
|
|
@ -227,12 +230,13 @@ struct pw_device *pw_client_device_new(struct pw_resource *resource,
|
|||
&impl->device_listener,
|
||||
&device_events, impl);
|
||||
pw_resource_add_listener(impl->resource,
|
||||
&impl->resource_listener,
|
||||
&resource_events,
|
||||
impl);
|
||||
pw_resource_set_implementation(impl->resource,
|
||||
&resource_implementation,
|
||||
impl);
|
||||
&impl->resource_listener,
|
||||
&resource_events,
|
||||
impl);
|
||||
pw_resource_add_object_listener(impl->resource,
|
||||
&impl->implementation_listener,
|
||||
&resource_implementation,
|
||||
impl);
|
||||
|
||||
return device;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ struct impl {
|
|||
|
||||
struct spa_hook node_listener;
|
||||
struct spa_hook resource_listener;
|
||||
struct spa_hook object_listener;
|
||||
|
||||
struct pw_array mems;
|
||||
|
||||
|
|
@ -174,7 +175,7 @@ struct impl {
|
|||
};
|
||||
|
||||
#define pw_client_node_resource(r,m,v,...) \
|
||||
pw_resource_notify_res(r,struct pw_client_node_proxy_events,m,v,__VA_ARGS__)
|
||||
pw_resource_call_res(r,struct pw_client_node_proxy_events,m,v,__VA_ARGS__)
|
||||
|
||||
#define pw_client_node_resource_add_mem(r,...) \
|
||||
pw_client_node_resource(r,add_mem,0,__VA_ARGS__)
|
||||
|
|
@ -476,11 +477,10 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
|
|||
|
||||
update_io(this, this->ios, id, memid);
|
||||
|
||||
pw_client_node_resource_set_io(this->resource,
|
||||
return pw_client_node_resource_set_io(this->resource,
|
||||
id,
|
||||
memid,
|
||||
mem_offset, mem_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_send_command(void *object, const struct spa_command *command)
|
||||
|
|
@ -1224,6 +1224,7 @@ static void client_node_resource_destroy(void *data)
|
|||
|
||||
impl->node.resource = this->resource = NULL;
|
||||
spa_hook_remove(&impl->resource_listener);
|
||||
spa_hook_remove(&impl->object_listener);
|
||||
|
||||
if (node->data_source.fd != -1) {
|
||||
spa_loop_invoke(node->data_loop,
|
||||
|
|
@ -1695,12 +1696,13 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
|
|||
this->node->rt.target.data = impl;
|
||||
|
||||
pw_resource_add_listener(this->resource,
|
||||
&impl->resource_listener,
|
||||
&resource_events,
|
||||
impl);
|
||||
pw_resource_set_implementation(this->resource,
|
||||
&client_node_methods,
|
||||
impl);
|
||||
&impl->resource_listener,
|
||||
&resource_events,
|
||||
impl);
|
||||
pw_resource_add_object_listener(this->resource,
|
||||
&impl->object_listener,
|
||||
&client_node_methods,
|
||||
impl);
|
||||
|
||||
this->node->port_user_data_size = sizeof(struct port);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ static int client_node_marshal_add_listener(void *object,
|
|||
void *data)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
pw_proxy_add_proxy_listener(proxy, listener, events, data);
|
||||
pw_proxy_add_object_listener(proxy, listener, events, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -820,7 +820,7 @@ static int client_node_demarshal_get_node(void *object, const struct pw_protocol
|
|||
SPA_POD_Int(&new_id)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_client_node_proxy_methods, get_node, 0,
|
||||
return pw_resource_notify(resource, struct pw_client_node_proxy_methods, get_node, 0,
|
||||
version, new_id);
|
||||
}
|
||||
|
||||
|
|
@ -898,7 +898,7 @@ static int client_node_demarshal_update(void *object, const struct pw_protocol_n
|
|||
}
|
||||
}
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, update, 0, change_mask,
|
||||
pw_resource_notify(resource, struct pw_client_node_proxy_methods, update, 0, change_mask,
|
||||
n_params,
|
||||
params, infop);
|
||||
return 0;
|
||||
|
|
@ -980,7 +980,7 @@ static int client_node_demarshal_port_update(void *object, const struct pw_proto
|
|||
}
|
||||
}
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, port_update, 0, direction,
|
||||
pw_resource_notify(resource, struct pw_client_node_proxy_methods, port_update, 0, direction,
|
||||
port_id,
|
||||
change_mask,
|
||||
n_params,
|
||||
|
|
@ -999,7 +999,7 @@ static int client_node_demarshal_set_active(void *object, const struct pw_protoc
|
|||
SPA_POD_Bool(&active)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, set_active, 0, active);
|
||||
pw_resource_notify(resource, struct pw_client_node_proxy_methods, set_active, 0, active);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1014,7 +1014,7 @@ static int client_node_demarshal_event_method(void *object, const struct pw_prot
|
|||
SPA_POD_PodObject(&event)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_resource_do(resource, struct pw_client_node_proxy_methods, event, 0, event);
|
||||
pw_resource_notify(resource, struct pw_client_node_proxy_methods, event, 0, event);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ static int core_method_marshal_add_listener(void *object,
|
|||
void *data)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
pw_proxy_add_proxy_listener(proxy, listener, events, data);
|
||||
pw_proxy_add_object_listener(proxy, listener, events, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -401,7 +401,7 @@ static int core_method_demarshal_hello(void *object, const struct pw_protocol_na
|
|||
SPA_POD_Int(&version)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_core_proxy_methods, hello, 0, version);
|
||||
return pw_resource_notify(resource, struct pw_core_proxy_methods, hello, 0, version);
|
||||
}
|
||||
|
||||
static int core_method_demarshal_sync(void *object, const struct pw_protocol_native_message *msg)
|
||||
|
|
@ -416,7 +416,7 @@ static int core_method_demarshal_sync(void *object, const struct pw_protocol_nat
|
|||
SPA_POD_Int(&seq)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_core_proxy_methods, sync, 0, id, seq);
|
||||
return pw_resource_notify(resource, struct pw_core_proxy_methods, sync, 0, id, seq);
|
||||
}
|
||||
|
||||
static int core_method_demarshal_pong(void *object, const struct pw_protocol_native_message *msg)
|
||||
|
|
@ -431,7 +431,7 @@ static int core_method_demarshal_pong(void *object, const struct pw_protocol_nat
|
|||
SPA_POD_Int(&seq)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_core_proxy_methods, pong, 0, id, seq);
|
||||
return pw_resource_notify(resource, struct pw_core_proxy_methods, pong, 0, id, seq);
|
||||
}
|
||||
|
||||
static int core_method_demarshal_error(void *object, const struct pw_protocol_native_message *msg)
|
||||
|
|
@ -450,7 +450,7 @@ static int core_method_demarshal_error(void *object, const struct pw_protocol_na
|
|||
SPA_POD_String(&error)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_core_proxy_methods, error, 0, id, seq, res, error);
|
||||
return pw_resource_notify(resource, struct pw_core_proxy_methods, error, 0, id, seq, res, error);
|
||||
}
|
||||
|
||||
static int core_method_demarshal_get_registry(void *object, const struct pw_protocol_native_message *msg)
|
||||
|
|
@ -465,7 +465,7 @@ static int core_method_demarshal_get_registry(void *object, const struct pw_prot
|
|||
SPA_POD_Int(&new_id)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_core_proxy_methods, get_registry, 0, version, new_id);
|
||||
return pw_resource_notify(resource, struct pw_core_proxy_methods, get_registry, 0, version, new_id);
|
||||
}
|
||||
|
||||
static int core_method_demarshal_create_object(void *object, const struct pw_protocol_native_message *msg)
|
||||
|
|
@ -504,7 +504,7 @@ static int core_method_demarshal_create_object(void *object, const struct pw_pro
|
|||
SPA_POD_Int(&new_id), NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_core_proxy_methods, create_object, 0, factory_name,
|
||||
return pw_resource_notify(resource, struct pw_core_proxy_methods, create_object, 0, factory_name,
|
||||
type, version,
|
||||
&props, new_id);
|
||||
}
|
||||
|
|
@ -527,7 +527,7 @@ static int core_method_demarshal_destroy(void *object, const struct pw_protocol_
|
|||
if ((r = pw_client_find_resource(client, id)) == NULL)
|
||||
goto no_resource;
|
||||
|
||||
return pw_resource_do(resource, struct pw_core_proxy_methods, destroy, 0, r);
|
||||
return pw_resource_notify(resource, struct pw_core_proxy_methods, destroy, 0, r);
|
||||
|
||||
no_resource:
|
||||
pw_log_error("client %p: can't find resouce %d", client, id);
|
||||
|
|
@ -541,7 +541,7 @@ static int registry_method_marshal_add_listener(void *object,
|
|||
void *data)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
pw_proxy_add_proxy_listener(proxy, listener, events, data);
|
||||
pw_proxy_add_object_listener(proxy, listener, events, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -594,7 +594,7 @@ static int registry_demarshal_bind(void *object, const struct pw_protocol_native
|
|||
SPA_POD_Int(&new_id)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_registry_proxy_methods, bind, 0, id, type, version, new_id);
|
||||
return pw_resource_notify(resource, struct pw_registry_proxy_methods, bind, 0, id, type, version, new_id);
|
||||
}
|
||||
|
||||
static int registry_demarshal_destroy(void *object, const struct pw_protocol_native_message *msg)
|
||||
|
|
@ -608,7 +608,7 @@ static int registry_demarshal_destroy(void *object, const struct pw_protocol_nat
|
|||
SPA_POD_Int(&id)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_registry_proxy_methods, destroy, 0, id);
|
||||
return pw_resource_notify(resource, struct pw_registry_proxy_methods, destroy, 0, id);
|
||||
}
|
||||
|
||||
static int module_method_marshal_add_listener(void *object,
|
||||
|
|
@ -617,7 +617,7 @@ static int module_method_marshal_add_listener(void *object,
|
|||
void *data)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
pw_proxy_add_proxy_listener(proxy, listener, events, data);
|
||||
pw_proxy_add_object_listener(proxy, listener, events, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -684,7 +684,7 @@ static int device_method_marshal_add_listener(void *object,
|
|||
void *data)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
pw_proxy_add_proxy_listener(proxy, listener, events, data);
|
||||
pw_proxy_add_object_listener(proxy, listener, events, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -833,7 +833,7 @@ static int device_demarshal_enum_params(void *object, const struct pw_protocol_n
|
|||
SPA_POD_Pod(&filter)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_device_proxy_methods, enum_params, 0,
|
||||
return pw_resource_notify(resource, struct pw_device_proxy_methods, enum_params, 0,
|
||||
seq, id, index, num, filter);
|
||||
}
|
||||
|
||||
|
|
@ -866,7 +866,7 @@ static int device_demarshal_set_param(void *object, const struct pw_protocol_nat
|
|||
SPA_POD_Pod(¶m)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_device_proxy_methods, set_param, 0, id, flags, param);
|
||||
return pw_resource_notify(resource, struct pw_device_proxy_methods, set_param, 0, id, flags, param);
|
||||
}
|
||||
|
||||
static int factory_method_marshal_add_listener(void *object,
|
||||
|
|
@ -875,7 +875,7 @@ static int factory_method_marshal_add_listener(void *object,
|
|||
void *data)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
pw_proxy_add_proxy_listener(proxy, listener, events, data);
|
||||
pw_proxy_add_object_listener(proxy, listener, events, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -942,7 +942,7 @@ static int node_method_marshal_add_listener(void *object,
|
|||
void *data)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
pw_proxy_add_proxy_listener(proxy, listener, events, data);
|
||||
pw_proxy_add_object_listener(proxy, listener, events, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1095,7 +1095,7 @@ static int node_demarshal_subscribe_params(void *object, const struct pw_protoco
|
|||
if (ctype != SPA_TYPE_Id)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_node_proxy_methods, subscribe_params, 0,
|
||||
return pw_resource_notify(resource, struct pw_node_proxy_methods, subscribe_params, 0,
|
||||
ids, n_ids);
|
||||
}
|
||||
|
||||
|
|
@ -1135,7 +1135,7 @@ static int node_demarshal_enum_params(void *object, const struct pw_protocol_nat
|
|||
SPA_POD_Pod(&filter)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_node_proxy_methods, enum_params, 0,
|
||||
return pw_resource_notify(resource, struct pw_node_proxy_methods, enum_params, 0,
|
||||
seq, id, index, num, filter);
|
||||
}
|
||||
|
||||
|
|
@ -1168,7 +1168,7 @@ static int node_demarshal_set_param(void *object, const struct pw_protocol_nativ
|
|||
SPA_POD_Pod(¶m)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_node_proxy_methods, set_param, 0, id, flags, param);
|
||||
return pw_resource_notify(resource, struct pw_node_proxy_methods, set_param, 0, id, flags, param);
|
||||
}
|
||||
|
||||
static int node_marshal_send_command(void *object, const struct spa_command *command)
|
||||
|
|
@ -1193,7 +1193,7 @@ static int node_demarshal_send_command(void *object, const struct pw_protocol_na
|
|||
SPA_POD_Pod(&command)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_node_proxy_methods, send_command, 0, command);
|
||||
return pw_resource_notify(resource, struct pw_node_proxy_methods, send_command, 0, command);
|
||||
}
|
||||
|
||||
static int port_method_marshal_add_listener(void *object,
|
||||
|
|
@ -1202,7 +1202,7 @@ static int port_method_marshal_add_listener(void *object,
|
|||
void *data)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
pw_proxy_add_proxy_listener(proxy, listener, events, data);
|
||||
pw_proxy_add_object_listener(proxy, listener, events, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1342,7 +1342,7 @@ static int port_demarshal_subscribe_params(void *object, const struct pw_protoco
|
|||
if (ctype != SPA_TYPE_Id)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_port_proxy_methods, subscribe_params, 0,
|
||||
return pw_resource_notify(resource, struct pw_port_proxy_methods, subscribe_params, 0,
|
||||
ids, n_ids);
|
||||
}
|
||||
|
||||
|
|
@ -1382,7 +1382,7 @@ static int port_demarshal_enum_params(void *object, const struct pw_protocol_nat
|
|||
SPA_POD_Pod(&filter)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_port_proxy_methods, enum_params, 0,
|
||||
return pw_resource_notify(resource, struct pw_port_proxy_methods, enum_params, 0,
|
||||
seq, id, index, num, filter);
|
||||
}
|
||||
|
||||
|
|
@ -1392,7 +1392,7 @@ static int client_method_marshal_add_listener(void *object,
|
|||
void *data)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
pw_proxy_add_proxy_listener(proxy, listener, events, data);
|
||||
pw_proxy_add_object_listener(proxy, listener, events, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1535,7 +1535,7 @@ static int client_demarshal_error(void *object, const struct pw_protocol_native_
|
|||
SPA_POD_String(&error)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_client_proxy_methods, error, 0, id, res, error);
|
||||
return pw_resource_notify(resource, struct pw_client_proxy_methods, error, 0, id, res, error);
|
||||
}
|
||||
|
||||
static int client_marshal_get_permissions(void *object, uint32_t index, uint32_t num)
|
||||
|
|
@ -1589,7 +1589,7 @@ static int client_demarshal_update_properties(void *object, const struct pw_prot
|
|||
SPA_POD_String(&props.items[i].value), NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
return pw_resource_do(resource, struct pw_client_proxy_methods, update_properties, 0,
|
||||
return pw_resource_notify(resource, struct pw_client_proxy_methods, update_properties, 0,
|
||||
&props);
|
||||
}
|
||||
|
||||
|
|
@ -1605,7 +1605,7 @@ static int client_demarshal_get_permissions(void *object, const struct pw_protoc
|
|||
SPA_POD_Int(&num)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_resource_do(resource, struct pw_client_proxy_methods, get_permissions, 0, index, num);
|
||||
return pw_resource_notify(resource, struct pw_client_proxy_methods, get_permissions, 0, index, num);
|
||||
}
|
||||
|
||||
static int client_marshal_update_permissions(void *object, uint32_t n_permissions,
|
||||
|
|
@ -1650,7 +1650,7 @@ static int client_demarshal_update_permissions(void *object, const struct pw_pro
|
|||
SPA_POD_Int(&permissions[i].permissions), NULL) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
return pw_resource_do(resource, struct pw_client_proxy_methods, update_permissions, 0,
|
||||
return pw_resource_notify(resource, struct pw_client_proxy_methods, update_permissions, 0,
|
||||
n_permissions, permissions);
|
||||
}
|
||||
|
||||
|
|
@ -1660,7 +1660,7 @@ static int link_method_marshal_add_listener(void *object,
|
|||
void *data)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
pw_proxy_add_proxy_listener(proxy, listener, events, data);
|
||||
pw_proxy_add_object_listener(proxy, listener, events, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,12 +38,13 @@ struct impl {
|
|||
struct pw_array permissions;
|
||||
};
|
||||
|
||||
#define pw_client_resource(r,m,v,...) pw_resource_notify(r,struct pw_client_proxy_events,m,v,__VA_ARGS__)
|
||||
#define pw_client_resource(r,m,v,...) pw_resource_call(r,struct pw_client_proxy_events,m,v,__VA_ARGS__)
|
||||
#define pw_client_resource_info(r,...) pw_client_resource(r,info,0,__VA_ARGS__)
|
||||
#define pw_client_resource_permissions(r,...) pw_client_resource(r,permissions,0,__VA_ARGS__)
|
||||
|
||||
struct resource_data {
|
||||
struct spa_hook resource_listener;
|
||||
struct spa_hook object_listener;
|
||||
struct pw_client *client;
|
||||
};
|
||||
|
||||
|
|
@ -198,8 +199,12 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
|||
|
||||
data = pw_resource_get_user_data(resource);
|
||||
data->client = this;
|
||||
pw_resource_add_listener(resource, &data->resource_listener, &resource_events, resource);
|
||||
pw_resource_set_implementation(resource, &client_methods, resource);
|
||||
pw_resource_add_listener(resource,
|
||||
&data->resource_listener,
|
||||
&resource_events, resource);
|
||||
pw_resource_add_object_listener(resource,
|
||||
&data->object_listener,
|
||||
&client_methods, resource);
|
||||
|
||||
pw_log_debug("client %p: bound to %d", this, resource->id);
|
||||
|
||||
|
|
|
|||
|
|
@ -97,10 +97,6 @@ struct pw_client_events {
|
|||
/** emited when a new resource is added for client */
|
||||
void (*resource_added) (void *data, struct pw_resource *resource);
|
||||
|
||||
/** emited when an implementation is set on a resource. This can
|
||||
* be used to override the implementation */
|
||||
void (*resource_impl) (void *data, struct pw_resource *resource);
|
||||
|
||||
/** emited when a resource is removed */
|
||||
void (*resource_removed) (void *data, struct pw_resource *resource);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ struct impl {
|
|||
|
||||
struct resource_data {
|
||||
struct spa_hook resource_listener;
|
||||
struct spa_hook object_listener;
|
||||
};
|
||||
|
||||
/** \endcond */
|
||||
|
|
@ -233,13 +234,13 @@ static struct pw_registry_proxy * core_get_registry(void *object, uint32_t versi
|
|||
|
||||
data = pw_resource_get_user_data(registry_resource);
|
||||
pw_resource_add_listener(registry_resource,
|
||||
&data->resource_listener,
|
||||
&resource_events,
|
||||
registry_resource);
|
||||
|
||||
pw_resource_set_implementation(registry_resource,
|
||||
®istry_methods,
|
||||
registry_resource);
|
||||
&data->resource_listener,
|
||||
&resource_events,
|
||||
registry_resource);
|
||||
pw_resource_add_object_listener(registry_resource,
|
||||
&data->object_listener,
|
||||
®istry_methods,
|
||||
registry_resource);
|
||||
|
||||
spa_list_append(&this->registry_resource_list, ®istry_resource->link);
|
||||
|
||||
|
|
@ -386,9 +387,13 @@ global_bind(void *_data,
|
|||
goto no_mem;
|
||||
|
||||
data = pw_resource_get_user_data(resource);
|
||||
pw_resource_add_listener(resource, &data->resource_listener, &core_resource_events, resource);
|
||||
|
||||
pw_resource_set_implementation(resource, &core_methods, resource);
|
||||
pw_resource_add_listener(resource,
|
||||
&data->resource_listener,
|
||||
&core_resource_events,
|
||||
resource);
|
||||
pw_resource_add_object_listener(resource,
|
||||
&data->object_listener,
|
||||
&core_methods, resource);
|
||||
|
||||
spa_list_append(&global->resource_list, &resource->link);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ struct impl {
|
|||
struct pw_device this;
|
||||
};
|
||||
|
||||
#define pw_device_resource(r,m,v,...) pw_resource_notify(r,struct pw_device_proxy_events,m,v,__VA_ARGS__)
|
||||
#define pw_device_resource(r,m,v,...) pw_resource_call(r,struct pw_device_proxy_events,m,v,__VA_ARGS__)
|
||||
#define pw_device_resource_info(r,...) pw_device_resource(r,info,0,__VA_ARGS__)
|
||||
#define pw_device_resource_param(r,...) pw_device_resource(r,param,0,__VA_ARGS__)
|
||||
|
||||
|
|
@ -49,10 +49,12 @@ struct result_device_params_data {
|
|||
};
|
||||
|
||||
struct resource_data {
|
||||
struct spa_hook resource_listener;
|
||||
struct pw_device *device;
|
||||
struct pw_resource *resource;
|
||||
|
||||
struct spa_hook resource_listener;
|
||||
struct spa_hook object_listener;
|
||||
|
||||
/* for async replies */
|
||||
int seq;
|
||||
int end;
|
||||
|
|
@ -294,9 +296,13 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
|||
data = pw_resource_get_user_data(resource);
|
||||
data->device = this;
|
||||
data->resource = resource;
|
||||
pw_resource_add_listener(resource, &data->resource_listener, &resource_events, data);
|
||||
|
||||
pw_resource_set_implementation(resource, &device_methods, data);
|
||||
pw_resource_add_listener(resource,
|
||||
&data->resource_listener,
|
||||
&resource_events, data);
|
||||
pw_resource_add_object_listener(resource,
|
||||
&data->object_listener,
|
||||
&device_methods, data);
|
||||
|
||||
pw_log_debug("device %p: bound to %d", this, resource->id);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#include "pipewire/interfaces.h"
|
||||
#include "pipewire/keys.h"
|
||||
|
||||
#define pw_factory_resource_info(r,...) pw_resource_notify(r,struct pw_factory_proxy_events,info,0,__VA_ARGS__)
|
||||
#define pw_factory_resource_info(r,...) pw_resource_call(r,struct pw_factory_proxy_events,info,0,__VA_ARGS__)
|
||||
|
||||
struct resource_data {
|
||||
struct spa_hook resource_listener;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
#define MAX_BUFFERS 64
|
||||
|
||||
#define pw_link_resource_info(r,...) pw_resource_notify(r,struct pw_link_proxy_events,info,0,__VA_ARGS__)
|
||||
#define pw_link_resource_info(r,...) pw_resource_call(r,struct pw_link_proxy_events,info,0,__VA_ARGS__)
|
||||
|
||||
/** \cond */
|
||||
struct impl {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ struct impl {
|
|||
void *hnd;
|
||||
};
|
||||
|
||||
#define pw_module_resource_info(r,...) pw_resource_notify(r,struct pw_module_proxy_events,info,0,__VA_ARGS__)
|
||||
#define pw_module_resource_info(r,...) pw_resource_call(r,struct pw_module_proxy_events,info,0,__VA_ARGS__)
|
||||
|
||||
struct resource_data {
|
||||
struct spa_hook resource_listener;
|
||||
|
|
|
|||
|
|
@ -55,14 +55,17 @@ struct impl {
|
|||
unsigned int pause_on_idle:1;
|
||||
};
|
||||
|
||||
#define pw_node_resource(r,m,v,...) pw_resource_notify(r,struct pw_node_proxy_events,m,v,__VA_ARGS__)
|
||||
#define pw_node_resource(r,m,v,...) pw_resource_call(r,struct pw_node_proxy_events,m,v,__VA_ARGS__)
|
||||
#define pw_node_resource_info(r,...) pw_node_resource(r,info,0,__VA_ARGS__)
|
||||
#define pw_node_resource_param(r,...) pw_node_resource(r,param,0,__VA_ARGS__)
|
||||
|
||||
struct resource_data {
|
||||
struct spa_hook resource_listener;
|
||||
struct pw_node *node;
|
||||
struct pw_resource *resource;
|
||||
|
||||
struct spa_hook resource_listener;
|
||||
struct spa_hook object_listener;
|
||||
|
||||
uint32_t subscribe_ids[MAX_PARAMS];
|
||||
uint32_t n_subscribe_ids;
|
||||
};
|
||||
|
|
@ -439,9 +442,13 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
|||
data = pw_resource_get_user_data(resource);
|
||||
data->node = this;
|
||||
data->resource = resource;
|
||||
pw_resource_add_listener(resource, &data->resource_listener, &resource_events, resource);
|
||||
|
||||
pw_resource_set_implementation(resource, &node_methods, resource);
|
||||
pw_resource_add_listener(resource,
|
||||
&data->resource_listener,
|
||||
&resource_events, resource);
|
||||
pw_resource_add_object_listener(resource,
|
||||
&data->object_listener,
|
||||
&node_methods, resource);
|
||||
|
||||
pw_log_debug("node %p: bound to %d", this, resource->id);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,14 +42,17 @@ struct impl {
|
|||
struct spa_node mix_node; /**< mix node implementation */
|
||||
};
|
||||
|
||||
#define pw_port_resource(r,m,v,...) pw_resource_notify(r,struct pw_port_proxy_events,m,v,__VA_ARGS__)
|
||||
#define pw_port_resource(r,m,v,...) pw_resource_call(r,struct pw_port_proxy_events,m,v,__VA_ARGS__)
|
||||
#define pw_port_resource_info(r,...) pw_port_resource(r,info,0,__VA_ARGS__)
|
||||
#define pw_port_resource_param(r,...) pw_port_resource(r,param,0,__VA_ARGS__)
|
||||
|
||||
struct resource_data {
|
||||
struct spa_hook resource_listener;
|
||||
struct pw_port *port;
|
||||
struct pw_resource *resource;
|
||||
|
||||
struct spa_hook resource_listener;
|
||||
struct spa_hook object_listener;
|
||||
|
||||
uint32_t subscribe_ids[MAX_PARAMS];
|
||||
uint32_t n_subscribe_ids;
|
||||
};
|
||||
|
|
@ -598,9 +601,13 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
|||
data = pw_resource_get_user_data(resource);
|
||||
data->port = this;
|
||||
data->resource = resource;
|
||||
pw_resource_add_listener(resource, &data->resource_listener, &resource_events, resource);
|
||||
|
||||
pw_resource_set_implementation(resource, &port_methods, resource);
|
||||
pw_resource_add_listener(resource,
|
||||
&data->resource_listener,
|
||||
&resource_events, resource);
|
||||
pw_resource_add_object_listener(resource,
|
||||
&data->object_listener,
|
||||
&port_methods, resource);
|
||||
|
||||
pw_log_debug("port %p: bound to %d", this, resource->id);
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ struct pw_global {
|
|||
#define pw_core_emit_global_added(c,g) pw_core_emit(c, global_added, 0, g)
|
||||
#define pw_core_emit_global_removed(c,g) pw_core_emit(c, global_removed, 0, g)
|
||||
|
||||
#define pw_core_resource(r,m,v,...) pw_resource_notify(r, struct pw_core_proxy_events, m, v, ##__VA_ARGS__)
|
||||
#define pw_core_resource(r,m,v,...) pw_resource_call(r, struct pw_core_proxy_events, m, v, ##__VA_ARGS__)
|
||||
#define pw_core_resource_info(r,...) pw_core_resource(r,info,0,__VA_ARGS__)
|
||||
#define pw_core_resource_done(r,...) pw_core_resource(r,done,0,__VA_ARGS__)
|
||||
#define pw_core_resource_ping(r,...) pw_core_resource(r,ping,0,__VA_ARGS__)
|
||||
|
|
@ -198,7 +198,7 @@ pw_core_resource_errorf(struct pw_resource *resource, uint32_t id, int seq,
|
|||
va_end(args);
|
||||
}
|
||||
|
||||
#define pw_registry_resource(r,m,v,...) pw_resource_notify(r, struct pw_registry_proxy_events,m,v,##__VA_ARGS__)
|
||||
#define pw_registry_resource(r,m,v,...) pw_resource_call(r, struct pw_registry_proxy_events,m,v,##__VA_ARGS__)
|
||||
#define pw_registry_resource_global(r,...) pw_registry_resource(r,global,0,__VA_ARGS__)
|
||||
#define pw_registry_resource_global_remove(r,...) pw_registry_resource(r,global_remove,0,__VA_ARGS__)
|
||||
|
||||
|
|
@ -626,9 +626,10 @@ struct pw_link {
|
|||
#define pw_resource_emit_error(o,s,r,m) pw_resource_emit(o, error, 0, s, r, m)
|
||||
|
||||
struct pw_resource {
|
||||
struct spa_interface impl; /**< event implementation */
|
||||
struct spa_interface impl; /**< object implementation */
|
||||
|
||||
struct pw_core *core; /**< the core object */
|
||||
struct spa_list link; /**< link in object resource_list */
|
||||
struct spa_list link; /**< link in global resource_list */
|
||||
|
||||
struct pw_client *client; /**< owner client */
|
||||
|
||||
|
|
@ -639,13 +640,11 @@ struct pw_resource {
|
|||
|
||||
unsigned int removed:1; /**< resource was removed from server */
|
||||
|
||||
struct spa_hook implementation;
|
||||
struct spa_hook_list implementation_list;
|
||||
struct spa_hook_list listener_list;
|
||||
struct spa_hook_list object_listener_list;
|
||||
|
||||
const struct pw_protocol_marshal *marshal;
|
||||
|
||||
void *access_private; /**< private data for access control */
|
||||
void *user_data; /**< extra user data */
|
||||
};
|
||||
|
||||
|
|
@ -655,7 +654,8 @@ struct pw_resource {
|
|||
#define pw_proxy_emit_error(p,s,r,m) pw_proxy_emit(p, error, 0, s, r, m)
|
||||
|
||||
struct pw_proxy {
|
||||
struct spa_interface impl; /**< method implementation */
|
||||
struct spa_interface impl; /**< object implementation */
|
||||
|
||||
struct pw_remote *remote; /**< the owner remote of this proxy */
|
||||
struct spa_list link; /**< link in the remote */
|
||||
|
||||
|
|
@ -663,7 +663,7 @@ struct pw_proxy {
|
|||
unsigned int removed:1; /**< proxy was removed from server */
|
||||
|
||||
struct spa_hook_list listener_list;
|
||||
struct spa_hook_list proxy_listener_list;
|
||||
struct spa_hook_list object_listener_list;
|
||||
|
||||
const struct pw_protocol_marshal *marshal; /**< protocol specific marshal functions */
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ struct pw_proxy *pw_proxy_new(struct pw_proxy *factory,
|
|||
this->remote = remote;
|
||||
|
||||
spa_hook_list_init(&this->listener_list);
|
||||
spa_hook_list_init(&this->proxy_listener_list);
|
||||
spa_hook_list_init(&this->object_listener_list);
|
||||
|
||||
this->id = pw_map_insert_new(&remote->objects, this);
|
||||
|
||||
|
|
@ -121,12 +121,12 @@ void pw_proxy_add_listener(struct pw_proxy *proxy,
|
|||
}
|
||||
|
||||
SPA_EXPORT
|
||||
void pw_proxy_add_proxy_listener(struct pw_proxy *proxy,
|
||||
void pw_proxy_add_object_listener(struct pw_proxy *proxy,
|
||||
struct spa_hook *listener,
|
||||
const void *events,
|
||||
const void *funcs,
|
||||
void *data)
|
||||
{
|
||||
spa_hook_list_append(&proxy->proxy_listener_list, listener, events, data);
|
||||
spa_hook_list_append(&proxy->object_listener_list, listener, funcs, data);
|
||||
}
|
||||
|
||||
/** Destroy a proxy object
|
||||
|
|
@ -189,9 +189,9 @@ int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error, ...)
|
|||
}
|
||||
|
||||
SPA_EXPORT
|
||||
struct spa_hook_list *pw_proxy_get_proxy_listeners(struct pw_proxy *proxy)
|
||||
struct spa_hook_list *pw_proxy_get_object_listeners(struct pw_proxy *proxy)
|
||||
{
|
||||
return &proxy->proxy_listener_list;
|
||||
return &proxy->object_listener_list;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
|
|
|
|||
|
|
@ -131,11 +131,11 @@ void pw_proxy_add_listener(struct pw_proxy *proxy,
|
|||
const struct pw_proxy_events *events,
|
||||
void *data);
|
||||
|
||||
/** Add a listener for the events received from the remote resource. The
|
||||
* events depend on the type of the remote resource. */
|
||||
void pw_proxy_add_proxy_listener(struct pw_proxy *proxy, /**< the proxy */
|
||||
/** Add a listener for the events received from the remote object. The
|
||||
* events depend on the type of the remote object type. */
|
||||
void pw_proxy_add_object_listener(struct pw_proxy *proxy, /**< the proxy */
|
||||
struct spa_hook *listener, /**< listener */
|
||||
const void *events, /**< proxied events */
|
||||
const void *funcs, /**< proxied functions */
|
||||
void *data /**< data passed to events */);
|
||||
|
||||
/** destroy a proxy */
|
||||
|
|
@ -158,12 +158,26 @@ int pw_proxy_sync(struct pw_proxy *proxy, int seq);
|
|||
int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error, ...);
|
||||
|
||||
/** Get the listener of proxy */
|
||||
struct spa_hook_list *pw_proxy_get_proxy_listeners(struct pw_proxy *proxy);
|
||||
struct spa_hook_list *pw_proxy_get_object_listeners(struct pw_proxy *proxy);
|
||||
|
||||
/** Get the marshal functions for the proxy */
|
||||
const struct pw_protocol_marshal *pw_proxy_get_marshal(struct pw_proxy *proxy);
|
||||
|
||||
#define pw_proxy_notify(p,type,event,ver,...) spa_hook_list_call(pw_proxy_get_proxy_listeners(p),type,event,ver,## __VA_ARGS__)
|
||||
#define pw_proxy_notify(p,type,event,version,...) \
|
||||
spa_hook_list_call(pw_proxy_get_object_listeners(p), \
|
||||
type, event, version, ## __VA_ARGS__)
|
||||
|
||||
#define pw_proxy_call(p,type,method,version,...) \
|
||||
spa_interface_call((struct spa_interface*)p, \
|
||||
type, method, version, ##__VA_ARGS__)
|
||||
|
||||
#define pw_proxy_call_res(p,type,method,version,...) \
|
||||
({ \
|
||||
int _res = -ENOTSUP; \
|
||||
spa_interface_call_res((struct spa_interface*)p, \
|
||||
type, _res, method, version, ##__VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,9 +60,8 @@ struct pw_resource *pw_resource_new(struct pw_client *client,
|
|||
this->type = type;
|
||||
this->version = version;
|
||||
|
||||
spa_hook_list_init(&this->implementation_list);
|
||||
spa_hook_list_append(&this->implementation_list, &this->implementation, NULL, NULL);
|
||||
spa_hook_list_init(&this->listener_list);
|
||||
spa_hook_list_init(&this->object_listener_list);
|
||||
|
||||
if (id == SPA_ID_INVALID) {
|
||||
id = pw_map_insert_new(&client->objects, this);
|
||||
|
|
@ -141,30 +140,18 @@ void pw_resource_add_listener(struct pw_resource *resource,
|
|||
}
|
||||
|
||||
SPA_EXPORT
|
||||
void pw_resource_set_implementation(struct pw_resource *resource,
|
||||
const void *implementation,
|
||||
void *data)
|
||||
void pw_resource_add_object_listener(struct pw_resource *resource,
|
||||
struct spa_hook *listener,
|
||||
const void *funcs,
|
||||
void *data)
|
||||
{
|
||||
struct pw_client *client = resource->client;
|
||||
|
||||
resource->implementation.cb = SPA_CALLBACKS_INIT(implementation, data);
|
||||
|
||||
pw_client_emit_resource_impl(client, resource);
|
||||
spa_hook_list_append(&resource->object_listener_list, listener, funcs, data);
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
void pw_resource_add_override(struct pw_resource *resource,
|
||||
struct spa_hook *listener,
|
||||
const void *implementation,
|
||||
void *data)
|
||||
struct spa_hook_list *pw_resource_get_object_listeners(struct pw_resource *resource)
|
||||
{
|
||||
spa_hook_list_prepend(&resource->implementation_list, listener, implementation, data);
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
struct spa_hook_list *pw_resource_get_implementation(struct pw_resource *resource)
|
||||
{
|
||||
return &resource->implementation_list;
|
||||
return &resource->object_listener_list;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
|
|
|
|||
|
|
@ -112,15 +112,10 @@ void pw_resource_add_listener(struct pw_resource *resource,
|
|||
void *data);
|
||||
|
||||
/** Set the resource implementation. */
|
||||
void pw_resource_set_implementation(struct pw_resource *resource,
|
||||
const void *implementation,
|
||||
void *data);
|
||||
|
||||
/** Override the implementation of a resource. */
|
||||
void pw_resource_add_override(struct pw_resource *resource,
|
||||
struct spa_hook *listener,
|
||||
const void *implementation,
|
||||
void *data);
|
||||
void pw_resource_add_object_listener(struct pw_resource *resource,
|
||||
struct spa_hook *listener,
|
||||
const void *funcs,
|
||||
void *data);
|
||||
|
||||
/** Generate an ping event for a resource. This will generate a pong event
|
||||
* with the same \a sequence number in the return value. */
|
||||
|
|
@ -129,27 +124,25 @@ int pw_resource_ping(struct pw_resource *resource, int seq);
|
|||
/** Generate an error for a resource */
|
||||
void pw_resource_error(struct pw_resource *resource, int res, const char *error, ...);
|
||||
|
||||
/** Get the implementation list of a resource */
|
||||
struct spa_hook_list *pw_resource_get_implementation(struct pw_resource *resource);
|
||||
/** Get the list of object listeners from a resource */
|
||||
struct spa_hook_list *pw_resource_get_object_listeners(struct pw_resource *resource);
|
||||
|
||||
/** Get the marshal functions for the resource */
|
||||
const struct pw_protocol_marshal *pw_resource_get_marshal(struct pw_resource *resource);
|
||||
|
||||
#define pw_resource_do(r,type,method,v,...) \
|
||||
spa_hook_list_call_once(pw_resource_get_implementation(r),type,method,v,## __VA_ARGS__)
|
||||
|
||||
#define pw_resource_do_parent(r,l,type,method,...) \
|
||||
spa_hook_list_call_once_start(pw_resource_get_implementation(r),l,type,method,v,## __VA_ARGS__)
|
||||
|
||||
#define pw_resource_notify(r,type,event,version,...) \
|
||||
spa_interface_call((struct spa_interface*)r, \
|
||||
type, event, version, ##__VA_ARGS__);
|
||||
spa_hook_list_call(pw_resource_get_object_listeners(r), \
|
||||
type, event, version, ## __VA_ARGS__)
|
||||
|
||||
#define pw_resource_notify_res(r,type,event,version,...) \
|
||||
#define pw_resource_call(r,type,method,version,...) \
|
||||
spa_interface_call((struct spa_interface*)r, \
|
||||
type, method, version, ##__VA_ARGS__)
|
||||
|
||||
#define pw_resource_call_res(r,type,method,version,...) \
|
||||
({ \
|
||||
int _res = -ENOTSUP; \
|
||||
spa_interface_call_res((struct spa_interface*)r, \
|
||||
type, _res, event, version, ##__VA_ARGS__); \
|
||||
type, _res, method, version, ##__VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ static void test_abi(void)
|
|||
void (*free) (void *data);
|
||||
void (*info_changed) (void *data, const struct pw_client_info *info);
|
||||
void (*resource_added) (void *data, struct pw_resource *resource);
|
||||
void (*resource_impl) (void *data, struct pw_resource *resource);
|
||||
void (*resource_removed) (void *data, struct pw_resource *resource);
|
||||
void (*busy_changed) (void *data, bool busy);
|
||||
} test = { PW_VERSION_CLIENT_EVENTS, NULL };
|
||||
|
|
@ -49,7 +48,6 @@ static void test_abi(void)
|
|||
TEST_FUNC(ev, test, free);
|
||||
TEST_FUNC(ev, test, info_changed);
|
||||
TEST_FUNC(ev, test, resource_added);
|
||||
TEST_FUNC(ev, test, resource_impl);
|
||||
TEST_FUNC(ev, test, resource_removed);
|
||||
TEST_FUNC(ev, test, busy_changed);
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ struct proxy_data {
|
|||
info_func_t info_func;
|
||||
pw_destroy_t destroy;
|
||||
struct spa_hook proxy_listener;
|
||||
struct spa_hook proxy_proxy_listener;
|
||||
struct spa_hook object_listener;
|
||||
};
|
||||
|
||||
struct command {
|
||||
|
|
@ -944,7 +944,7 @@ static bool bind_global(struct remote_data *rd, struct global *global, char **er
|
|||
pd->proxy = proxy;
|
||||
pd->info_func = info_func;
|
||||
pd->destroy = destroy;
|
||||
pw_proxy_add_proxy_listener(proxy, &pd->proxy_proxy_listener, events, pd);
|
||||
pw_proxy_add_object_listener(proxy, &pd->object_listener, events, pd);
|
||||
pw_proxy_add_listener(proxy, &pd->proxy_listener, &proxy_events, pd);
|
||||
|
||||
global->proxy = proxy;
|
||||
|
|
@ -1039,7 +1039,7 @@ static bool do_create_node(struct data *data, const char *cmd, char *args, char
|
|||
pd->rd = rd;
|
||||
pd->proxy = proxy;
|
||||
pd->destroy = (pw_destroy_t) pw_node_info_free;
|
||||
pw_proxy_add_proxy_listener(proxy, &pd->proxy_proxy_listener, &node_events, pd);
|
||||
pw_proxy_add_object_listener(proxy, &pd->object_listener, &node_events, pd);
|
||||
pw_proxy_add_listener(proxy, &pd->proxy_listener, &proxy_events, pd);
|
||||
|
||||
id = pw_map_insert_new(&data->vars, proxy);
|
||||
|
|
@ -1108,7 +1108,7 @@ static bool do_create_link(struct data *data, const char *cmd, char *args, char
|
|||
pd->rd = rd;
|
||||
pd->proxy = proxy;
|
||||
pd->destroy = (pw_destroy_t) pw_link_info_free;
|
||||
pw_proxy_add_proxy_listener(proxy, &pd->proxy_proxy_listener, &link_events, pd);
|
||||
pw_proxy_add_object_listener(proxy, &pd->object_listener, &link_events, pd);
|
||||
pw_proxy_add_listener(proxy, &pd->proxy_listener, &proxy_events, pd);
|
||||
|
||||
id = pw_map_insert_new(&data->vars, proxy);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ struct proxy_data {
|
|||
void *info;
|
||||
pw_destroy_t destroy;
|
||||
struct spa_hook proxy_listener;
|
||||
struct spa_hook proxy_proxy_listener;
|
||||
struct spa_hook object_listener;
|
||||
int pending_seq;
|
||||
struct spa_list pending_link;
|
||||
print_func_t print_func;
|
||||
|
|
@ -656,7 +656,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id,
|
|||
pd->pending_seq = 0;
|
||||
pd->print_func = print_func;
|
||||
spa_list_init(&pd->param_list);
|
||||
pw_proxy_add_proxy_listener(proxy, &pd->proxy_proxy_listener, events, pd);
|
||||
pw_proxy_add_object_listener(proxy, &pd->object_listener, events, pd);
|
||||
pw_proxy_add_listener(proxy, &pd->proxy_listener, &proxy_events, pd);
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue