Add versions to structures

Use versions instead of size
Remove user_data from callbacks, we can simply pass the callback struct.
This commit is contained in:
Wim Taymans 2017-06-14 18:32:39 +02:00
parent 4a219e81dd
commit c3b73ba47d
45 changed files with 344 additions and 303 deletions

View file

@ -94,8 +94,7 @@ struct proxy {
struct spa_loop *main_loop;
struct spa_loop *data_loop;
struct spa_node_callbacks callbacks;
void *user_data;
const struct spa_node_callbacks *callbacks;
struct pw_resource *resource;
@ -210,8 +209,7 @@ static int spa_proxy_node_send_command(struct spa_node *node, struct spa_command
static int
spa_proxy_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks,
size_t callbacks_size, void *user_data)
const struct spa_node_callbacks *callbacks)
{
struct proxy *this;
@ -219,8 +217,7 @@ spa_proxy_node_set_callbacks(struct spa_node *node,
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF(node, struct proxy, node);
this->callbacks = *callbacks;
this->user_data = user_data;
this->callbacks = callbacks;
return SPA_RESULT_OK;
}
@ -850,14 +847,14 @@ static int handle_node_event(struct proxy *this, struct spa_event *event)
*io = impl->transport->outputs[i];
pw_log_trace("%d %d", io->status, io->buffer_id);
}
this->callbacks.have_output(&this->node, this->user_data);
this->callbacks->have_output(this->callbacks, &this->node);
} else if (SPA_EVENT_TYPE(event) == impl->core->type.event_transport.NeedInput) {
this->callbacks.need_input(&this->node, this->user_data);
this->callbacks->need_input(this->callbacks, &this->node);
} else if (SPA_EVENT_TYPE(event) == impl->core->type.event_transport.ReuseBuffer) {
struct pw_event_transport_reuse_buffer *p =
(struct pw_event_transport_reuse_buffer *) event;
this->callbacks.reuse_buffer(&this->node, p->body.port_id.value,
p->body.buffer_id.value, this->user_data);
this->callbacks->reuse_buffer(this->callbacks, &this->node, p->body.port_id.value,
p->body.buffer_id.value);
}
return SPA_RESULT_OK;
}
@ -870,7 +867,7 @@ client_node_done(void *object, int seq, int res)
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
struct proxy *this = &impl->proxy;
this->callbacks.done(&this->node, seq, res, this->user_data);
this->callbacks->done(this->callbacks, &this->node, seq, res);
}
@ -936,7 +933,7 @@ static void client_node_event(void *object, struct spa_event *event)
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
struct proxy *this = &impl->proxy;
this->callbacks.event(&this->node, event, this->user_data);
this->callbacks->event(this->callbacks, &this->node, event);
}
static void client_node_destroy(void *object)
@ -979,7 +976,7 @@ static void proxy_on_data_fd_events(struct spa_source *source)
}
static const struct spa_node proxy_node = {
sizeof(struct spa_node),
SPA_VERSION_NODE,
NULL,
spa_proxy_node_get_props,
spa_proxy_node_set_props,