mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-08 13:30:08 -05:00
Cleanups
Only pass data to callbacks. Rename some structs Provide methods to access structs
This commit is contained in:
parent
1b79419554
commit
0602d76b9e
57 changed files with 716 additions and 422 deletions
|
|
@ -59,7 +59,7 @@ struct impl {
|
|||
struct spa_loop *main_loop;
|
||||
|
||||
const struct spa_monitor_callbacks *callbacks;
|
||||
void *user_data;
|
||||
void *callbacks_data;
|
||||
|
||||
struct udev *udev;
|
||||
struct udev_monitor *umonitor;
|
||||
|
|
@ -350,7 +350,7 @@ static void impl_on_fd_events(struct spa_source *source)
|
|||
|
||||
spa_pod_builder_object(&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->item);
|
||||
event = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_event);
|
||||
this->callbacks->event(&this->monitor, event, this->user_data);
|
||||
this->callbacks->event(this->callbacks_data, event);
|
||||
}
|
||||
close_card(this);
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ static void impl_on_fd_events(struct spa_source *source)
|
|||
static int
|
||||
impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
void *user_data)
|
||||
void *data)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
|
@ -368,7 +368,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks_data = data;
|
||||
|
||||
if (callbacks) {
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ static int do_send_done(struct spa_loop *loop, bool async, uint32_t seq, size_t
|
|||
{
|
||||
struct state *this = user_data;
|
||||
|
||||
this->callbacks->done(&this->node, seq, *(int*)data, this->user_data);
|
||||
this->callbacks->done(this->callbacks_data, seq, *(int*)data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
void *data)
|
||||
{
|
||||
struct state *this;
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ static int do_send_done(struct spa_loop *loop, bool async, uint32_t seq, size_t
|
|||
{
|
||||
struct state *this = user_data;
|
||||
|
||||
this->callbacks->done(&this->node, seq, *(int*)data, this->user_data);
|
||||
this->callbacks->done(this->callbacks_data, seq, *(int*)data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
void *data)
|
||||
{
|
||||
struct state *this;
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ pull_frames(struct state *state,
|
|||
io->range.offset = state->sample_count * state->frame_size;
|
||||
io->range.min_size = state->threshold * state->frame_size;
|
||||
io->range.max_size = frames * state->frame_size;
|
||||
state->callbacks->need_input(&state->node, state->user_data);
|
||||
state->callbacks->need_input(state->callbacks_data);
|
||||
}
|
||||
while (!spa_list_is_empty(&state->ready) && to_write > 0) {
|
||||
uint8_t *src, *dst;
|
||||
|
|
@ -373,10 +373,9 @@ pull_frames(struct state *state,
|
|||
b->outstanding = true;
|
||||
state->io->buffer_id = b->outbuf->id;
|
||||
spa_log_trace(state->log, "alsa-util %p: reuse buffer %u", state, b->outbuf->id);
|
||||
state->callbacks->reuse_buffer(&state->node,
|
||||
state->callbacks->reuse_buffer(state->callbacks_data,
|
||||
0,
|
||||
b->outbuf->id,
|
||||
state->user_data);
|
||||
b->outbuf->id);
|
||||
state->ready_offset = 0;
|
||||
}
|
||||
total_frames += n_frames;
|
||||
|
|
@ -432,7 +431,7 @@ push_frames(struct state *state,
|
|||
b->outstanding = true;
|
||||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_HAVE_BUFFER;
|
||||
state->callbacks->have_output(&state->node, state->user_data);
|
||||
state->callbacks->have_output(state->callbacks_data);
|
||||
}
|
||||
}
|
||||
return total_frames;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ struct state {
|
|||
snd_output_t *output;
|
||||
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *user_data;
|
||||
void *callbacks_data;
|
||||
|
||||
uint8_t props_buffer[1024];
|
||||
struct props props;
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *user_data;
|
||||
void *callbacks_data;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -352,7 +352,7 @@ static void on_output(struct spa_source *source)
|
|||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER)
|
||||
this->callbacks->have_output(&this->node, this->user_data);
|
||||
this->callbacks->have_output(this->callbacks_data);
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
|
|
@ -407,7 +407,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
void *data)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -420,7 +420,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *user_data;
|
||||
void *callbacks_data;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -226,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->node, this->user_data);
|
||||
this->callbacks->need_input(this->callbacks_data);
|
||||
}
|
||||
if (spa_list_is_empty(&this->ready)) {
|
||||
spa_log_error(this->log, NAME " %p: no buffers", this);
|
||||
|
|
@ -322,7 +322,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
void *data)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -335,7 +335,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *user_data;
|
||||
void *callbacks_data;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -279,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->node, this->user_data);
|
||||
this->callbacks->have_output(this->callbacks_data);
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
|
|
@ -334,7 +334,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
void *data)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ struct impl {
|
|||
struct spa_loop *main_loop;
|
||||
|
||||
const struct spa_monitor_callbacks *callbacks;
|
||||
void *user_data;
|
||||
void *callbacks_data;
|
||||
|
||||
struct udev *udev;
|
||||
struct udev_monitor *umonitor;
|
||||
|
|
@ -231,13 +231,13 @@ static void impl_on_fd_events(struct spa_source *source)
|
|||
spa_pod_builder_object(&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->uitem.item);
|
||||
|
||||
event = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_event);
|
||||
this->callbacks->event(&this->monitor, event, this->user_data);
|
||||
this->callbacks->event(this->callbacks_data, event);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
void *user_data)
|
||||
void *data)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
|
@ -247,7 +247,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks_data = data;
|
||||
if (callbacks) {
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *user_data;
|
||||
void *callbacks_data;
|
||||
|
||||
struct port out_ports[1];
|
||||
};
|
||||
|
|
@ -237,7 +237,7 @@ static int do_pause_done(struct spa_loop *loop,
|
|||
if (SPA_RESULT_IS_OK(res))
|
||||
res = spa_v4l2_stream_off(this);
|
||||
|
||||
this->callbacks->done(&this->node, seq, res, this->user_data);
|
||||
this->callbacks->done(this->callbacks_data, seq, res);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ static int do_start_done(struct spa_loop *loop,
|
|||
struct impl *this = user_data;
|
||||
int res = *(int*)data;
|
||||
|
||||
this->callbacks->done(&this->node, seq, res, this->user_data);
|
||||
this->callbacks->done(this->callbacks_data, seq, res);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -360,7 +360,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
|
||||
static int impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
void *data)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -369,7 +369,7 @@ static int impl_node_set_callbacks(struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -934,7 +934,7 @@ static int mmap_read(struct impl *this)
|
|||
b->outstanding = true;
|
||||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_HAVE_BUFFER;
|
||||
this->callbacks->have_output(&this->node, this->user_data);
|
||||
this->callbacks->have_output(this->callbacks_data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *user_data;
|
||||
void *callbacks_data;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -303,7 +303,7 @@ static void on_output(struct spa_source *source)
|
|||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER)
|
||||
this->callbacks->have_output(&this->node, this->user_data);
|
||||
this->callbacks->have_output(this->callbacks_data);
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
|
|
@ -358,7 +358,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
void *data)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -371,7 +371,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ struct impl {
|
|||
struct props props;
|
||||
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *user_data;
|
||||
void *callbacks_data;
|
||||
|
||||
uint8_t format_buffer[1024];
|
||||
struct spa_audio_info current_format;
|
||||
|
|
@ -210,7 +210,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
void *data)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -649,7 +649,7 @@ static struct spa_buffer *find_free_buffer(struct impl *this, struct port *port)
|
|||
static inline void release_buffer(struct impl *this, struct spa_buffer *buffer)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->reuse_buffer)
|
||||
this->callbacks->reuse_buffer(&this->node, 0, buffer->id, this->user_data);
|
||||
this->callbacks->reuse_buffer(this->callbacks_data, 0, buffer->id);
|
||||
}
|
||||
|
||||
static void do_volume(struct impl *this, struct spa_buffer *dbuf, struct spa_buffer *sbuf)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue