mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
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:
parent
4a219e81dd
commit
c3b73ba47d
45 changed files with 344 additions and 303 deletions
|
|
@ -58,8 +58,7 @@ struct impl {
|
|||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
|
||||
struct spa_monitor_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_monitor_callbacks *callbacks;
|
||||
|
||||
struct udev *udev;
|
||||
struct udev_monitor *umonitor;
|
||||
|
|
@ -350,15 +349,14 @@ 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, &this->monitor, event);
|
||||
}
|
||||
close_card(this);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
size_t callbacks_size, void *user_data)
|
||||
const struct spa_monitor_callbacks *callbacks)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
|
@ -367,10 +365,9 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
if (callbacks) {
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
if (callbacks) {
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
return res;
|
||||
|
||||
|
|
@ -389,7 +386,6 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
spa_loop_add_source(this->main_loop, &this->source);
|
||||
} else {
|
||||
spa_zero(this->callbacks);
|
||||
spa_loop_remove_source(this->main_loop, &this->source);
|
||||
}
|
||||
|
||||
|
|
@ -454,8 +450,8 @@ static int impl_monitor_enum_items(struct spa_monitor *monitor,
|
|||
}
|
||||
|
||||
static const struct spa_monitor impl_monitor = {
|
||||
SPA_VERSION_MONITOR,
|
||||
NULL,
|
||||
sizeof(struct spa_monitor),
|
||||
impl_monitor_set_callbacks,
|
||||
impl_monitor_enum_items,
|
||||
};
|
||||
|
|
@ -542,6 +538,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_alsa_monitor_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -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, &this->node, seq, *(int*)data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -150,8 +150,7 @@ 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,
|
||||
size_t callbacks_size, void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct state *this;
|
||||
|
||||
|
|
@ -159,8 +158,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 = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -569,7 +567,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -692,6 +690,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_alsa_sink_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct state),
|
||||
|
|
|
|||
|
|
@ -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, &this->node, seq, *(int*)data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -168,7 +168,7 @@ 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, size_t callbacks_size, void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct state *this;
|
||||
|
||||
|
|
@ -176,8 +176,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 = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -578,7 +577,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -635,7 +634,7 @@ static int impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -746,7 +745,9 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_alsa_source_factory = { NAME,
|
||||
const struct spa_handle_factory spa_alsa_source_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct state),
|
||||
impl_init,
|
||||
|
|
|
|||
|
|
@ -324,7 +324,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, &state->node);
|
||||
}
|
||||
while (!spa_list_is_empty(&state->ready) && to_write > 0) {
|
||||
uint8_t *src, *dst;
|
||||
|
|
@ -371,7 +371,10 @@ 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, 0, b->outbuf->id, state->user_data);
|
||||
state->callbacks->reuse_buffer(state->callbacks,
|
||||
&state->node,
|
||||
0,
|
||||
b->outbuf->id);
|
||||
state->ready_offset = 0;
|
||||
}
|
||||
total_frames += n_frames;
|
||||
|
|
@ -427,7 +430,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, &state->node);
|
||||
}
|
||||
}
|
||||
return total_frames;
|
||||
|
|
|
|||
|
|
@ -118,8 +118,7 @@ struct state {
|
|||
snd_pcm_stream_t stream;
|
||||
snd_output_t *output;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
uint8_t props_buffer[1024];
|
||||
struct props props;
|
||||
|
|
|
|||
|
|
@ -87,8 +87,7 @@ struct impl {
|
|||
struct spa_type_map *map;
|
||||
struct spa_log *log;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
int port_count;
|
||||
int port_queued;
|
||||
|
|
@ -153,9 +152,7 @@ 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,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -163,8 +160,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 = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -774,7 +770,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -884,6 +880,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_audiomixer_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -122,8 +122,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -241,7 +240,7 @@ static int impl_node_set_props(struct spa_node *node, const struct spa_props *pr
|
|||
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
|
|
@ -263,7 +262,7 @@ static void read_timer(struct impl *this)
|
|||
{
|
||||
uint64_t expirations;
|
||||
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (read(this->timer_source.fd, &expirations, sizeof(uint64_t)) < sizeof(uint64_t))
|
||||
perror("read timerfd");
|
||||
}
|
||||
|
|
@ -351,7 +350,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, &this->node);
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
|
|
@ -405,9 +404,7 @@ 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,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -415,12 +412,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks->have_output != NULL) {
|
||||
if (this->data_loop == NULL && (callbacks && callbacks->have_output != NULL)) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -867,14 +863,14 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
this->io->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
if (!this->callbacks.have_output && (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;
|
||||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -935,7 +931,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -1061,6 +1057,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_audiotestsrc_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -71,8 +71,7 @@ struct impl {
|
|||
struct spa_type_map *map;
|
||||
struct spa_log *log;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct port in_ports[1];
|
||||
struct port out_ports[1];
|
||||
|
|
@ -111,9 +110,7 @@ static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, struct spa_co
|
|||
|
||||
static int
|
||||
spa_ffmpeg_dec_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 impl *this;
|
||||
|
||||
|
|
@ -122,8 +119,7 @@ spa_ffmpeg_dec_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 = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -432,7 +428,7 @@ spa_ffmpeg_dec_node_port_send_command(struct spa_node *node,
|
|||
|
||||
|
||||
static const struct spa_node ffmpeg_dec_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
spa_ffmpeg_dec_node_get_props,
|
||||
spa_ffmpeg_dec_node_set_props,
|
||||
|
|
|
|||
|
|
@ -75,8 +75,7 @@ struct impl {
|
|||
struct spa_type_map *map;
|
||||
struct spa_log *log;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct port in_ports[1];
|
||||
struct port out_ports[1];
|
||||
|
|
@ -115,8 +114,7 @@ static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, struct spa_co
|
|||
|
||||
static int
|
||||
spa_ffmpeg_enc_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 impl *this;
|
||||
|
||||
|
|
@ -125,8 +123,7 @@ spa_ffmpeg_enc_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 = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -426,7 +423,7 @@ static int spa_ffmpeg_enc_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node ffmpeg_enc_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
spa_ffmpeg_enc_node_get_props,
|
||||
spa_ffmpeg_enc_node_set_props,
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ static void on_trace_event(struct spa_source *source)
|
|||
}
|
||||
|
||||
static const struct spa_log impl_log = {
|
||||
sizeof(struct spa_log),
|
||||
SPA_VERSION_LOG,
|
||||
NULL,
|
||||
DEFAULT_LOG_LEVEL,
|
||||
impl_log_log,
|
||||
|
|
@ -256,6 +256,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
static const struct spa_handle_factory logger_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -592,7 +592,7 @@ static void loop_destroy_source(struct spa_source *source)
|
|||
}
|
||||
|
||||
static const struct spa_loop impl_loop = {
|
||||
sizeof(struct spa_loop),
|
||||
SPA_VERSION_LOOP,
|
||||
loop_add_source,
|
||||
loop_update_source,
|
||||
loop_remove_source,
|
||||
|
|
@ -600,7 +600,7 @@ static const struct spa_loop impl_loop = {
|
|||
};
|
||||
|
||||
static const struct spa_loop_control impl_loop_control = {
|
||||
sizeof(struct spa_loop_control),
|
||||
SPA_VERSION_LOOP_CONTROL,
|
||||
loop_get_fd,
|
||||
loop_add_hooks,
|
||||
loop_enter,
|
||||
|
|
@ -609,7 +609,7 @@ static const struct spa_loop_control impl_loop_control = {
|
|||
};
|
||||
|
||||
static const struct spa_loop_utils impl_loop_utils = {
|
||||
sizeof(struct spa_loop_utils),
|
||||
SPA_VERSION_LOOP_UTILS,
|
||||
loop_add_io,
|
||||
loop_update_io,
|
||||
loop_add_idle,
|
||||
|
|
@ -734,11 +734,12 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
static const struct spa_handle_factory loop_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
impl_init,
|
||||
impl_enum_interface_info,
|
||||
impl_enum_interface_info
|
||||
};
|
||||
|
||||
static void reg(void) __attribute__ ((constructor));
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ impl_type_map_get_size(const struct spa_type_map *map)
|
|||
}
|
||||
|
||||
static const struct spa_type_map impl_type_map = {
|
||||
sizeof(struct spa_type_map),
|
||||
SPA_VERSION_TYPE_MAP,
|
||||
NULL,
|
||||
impl_type_map_get_id,
|
||||
impl_type_map_get_type,
|
||||
|
|
@ -208,6 +208,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
static const struct spa_handle_factory type_map_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -91,8 +91,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -183,7 +182,7 @@ static int impl_node_set_props(struct spa_node *node, const struct spa_props *pr
|
|||
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.need_input || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->need_input) || this->props.live) {
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
|
|
@ -205,7 +204,7 @@ static inline void read_timer(struct impl *this)
|
|||
{
|
||||
uint64_t expirations;
|
||||
|
||||
if (this->callbacks.need_input || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->need_input) || this->props.live) {
|
||||
if (read(this->timer_source.fd, &expirations, sizeof(uint64_t)) < sizeof(uint64_t))
|
||||
perror("read timerfd");
|
||||
}
|
||||
|
|
@ -225,8 +224,8 @@ 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);
|
||||
if (this->callbacks->need_input)
|
||||
this->callbacks->need_input(this->callbacks, &this->node);
|
||||
}
|
||||
if (spa_list_is_empty(&this->ready)) {
|
||||
spa_log_error(this->log, NAME " %p: no buffers", this);
|
||||
|
|
@ -321,9 +320,7 @@ 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,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -331,12 +328,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks->need_input != NULL) {
|
||||
if (this->data_loop == NULL && callbacks != NULL && callbacks->need_input != NULL) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -675,7 +671,7 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
input->buffer_id = SPA_ID_INVALID;
|
||||
input->status = SPA_RESULT_OK;
|
||||
}
|
||||
if (this->callbacks.need_input == NULL)
|
||||
if (this->callbacks == NULL || this->callbacks->need_input == NULL)
|
||||
return consume_buffer(this);
|
||||
else
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -687,7 +683,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -748,7 +744,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -874,6 +870,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_fakesink_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -199,7 +198,7 @@ static int fill_buffer(struct impl *this, struct buffer *b)
|
|||
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
|
|
@ -221,7 +220,7 @@ static inline void read_timer(struct impl *this)
|
|||
{
|
||||
uint64_t expirations;
|
||||
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (read(this->timer_source.fd, &expirations, sizeof(uint64_t)) < sizeof(uint64_t))
|
||||
perror("read timerfd");
|
||||
}
|
||||
|
|
@ -278,8 +277,8 @@ static void on_output(struct spa_source *source)
|
|||
|
||||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER && this->callbacks.have_output)
|
||||
this->callbacks.have_output(&this->node, this->user_data);
|
||||
if (res == SPA_RESULT_HAVE_BUFFER && this->callbacks && this->callbacks->have_output)
|
||||
this->callbacks->have_output(this->callbacks, &this->node);
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
|
|
@ -333,9 +332,7 @@ 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,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -343,12 +340,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks->have_output != NULL) {
|
||||
if (this->data_loop == NULL && (callbacks != NULL && callbacks->have_output != NULL)) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -717,14 +713,15 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
this->io->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
if (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;
|
||||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -785,7 +782,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -911,6 +908,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_fakesrc_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -60,8 +60,7 @@ struct impl {
|
|||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
|
||||
struct spa_monitor_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_monitor_callbacks *callbacks;
|
||||
|
||||
struct udev *udev;
|
||||
struct udev_monitor *umonitor;
|
||||
|
|
@ -231,13 +230,12 @@ 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, &this->monitor, event);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
size_t callbacks_size, void *user_data)
|
||||
const struct spa_monitor_callbacks *callbacks)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
|
@ -246,10 +244,8 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
if (callbacks) {
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
return res;
|
||||
|
||||
|
|
@ -268,7 +264,6 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
|
||||
spa_loop_add_source(this->main_loop, &this->source);
|
||||
} else {
|
||||
spa_zero(this->callbacks);
|
||||
spa_loop_remove_source(this->main_loop, &this->source);
|
||||
}
|
||||
|
||||
|
|
@ -325,8 +320,8 @@ impl_monitor_enum_items(struct spa_monitor *monitor, struct spa_monitor_item **i
|
|||
}
|
||||
|
||||
static const struct spa_monitor impl_monitor = {
|
||||
SPA_VERSION_MONITOR,
|
||||
NULL,
|
||||
sizeof(struct spa_monitor),
|
||||
impl_monitor_set_callbacks,
|
||||
impl_monitor_enum_items,
|
||||
};
|
||||
|
|
@ -413,6 +408,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_v4l2_monitor_factory = {
|
||||
SPA_VERSION_MONITOR,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -157,8 +157,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct port out_ports[1];
|
||||
};
|
||||
|
|
@ -237,7 +236,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, &this->node, seq, res);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -276,7 +275,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, &this->node, seq, res);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -355,9 +354,7 @@ 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,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -365,8 +362,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 = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -821,7 +817,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -880,7 +876,7 @@ static int impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -991,6 +987,7 @@ static int impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_v4l2_source_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -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, &this->node);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,8 +111,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
|
@ -222,7 +221,7 @@ static int fill_buffer(struct impl *this, struct buffer *b)
|
|||
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
|
|
@ -244,7 +243,7 @@ static void read_timer(struct impl *this)
|
|||
{
|
||||
uint64_t expirations;
|
||||
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if ((this->callbacks && this->callbacks->have_output) || this->props.live) {
|
||||
if (read(this->timer_source.fd, &expirations, sizeof(uint64_t)) < sizeof(uint64_t))
|
||||
perror("read timerfd");
|
||||
}
|
||||
|
|
@ -301,7 +300,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, &this->node);
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
|
|
@ -355,9 +354,7 @@ 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,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -365,12 +362,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks->have_output != NULL) {
|
||||
if (this->data_loop == NULL && callbacks != NULL && callbacks->have_output != NULL) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
this->callbacks = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -810,14 +806,15 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
this->io->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
if (!this->callbacks.have_output && (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;
|
||||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -878,7 +875,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
sizeof(struct spa_clock),
|
||||
SPA_VERSION_CLOCK,
|
||||
NULL,
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
impl_clock_get_props,
|
||||
|
|
@ -1004,6 +1001,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_videotestsrc_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
|
|
@ -108,8 +108,7 @@ struct impl {
|
|||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
|
||||
uint8_t format_buffer[1024];
|
||||
struct spa_audio_info current_format;
|
||||
|
|
@ -208,8 +207,7 @@ 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,
|
||||
size_t callbacks_size, void *user_data)
|
||||
const struct spa_node_callbacks *callbacks)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -217,8 +215,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 = callbacks;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -647,8 +644,8 @@ 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.reuse_buffer)
|
||||
this->callbacks.reuse_buffer(&this->node, 0, buffer->id, this->user_data);
|
||||
if (this->callbacks && this->callbacks->reuse_buffer)
|
||||
this->callbacks->reuse_buffer(this->callbacks, &this->node, 0, buffer->id);
|
||||
}
|
||||
|
||||
static void do_volume(struct impl *this, struct spa_buffer *dbuf, struct spa_buffer *sbuf)
|
||||
|
|
@ -765,7 +762,7 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
sizeof(struct spa_node),
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
impl_node_get_props,
|
||||
impl_node_set_props,
|
||||
|
|
@ -879,6 +876,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_volume_factory = {
|
||||
SPA_VERSION_HANDLE_FACTORY,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue