node: improve callbacks

Make separate callbacks for events and RT notifications.
This commit is contained in:
Wim Taymans 2017-05-11 10:29:20 +02:00
parent fb0919b8b7
commit 3b33e3d362
32 changed files with 557 additions and 481 deletions

View file

@ -161,7 +161,7 @@ struct _SpaV4l2Source {
uint8_t props_buffer[512];
SpaV4l2SourceProps props;
SpaEventNodeCallback event_cb;
SpaNodeCallbacks callbacks;
void *user_data;
SpaV4l2State state[1];
@ -244,7 +244,7 @@ do_pause_done (SpaLoop *loop,
if (SPA_RESULT_IS_OK (ac->body.res.value))
ac->body.res.value = spa_v4l2_stream_off (this);
this->event_cb (&this->node, (SpaEvent *)ac, this->user_data);
this->callbacks.event (&this->node, (SpaEvent *)ac, this->user_data);
return SPA_RESULT_OK;
}
@ -290,7 +290,7 @@ do_start_done (SpaLoop *loop,
SpaV4l2Source *this = user_data;
SpaEventNodeAsyncComplete *ac = data;
this->event_cb (&this->node, (SpaEvent *)ac, this->user_data);
this->callbacks.event (&this->node, (SpaEvent *)ac, this->user_data);
return SPA_RESULT_OK;
}
@ -381,9 +381,10 @@ spa_v4l2_source_node_send_command (SpaNode *node,
}
static SpaResult
spa_v4l2_source_node_set_event_callback (SpaNode *node,
SpaEventNodeCallback event,
void *user_data)
spa_v4l2_source_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaV4l2Source *this;
@ -391,7 +392,7 @@ spa_v4l2_source_node_set_event_callback (SpaNode *node,
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
this->event_cb = event;
this->callbacks = *callbacks;
this->user_data = user_data;
return SPA_RESULT_OK;
@ -474,11 +475,11 @@ spa_v4l2_source_node_port_enum_formats (SpaNode *node,
}
static SpaResult
spa_v4l2_source_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
spa_v4l2_source_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
{
SpaV4l2Source *this;
SpaV4l2State *state;
@ -823,7 +824,7 @@ static const SpaNode v4l2source_node = {
spa_v4l2_source_node_get_props,
spa_v4l2_source_node_set_props,
spa_v4l2_source_node_send_command,
spa_v4l2_source_node_set_event_callback,
spa_v4l2_source_node_set_callbacks,
spa_v4l2_source_node_get_n_ports,
spa_v4l2_source_node_get_port_ids,
spa_v4l2_source_node_add_port,

View file

@ -972,15 +972,11 @@ mmap_read (SpaV4l2Source *this)
d[0].chunk->size = buf.bytesused;
d[0].chunk->stride = state->fmt.fmt.pix.bytesperline;
{
SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
b->outstanding = true;
io->buffer_id = b->outbuf->id;
io->status = SPA_RESULT_HAVE_BUFFER;
this->callbacks.have_output (&this->node, this->user_data);
b->outstanding = true;
io->buffer_id = b->outbuf->id;
io->status = SPA_RESULT_HAVE_BUFFER;
this->event_cb (&this->node, &event, this->user_data);
}
return SPA_RESULT_OK;
}