hooks: use hook to implement the callbacks

This way we get the version check implemented and save some
code.
This commit is contained in:
Wim Taymans 2019-05-15 11:19:23 +02:00
parent a78617c6a8
commit 6ee192dff5
26 changed files with 121 additions and 111 deletions

View file

@ -128,8 +128,7 @@ struct node {
struct spa_loop *data_loop;
struct spa_hook_list hooks;
const struct spa_node_callbacks *callbacks;
void *callbacks_data;
struct spa_hook callbacks;
struct io ios[MAX_IO];
struct pw_resource *resource;
@ -521,8 +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 = callbacks;
this->callbacks_data = data;
this->callbacks = SPA_HOOK_INIT(callbacks, data);
return 0;
}
@ -1115,8 +1113,7 @@ static void node_on_data_fd_events(struct spa_source *source)
spa_log_warn(this->log, "node %p: read %"PRIu64" failed %m", this, cmd);
spa_log_trace_fp(this->log, "node %p: got ready", this);
if (this->callbacks && this->callbacks->ready)
this->callbacks->ready(this->callbacks_data, SPA_STATUS_HAVE_BUFFER);
spa_node_call_ready(&this->callbacks, SPA_STATUS_HAVE_BUFFER);
}
}

View file

@ -72,8 +72,7 @@ struct node {
struct spa_param_info params[5];
struct spa_hook_list hooks;
const struct spa_node_callbacks *callbacks;
void *callbacks_data;
struct spa_hook callbacks;
};
struct impl {
@ -378,8 +377,7 @@ impl_node_set_callbacks(struct spa_node *node,
this = SPA_CONTAINER_OF(node, struct node, node);
this->callbacks = callbacks;
this->callbacks_data = data;
this->callbacks = SPA_HOOK_INIT(callbacks, data);
return 0;
}
@ -1234,7 +1232,7 @@ static int node_ready(void *data, int status)
impl_node_process(&impl->node.node);
impl->driver = true;
return impl->node.callbacks->ready(impl->node.callbacks_data, status);
return spa_node_call_ready(&impl->node.callbacks, status);
}
static const struct spa_node_callbacks node_callbacks = {