Add user_data to callbacks

Add user data to callbacks, it's more flexible and natural
This commit is contained in:
Wim Taymans 2017-06-18 19:48:31 +02:00
parent 59ec32c039
commit 763bd1100e
27 changed files with 156 additions and 165 deletions

View file

@ -123,6 +123,7 @@ struct impl {
struct props props;
const struct spa_node_callbacks *callbacks;
void *user_data;
struct spa_source timer_source;
struct itimerspec timerspec;
@ -350,7 +351,7 @@ static void on_output(struct spa_source *source)
res = make_buffer(this);
if (res == SPA_RESULT_HAVE_BUFFER)
this->callbacks->have_output(this->callbacks, &this->node);
this->callbacks->have_output(&this->node, this->user_data);
}
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
@ -404,7 +405,8 @@ static int impl_node_send_command(struct spa_node *node, struct spa_command *com
static int
impl_node_set_callbacks(struct spa_node *node,
const struct spa_node_callbacks *callbacks)
const struct spa_node_callbacks *callbacks,
void *user_data)
{
struct impl *this;
@ -417,6 +419,7 @@ impl_node_set_callbacks(struct spa_node *node,
return SPA_RESULT_ERROR;
}
this->callbacks = callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
}
@ -863,7 +866,8 @@ static int impl_node_process_output(struct spa_node *node)
this->io->buffer_id = SPA_ID_INVALID;
}
if ((this->callbacks == NULL || this->callbacks->have_output == NULL) && (io->status == SPA_RESULT_NEED_BUFFER))
if ((this->callbacks == NULL || this->callbacks->have_output == NULL) &&
(io->status == SPA_RESULT_NEED_BUFFER))
return make_buffer(this);
else
return SPA_RESULT_OK;