mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
Add user_data to callbacks
Add user data to callbacks, it's more flexible and natural
This commit is contained in:
parent
59ec32c039
commit
763bd1100e
27 changed files with 156 additions and 165 deletions
|
|
@ -92,6 +92,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *user_data;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -225,7 +226,7 @@ static int consume_buffer(struct impl *this)
|
|||
if (spa_list_is_empty(&this->ready)) {
|
||||
io->status = SPA_RESULT_NEED_BUFFER;
|
||||
if (this->callbacks->need_input)
|
||||
this->callbacks->need_input(this->callbacks, &this->node);
|
||||
this->callbacks->need_input(&this->node, this->user_data);
|
||||
}
|
||||
if (spa_list_is_empty(&this->ready)) {
|
||||
spa_log_error(this->log, NAME " %p: no buffers", this);
|
||||
|
|
@ -320,7 +321,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;
|
||||
|
||||
|
|
@ -333,6 +335,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *user_data;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -278,7 +279,7 @@ static void on_output(struct spa_source *source)
|
|||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER && this->callbacks && this->callbacks->have_output)
|
||||
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)
|
||||
|
|
@ -332,7 +333,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;
|
||||
|
||||
|
|
@ -345,6 +347,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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue