mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-13 08:56:39 -05:00
hook: separate spa_callbacks from the hook
Make a spa_callbacks with just the functions and data and use this in the hook and objects.
This commit is contained in:
parent
6ee192dff5
commit
448c1937ad
28 changed files with 97 additions and 84 deletions
|
|
@ -103,14 +103,14 @@ struct spa_graph_node {
|
|||
struct spa_graph_state *state; /**< state of the node */
|
||||
struct spa_graph_link graph_link; /**< link in graph */
|
||||
struct spa_graph *subgraph; /**< subgraph or NULL */
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
struct spa_list sched_link; /**< link for scheduler */
|
||||
};
|
||||
|
||||
#define spa_graph_node_call(n,method,version,...) \
|
||||
({ \
|
||||
int __res = 0; \
|
||||
spa_hook_call_res(&(n)->callbacks, \
|
||||
spa_callbacks_call_res(&(n)->callbacks, \
|
||||
struct spa_graph_node_callbacks, __res, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
__res; \
|
||||
|
|
@ -250,7 +250,7 @@ spa_graph_node_set_callbacks(struct spa_graph_node *node,
|
|||
const struct spa_graph_node_callbacks *callbacks,
|
||||
void *data)
|
||||
{
|
||||
node->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
node->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -86,11 +86,11 @@ struct spa_monitor_callbacks {
|
|||
int (*event) (void *data, struct spa_event *event);
|
||||
};
|
||||
|
||||
#define spa_monitor_call(hook,method,version,...) \
|
||||
#define spa_monitor_call(callbacks,method,version,...) \
|
||||
({ \
|
||||
int __res = 0; \
|
||||
spa_hook_call_res(hook, struct spa_monitor_callbacks, __res, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
spa_callbacks_call_res(callbacks, struct spa_monitor_callbacks, \
|
||||
__res, method, version, ##__VA_ARGS__); \
|
||||
__res; \
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -208,12 +208,12 @@ struct spa_node_callbacks {
|
|||
uint32_t buffer_id);
|
||||
};
|
||||
|
||||
#define spa_node_call(hook,method,version,...) \
|
||||
#define spa_node_call(callbacks,method,version,...) \
|
||||
({ \
|
||||
int __res = 0; \
|
||||
spa_hook_call_res(hook, struct spa_node_callbacks, __res, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
__res; \
|
||||
int _res = 0; \
|
||||
spa_callbacks_call_res(callbacks, struct spa_node_callbacks, \
|
||||
_res, method, version, ##__VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
|
||||
#define spa_node_call_ready(hook,s) spa_node_call(hook, ready, 0, s)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ struct spa_pod_builder {
|
|||
uint32_t size;
|
||||
uint32_t _padding;
|
||||
struct spa_pod_builder_state state;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
};
|
||||
|
||||
#define SPA_POD_BUILDER_INIT(buffer,size) (struct spa_pod_builder){ buffer, size, }
|
||||
|
|
@ -72,7 +72,7 @@ static inline void
|
|||
spa_pod_builder_set_callbacks(struct spa_pod_builder *builder,
|
||||
const struct spa_pod_builder_callbacks *callbacks, void *data)
|
||||
{
|
||||
builder->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
builder->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
@ -127,7 +127,7 @@ static inline int spa_pod_builder_raw(struct spa_pod_builder *builder, const voi
|
|||
|
||||
if (offset + size > builder->size) {
|
||||
res = -ENOSPC;
|
||||
spa_hook_call_res(&builder->callbacks, struct spa_pod_builder_callbacks, res,
|
||||
spa_callbacks_call_res(&builder->callbacks, struct spa_pod_builder_callbacks, res,
|
||||
overflow, 0, offset + size);
|
||||
}
|
||||
if (res == 0)
|
||||
|
|
|
|||
|
|
@ -42,19 +42,26 @@ struct spa_hook_list {
|
|||
struct spa_list list;
|
||||
};
|
||||
|
||||
/** Callbacks, contains the structure with functions and the data passed
|
||||
* to the functions. The structure should also contain a version field that
|
||||
* is checked. */
|
||||
struct spa_callbacks {
|
||||
const void *funcs;
|
||||
void *data;
|
||||
};
|
||||
|
||||
#define SPA_CALLBACKS_INIT(_funcs,_data) (struct spa_callbacks){ _funcs, _data, }
|
||||
|
||||
/** A hook, contains the structure with functions and the data passed
|
||||
* to the functions. */
|
||||
struct spa_hook {
|
||||
struct spa_list link;
|
||||
const void *funcs;
|
||||
void *data;
|
||||
struct spa_callbacks cb;
|
||||
void *priv; /**< private data for the hook list */
|
||||
void (*removed) (struct spa_hook *hook);
|
||||
|
||||
};
|
||||
|
||||
#define SPA_HOOK_INIT(_funcs,_data) (struct spa_hook){ .funcs = _funcs, .data = _data, }
|
||||
|
||||
/** Initialize a hook list */
|
||||
static inline void spa_hook_list_init(struct spa_hook_list *list)
|
||||
{
|
||||
|
|
@ -66,8 +73,7 @@ static inline void spa_hook_list_append(struct spa_hook_list *list,
|
|||
struct spa_hook *hook,
|
||||
const void *funcs, void *data)
|
||||
{
|
||||
hook->funcs = funcs;
|
||||
hook->data = data;
|
||||
hook->cb = SPA_CALLBACKS_INIT(funcs, data);
|
||||
spa_list_append(&list->list, &hook->link);
|
||||
}
|
||||
|
||||
|
|
@ -76,8 +82,7 @@ static inline void spa_hook_list_prepend(struct spa_hook_list *list,
|
|||
struct spa_hook *hook,
|
||||
const void *funcs, void *data)
|
||||
{
|
||||
hook->funcs = funcs;
|
||||
hook->data = data;
|
||||
hook->cb = SPA_CALLBACKS_INIT(funcs, data);
|
||||
spa_list_prepend(&list->list, &hook->link);
|
||||
}
|
||||
|
||||
|
|
@ -110,18 +115,18 @@ spa_hook_list_join(struct spa_hook_list *list,
|
|||
spa_list_insert_list(&list->list, &save->list);
|
||||
}
|
||||
|
||||
#define spa_hook_call(hook,type,method,vers,...) \
|
||||
#define spa_callbacks_call(callbacks,type,method,vers,...) \
|
||||
({ \
|
||||
const type *cb = (const type *) (hook)->funcs; \
|
||||
if (cb && cb->version >= vers && cb->method) \
|
||||
cb->method((hook)->data, ## __VA_ARGS__); \
|
||||
const type *_f = (const type *) (callbacks)->funcs; \
|
||||
if (_f && _f->version >= (vers) && _f->method) \
|
||||
_f->method((callbacks)->data, ## __VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define spa_hook_call_res(hook,type,res,method,vers,...) \
|
||||
#define spa_callbacks_call_res(callbacks,type,res,method,vers,...) \
|
||||
({ \
|
||||
const type *cb = (const type *) (hook)->funcs; \
|
||||
if (cb && cb->version >= vers && cb->method) \
|
||||
res = cb->method((hook)->data, ## __VA_ARGS__); \
|
||||
const type *_f = (const type *) (callbacks)->funcs; \
|
||||
if (_f && _f->version >= (vers) && _f->method) \
|
||||
res = _f->method((callbacks)->data, ## __VA_ARGS__); \
|
||||
res; \
|
||||
})
|
||||
|
||||
|
|
@ -130,7 +135,7 @@ spa_hook_list_join(struct spa_hook_list *list,
|
|||
struct spa_hook_list *_l = l; \
|
||||
struct spa_hook *_h, *_t; \
|
||||
spa_list_for_each_safe(_h, _t, &_l->list, link) \
|
||||
spa_hook_call(_h,type,method,vers, ## __VA_ARGS__); \
|
||||
spa_callbacks_call(&_h->cb,type,method,vers, ## __VA_ARGS__); \
|
||||
})
|
||||
|
||||
/** Call all hooks in a list, starting from the given one and optionally stopping
|
||||
|
|
@ -144,9 +149,9 @@ spa_hook_list_join(struct spa_hook_list *list,
|
|||
int count = 0; \
|
||||
spa_list_cursor_start(cursor, s, link); \
|
||||
spa_list_for_each_cursor(ci, cursor, &list->list, link) { \
|
||||
const type *cb = (const type *)ci->funcs; \
|
||||
if (cb && cb->version >= vers && cb->method) { \
|
||||
cb->method(ci->data, ## __VA_ARGS__); \
|
||||
const type *_f = (const type *)ci->cb.funcs; \
|
||||
if (_f && _f->version >= (vers) && _f->method) { \
|
||||
_f->method(ci->cb.data, ## __VA_ARGS__); \
|
||||
count++; \
|
||||
if (once) \
|
||||
break; \
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ struct impl {
|
|||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
|
||||
struct udev *udev;
|
||||
struct udev_monitor *umonitor;
|
||||
|
|
@ -377,7 +377,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
if (callbacks) {
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ struct state {
|
|||
snd_output_t *output;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
|
||||
uint64_t info_all;
|
||||
struct spa_node_info info;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
|
||||
bool async;
|
||||
struct spa_source timer_source;
|
||||
|
|
@ -510,7 +510,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ struct impl {
|
|||
struct spa_loop *data_loop;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
|
||||
uint64_t info_all;
|
||||
struct spa_node_info info;
|
||||
|
|
@ -974,7 +974,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ struct impl {
|
|||
struct spa_loop *data_loop;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
|
||||
uint64_t info_all;
|
||||
struct spa_node_info info;
|
||||
|
|
@ -607,7 +607,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ struct spa_bt_monitor {
|
|||
struct spa_dbus_connection *dbus_connection;
|
||||
DBusConnection *conn;
|
||||
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
|
||||
uint32_t count;
|
||||
|
||||
|
|
@ -2050,7 +2050,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
this = SPA_CONTAINER_OF(monitor, struct spa_bt_monitor, monitor);
|
||||
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
if (callbacks) {
|
||||
get_managed_objects(this);
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ struct spa_bt_transport {
|
|||
void *user_data;
|
||||
|
||||
struct spa_hook_list listener_list;
|
||||
struct spa_hook impl;
|
||||
struct spa_callbacks impl;
|
||||
};
|
||||
|
||||
#define spa_bt_transport_emit(t,m,v,...) spa_hook_list_call(&(t)->listener_list, \
|
||||
|
|
@ -228,12 +228,12 @@ struct spa_bt_transport {
|
|||
spa_hook_list_append(&(t)->listener_list, listener, events, data)
|
||||
|
||||
#define spa_bt_transport_set_implementation(t,_impl,_data) \
|
||||
(t)->impl = SPA_HOOK_INIT(_impl, _data)
|
||||
(t)->impl = SPA_CALLBACKS_INIT(_impl, _data)
|
||||
|
||||
#define spa_bt_transport_impl(t,m,v,...) \
|
||||
({ \
|
||||
int res = 0; \
|
||||
spa_hook_call_res(&(t)->impl, struct spa_bt_transport_implementation, res, m, v, ##__VA_ARGS__); \
|
||||
spa_callbacks_call_res(&(t)->impl, struct spa_bt_transport_implementation, res, m, v, ##__VA_ARGS__); \
|
||||
res; \
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -393,7 +393,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return -EINVAL;
|
||||
}
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -407,7 +407,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return -EINVAL;
|
||||
}
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ struct impl {
|
|||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
|
||||
struct udev *udev;
|
||||
struct udev_monitor *umonitor;
|
||||
|
|
@ -283,7 +283,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
if (callbacks) {
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
|
||||
struct port out_ports[1];
|
||||
|
||||
|
|
@ -383,7 +383,7 @@ static int impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
|
||||
bool async;
|
||||
struct spa_source timer_source;
|
||||
|
|
@ -455,7 +455,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ static void test_abi(void)
|
|||
/* builder */
|
||||
spa_assert(sizeof(struct spa_pod_frame) == 24);
|
||||
spa_assert(sizeof(struct spa_pod_builder_state) == 16);
|
||||
spa_assert(sizeof(struct spa_pod_builder) == 80);
|
||||
spa_assert(sizeof(struct spa_pod_builder) == 48);
|
||||
|
||||
/* command */
|
||||
spa_assert(sizeof(struct spa_command_body) == 8);
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ static void node_port_init(void *data, struct pw_port *port)
|
|||
if (direction == PW_DIRECTION_INPUT) {
|
||||
pw_log_debug("mix node %p", p->spa_node);
|
||||
pw_port_set_mix(port, p->spa_node, PW_PORT_MIX_FLAG_MULTI);
|
||||
port->impl = SPA_HOOK_INIT(&port_implementation, p);
|
||||
port->impl = SPA_CALLBACKS_INIT(&port_implementation, p);
|
||||
}
|
||||
spa_list_append(&n->ports, &p->link);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ struct node {
|
|||
struct spa_loop *data_loop;
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
struct io ios[MAX_IO];
|
||||
|
||||
struct pw_resource *resource;
|
||||
|
|
@ -520,7 +520,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct node, node);
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1529,7 +1529,7 @@ static void node_port_added(void *data, struct pw_port *port)
|
|||
PW_PORT_MIX_FLAG_MULTI |
|
||||
PW_PORT_MIX_FLAG_MIX_ONLY);
|
||||
|
||||
port->impl = SPA_HOOK_INIT(&port_impl, p);
|
||||
port->impl = SPA_CALLBACKS_INIT(&port_impl, p);
|
||||
port->owner_data = impl;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ struct node {
|
|||
struct spa_param_info params[5];
|
||||
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
};
|
||||
|
||||
struct impl {
|
||||
|
|
@ -377,7 +377,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct node, node);
|
||||
|
||||
this->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ void pw_factory_set_implementation(struct pw_factory *factory,
|
|||
const struct pw_factory_implementation *implementation,
|
||||
void *data)
|
||||
{
|
||||
factory->impl = SPA_HOOK_INIT(implementation, data);
|
||||
factory->impl = SPA_CALLBACKS_INIT(implementation, data);
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
|
|
@ -213,7 +213,7 @@ void *pw_factory_create_object(struct pw_factory *factory,
|
|||
uint32_t new_id)
|
||||
{
|
||||
void *res = NULL;
|
||||
spa_hook_call_res(&factory->impl,
|
||||
spa_callbacks_call_res(&factory->impl,
|
||||
struct pw_factory_implementation,
|
||||
res, create_object, 0,
|
||||
resource, type, version, properties, new_id);
|
||||
|
|
|
|||
|
|
@ -175,8 +175,7 @@ int pw_port_init_mix(struct pw_port *port, struct pw_port_mix *mix)
|
|||
if (port->mix->add_port)
|
||||
port->mix->add_port(port->mix, port->direction, port_id, NULL);
|
||||
|
||||
spa_hook_call_res(&port->impl, struct pw_port_implementation,
|
||||
res, init_mix, 0, mix);
|
||||
res = pw_port_call_init_mix(port, mix);
|
||||
|
||||
/* set the same format on the mixer as on the port if any */
|
||||
if (port->mix->enum_params && port->mix->set_param) {
|
||||
|
|
@ -211,8 +210,7 @@ int pw_port_release_mix(struct pw_port *port, struct pw_port_mix *mix)
|
|||
spa_list_remove(&mix->link);
|
||||
port->n_mix--;
|
||||
|
||||
spa_hook_call_res(&port->impl, struct pw_port_implementation,
|
||||
res, release_mix, 0, mix);
|
||||
res = pw_port_call_release_mix(port, mix);
|
||||
|
||||
if (port->mix->remove_port) {
|
||||
port->mix->remove_port(port->mix, port->direction, port_id);
|
||||
|
|
@ -1033,8 +1031,7 @@ int pw_port_use_buffers(struct pw_port *port, uint32_t mix_id,
|
|||
port->allocated = false;
|
||||
free_allocation(&port->allocation);
|
||||
|
||||
spa_hook_call_res(&port->impl, struct pw_port_implementation,
|
||||
res, use_buffers, 0, buffers, n_buffers);
|
||||
res = pw_port_call_use_buffers(port, buffers, n_buffers);
|
||||
}
|
||||
|
||||
if (n_buffers > 0 && !SPA_RESULT_IS_ASYNC(res)) {
|
||||
|
|
@ -1062,9 +1059,7 @@ int pw_port_alloc_buffers(struct pw_port *port,
|
|||
}
|
||||
|
||||
if (res >= 0) {
|
||||
spa_hook_call_res(&port->impl, struct pw_port_implementation,
|
||||
res, alloc_buffers, 0,
|
||||
params, n_params, buffers, n_buffers);
|
||||
res = pw_port_call_alloc_buffers(port, params, n_params, buffers, n_buffers);
|
||||
if (res < 0) {
|
||||
pw_log_error("port %p: %d implementation alloc failed: %d (%s)",
|
||||
port, port->port_id, res, spa_strerror(res));
|
||||
|
|
|
|||
|
|
@ -453,6 +453,20 @@ struct pw_port_implementation {
|
|||
struct spa_buffer **buffers, uint32_t *n_buffers);
|
||||
};
|
||||
|
||||
#define pw_port_call(p,m,v,...) \
|
||||
({ \
|
||||
int _res = 0; \
|
||||
spa_callbacks_call_res(&(p)->impl, \
|
||||
struct pw_port_implementation, \
|
||||
_res, m, v, ## __VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
|
||||
#define pw_port_call_init_mix(p,m) pw_port_call(p,init_mix,0,m)
|
||||
#define pw_port_call_release_mix(p,m) pw_port_call(p,release_mix,0,m)
|
||||
#define pw_port_call_use_buffers(p,b,n) pw_port_call(p,use_buffers,0,b,n)
|
||||
#define pw_port_call_alloc_buffers(p,pp,np,b,n) pw_port_call(p,alloc_buffers,0,pp,np,b,n)
|
||||
|
||||
#define pw_port_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_port_events, m, v, ##__VA_ARGS__)
|
||||
#define pw_port_emit_destroy(p) pw_port_emit(p, destroy, 0)
|
||||
#define pw_port_emit_free(p) pw_port_emit(p, free, 0)
|
||||
|
|
@ -497,7 +511,7 @@ struct pw_port {
|
|||
|
||||
struct spa_hook_list listener_list;
|
||||
|
||||
struct spa_hook impl;
|
||||
struct spa_callbacks impl;
|
||||
|
||||
struct spa_node *mix; /**< port buffer mix/split */
|
||||
#define PW_PORT_MIX_FLAG_MULTI (1<<0) /**< multi input or output */
|
||||
|
|
@ -700,7 +714,7 @@ struct pw_factory {
|
|||
|
||||
struct spa_hook_list listener_list; /**< event listeners */
|
||||
|
||||
struct spa_hook impl;
|
||||
struct spa_callbacks impl;
|
||||
|
||||
void *user_data;
|
||||
|
||||
|
|
|
|||
|
|
@ -142,8 +142,7 @@ void pw_resource_set_implementation(struct pw_resource *resource,
|
|||
{
|
||||
struct pw_client *client = resource->client;
|
||||
|
||||
resource->implementation.funcs = implementation;
|
||||
resource->implementation.data = data;
|
||||
resource->implementation.cb = SPA_CALLBACKS_INIT(implementation, data);
|
||||
|
||||
pw_client_emit_resource_impl(client, resource);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ struct stream {
|
|||
|
||||
struct spa_node impl_node;
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_hook callbacks;
|
||||
struct spa_callbacks callbacks;
|
||||
struct spa_io_buffers *io;
|
||||
struct spa_io_position *position;
|
||||
uint32_t io_control_size;
|
||||
|
|
@ -405,7 +405,7 @@ static int impl_set_callbacks(struct spa_node *node,
|
|||
{
|
||||
struct stream *d = SPA_CONTAINER_OF(node, struct stream, impl_node);
|
||||
|
||||
d->callbacks = SPA_HOOK_INIT(callbacks, data);
|
||||
d->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue