mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05: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
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue