interfaces: make events return void

Events are dispatched with hooks and have no return value.

Make it possible to get the last resource and proxy sender value
for where we need it.
This commit is contained in:
Wim Taymans 2019-03-01 14:04:05 +01:00
parent 0390969228
commit 09c4683ef1
29 changed files with 269 additions and 330 deletions

View file

@ -88,17 +88,17 @@ struct spa_device_events {
uint32_t version;
/** notify extra information about the device */
int (*info) (void *data, const struct spa_device_info *info);
void (*info) (void *data, const struct spa_device_info *info);
/** notify a result */
int (*result) (void *data, int seq, int res, const void *result);
void (*result) (void *data, int seq, int res, const void *result);
/** a device event */
int (*event) (void *data, struct spa_event *event);
void (*event) (void *data, struct spa_event *event);
/** info changed for an object managed by the device, info is NULL when
* the object is removed */
int (*object_info) (void *data, uint32_t id,
void (*object_info) (void *data, uint32_t id,
const struct spa_device_object_info *info);
};

View file

@ -36,7 +36,7 @@ struct spa_result_device_params_data {
struct spa_result_device_params data;
};
static inline int spa_result_func_device_params(void *data, int seq, int res,
static inline void spa_result_func_device_params(void *data, int seq, int res,
const void *result)
{
struct spa_result_device_params_data *d =
@ -47,7 +47,6 @@ static inline int spa_result_func_device_params(void *data, int seq, int res,
spa_pod_builder_raw_padded(d->builder, r->param, SPA_POD_SIZE(r->param));
d->data.next = r->next;
d->data.param = SPA_MEMBER(d->builder->data, offset, struct spa_pod);
return 0;
}
static inline int spa_device_enum_params_sync(struct spa_device *device,

View file

@ -126,10 +126,10 @@ struct spa_node_events {
uint32_t version; /**< version of this structure */
/** Emited when info changes */
int (*info) (void *data, const struct spa_node_info *info);
void (*info) (void *data, const struct spa_node_info *info);
/** Emited when port info changes, NULL when port is removed */
int (*port_info) (void *data,
void (*port_info) (void *data,
enum spa_direction direction, uint32_t port,
const struct spa_port_info *info);
@ -149,7 +149,7 @@ struct spa_node_events {
* the method call. Users should match the seq number from
* request to the reply.
*/
int (*result) (void *data, int seq, int res, const void *result);
void (*result) (void *data, int seq, int res, const void *result);
/**
* \param node a spa_node
@ -158,7 +158,7 @@ struct spa_node_events {
* This will be called when an out-of-bound event is notified
* on \a node.
*/
int (*event) (void *data, struct spa_event *event);
void (*event) (void *data, struct spa_event *event);
};
#define spa_node_emit(hooks,method,version,...) \

View file

@ -36,7 +36,7 @@ struct spa_result_node_params_data {
struct spa_result_node_params data;
};
static inline int spa_result_func_node_params(void *data,
static inline void spa_result_func_node_params(void *data,
int seq, int res, const void *result)
{
struct spa_result_node_params_data *d =
@ -47,7 +47,6 @@ static inline int spa_result_func_node_params(void *data,
spa_pod_builder_raw_padded(d->builder, r->param, SPA_POD_SIZE(r->param));
d->data.next = r->next;
d->data.param = SPA_MEMBER(d->builder->data, offset, struct spa_pod);
return 0;
}
static inline int spa_node_enum_params_sync(struct spa_node *node,

View file

@ -553,25 +553,20 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
return 0;
}
static int on_node_result(void *data, int seq, int res, const void *result)
static void on_node_result(void *data, int seq, int res, const void *result)
{
struct impl *this = data;
spa_log_debug(this->log, "%p: result %d %d", this, seq, res);
spa_node_emit_result(&this->hooks, seq, res, result);
return 0;
}
static int fmt_input_port_info(void *data,
static void fmt_input_port_info(void *data,
enum spa_direction direction, uint32_t port,
const struct spa_port_info *info)
{
struct impl *this = data;
if (direction != SPA_DIRECTION_INPUT)
return 0;
spa_node_emit_port_info(&this->hooks, direction, port, info);
return 0;
if (direction == SPA_DIRECTION_INPUT)
spa_node_emit_port_info(&this->hooks, direction, port, info);
}
static struct spa_node_events fmt_input_events = {
@ -580,17 +575,13 @@ static struct spa_node_events fmt_input_events = {
.result = on_node_result,
};
static int fmt_output_port_info(void *data,
static void fmt_output_port_info(void *data,
enum spa_direction direction, uint32_t port,
const struct spa_port_info *info)
{
struct impl *this = data;
if (direction != SPA_DIRECTION_OUTPUT)
return 0;
spa_node_emit_port_info(&this->hooks, direction, port, info);
return 0;
if (direction == SPA_DIRECTION_OUTPUT)
spa_node_emit_port_info(&this->hooks, direction, port, info);
}
static struct spa_node_events fmt_output_events = {

View file

@ -52,7 +52,7 @@ struct data {
struct spa_hook listener;
};
static int print_param(void *data, int seq, int res, const void *result)
static void print_param(void *data, int seq, int res, const void *result)
{
const struct spa_result_node_params *r = result;
@ -60,7 +60,6 @@ static int print_param(void *data, int seq, int res, const void *result)
spa_debug_format(16, NULL, r->param);
else
spa_debug_pod(16, NULL, r->param);
return 0;
}
static void
@ -129,7 +128,7 @@ inspect_port_params(struct data *data, struct spa_node *node,
}
}
static int node_info(void *_data, const struct spa_node_info *info)
static void node_info(void *_data, const struct spa_node_info *info)
{
struct data *data = _data;
@ -144,10 +143,9 @@ static int node_info(void *_data, const struct spa_node_info *info)
if (info->change_mask & SPA_NODE_CHANGE_MASK_PARAMS) {
inspect_node_params(data, data->node, info->n_params, info->params);
}
return 0;
}
static int node_port_info(void *_data, enum spa_direction direction, uint32_t id,
static void node_port_info(void *_data, enum spa_direction direction, uint32_t id,
const struct spa_port_info *info)
{
struct data *data = _data;
@ -170,7 +168,6 @@ static int node_port_info(void *_data, enum spa_direction direction, uint32_t id
info->n_params, info->params);
}
}
return 0;
}
static const struct spa_node_events node_events =