Remove unused events, drained and marker can be done with
ASYNC_COMPLETED messages
Handle result of idle callback to disable the poll item
Identify poll items with a unique id.
Remove set_state vfunc
push_event -> send_command, commands are to do something, events are the
result of something.
Add poll item in v4l2 as soon as we have the fd but disable the item
until streaming starts.
This commit is contained in:
Wim Taymans 2016-10-21 14:57:01 +02:00
parent 9b2b4b9b5c
commit 1bd751372e
21 changed files with 188 additions and 190 deletions

View file

@ -530,10 +530,10 @@ spa_alsa_sink_node_port_reuse_buffer (SpaNode *node,
}
static SpaResult
spa_alsa_sink_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
spa_alsa_sink_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -563,7 +563,7 @@ static const SpaNode alsasink_node = {
spa_alsa_sink_node_port_push_input,
spa_alsa_sink_node_port_pull_output,
spa_alsa_sink_node_port_reuse_buffer,
spa_alsa_sink_node_port_push_event,
spa_alsa_sink_node_port_send_command,
};
static SpaResult

View file

@ -634,10 +634,10 @@ spa_alsa_source_node_port_reuse_buffer (SpaNode *node,
}
static SpaResult
spa_alsa_source_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
spa_alsa_source_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -666,7 +666,7 @@ static const SpaNode alsasource_node = {
spa_alsa_source_node_port_push_input,
spa_alsa_source_node_port_pull_output,
spa_alsa_source_node_port_reuse_buffer,
spa_alsa_source_node_port_push_event,
spa_alsa_source_node_port_send_command,
};
static SpaResult

View file

@ -722,10 +722,10 @@ spa_audiomixer_node_port_reuse_buffer (SpaNode *node,
}
static SpaResult
spa_audiomixer_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
spa_audiomixer_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -754,7 +754,7 @@ static const SpaNode audiomixer_node = {
spa_audiomixer_node_port_push_input,
spa_audiomixer_node_port_pull_output,
spa_audiomixer_node_port_reuse_buffer,
spa_audiomixer_node_port_push_event,
spa_audiomixer_node_port_send_command,
};
static SpaResult

View file

@ -859,10 +859,10 @@ spa_audiotestsrc_node_port_reuse_buffer (SpaNode *node,
}
static SpaResult
spa_audiotestsrc_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
spa_audiotestsrc_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -891,7 +891,7 @@ static const SpaNode audiotestsrc_node = {
spa_audiotestsrc_node_port_push_input,
spa_audiotestsrc_node_port_pull_output,
spa_audiotestsrc_node_port_reuse_buffer,
spa_audiotestsrc_node_port_push_event,
spa_audiotestsrc_node_port_send_command,
};
static SpaResult

View file

@ -498,10 +498,10 @@ spa_ffmpeg_dec_node_port_reuse_buffer (SpaNode *node,
}
static SpaResult
spa_ffmpeg_dec_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
spa_ffmpeg_dec_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -531,7 +531,7 @@ static const SpaNode ffmpeg_dec_node = {
spa_ffmpeg_dec_node_port_push_input,
spa_ffmpeg_dec_node_port_pull_output,
spa_ffmpeg_dec_node_port_reuse_buffer,
spa_ffmpeg_dec_node_port_push_event,
spa_ffmpeg_dec_node_port_send_command,
};
static SpaResult

View file

@ -508,10 +508,10 @@ spa_ffmpeg_enc_node_port_reuse_buffer (SpaNode *node,
}
static SpaResult
spa_ffmpeg_enc_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
spa_ffmpeg_enc_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -540,7 +540,7 @@ static const SpaNode ffmpeg_enc_node = {
spa_ffmpeg_enc_node_port_push_input,
spa_ffmpeg_enc_node_port_pull_output,
spa_ffmpeg_enc_node_port_reuse_buffer,
spa_ffmpeg_enc_node_port_push_event,
spa_ffmpeg_enc_node_port_send_command,
};
static SpaResult

View file

@ -226,7 +226,6 @@ spa_v4l2_source_node_send_command (SpaNode *node,
SpaNodeCommand *command)
{
SpaV4l2Source *this;
SpaResult res;
if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
@ -247,10 +246,7 @@ spa_v4l2_source_node_send_command (SpaNode *node,
if (state->n_buffers == 0)
return SPA_RESULT_NO_BUFFERS;
if ((res = spa_v4l2_start (this)) < 0)
return res;
break;
return spa_v4l2_start (this);
}
case SPA_NODE_COMMAND_PAUSE:
{
@ -262,12 +258,8 @@ spa_v4l2_source_node_send_command (SpaNode *node,
if (state->n_buffers == 0)
return SPA_RESULT_NO_BUFFERS;
if ((res = spa_v4l2_pause (this)) < 0)
return res;
break;
return spa_v4l2_pause (this);
}
case SPA_NODE_COMMAND_FLUSH:
case SPA_NODE_COMMAND_DRAIN:
case SPA_NODE_COMMAND_MARKER:
@ -714,15 +706,14 @@ spa_v4l2_source_node_port_reuse_buffer (SpaNode *node,
}
static SpaResult
spa_v4l2_source_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
spa_v4l2_source_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static const SpaNode v4l2source_node = {
sizeof (SpaNode),
NULL,
@ -747,7 +738,7 @@ static const SpaNode v4l2source_node = {
spa_v4l2_source_node_port_push_input,
spa_v4l2_source_node_port_pull_output,
spa_v4l2_source_node_port_reuse_buffer,
spa_v4l2_source_node_port_push_event,
spa_v4l2_source_node_port_send_command,
};
static SpaResult

View file

@ -9,6 +9,8 @@
#define CLEAR(x) memset(&(x), 0, sizeof(x))
static int v4l2_on_fd_events (SpaPollNotifyData *data);
static int
xioctl (int fd, int request, void *arg)
{
@ -66,6 +68,21 @@ spa_v4l2_open (SpaV4l2Source *this)
spa_log_error (state->log, "v4l2: %s is no video capture device\n", props->device);
return -1;
}
state->fds[0].fd = state->fd;
state->fds[0].events = POLLIN | POLLPRI | POLLERR;
state->fds[0].revents = 0;
state->poll.id = 0;
state->poll.enabled = false;
state->poll.fds = state->fds;
state->poll.n_fds = 1;
state->poll.idle_cb = NULL;
state->poll.before_cb = NULL;
state->poll.after_cb = v4l2_on_fd_events;
state->poll.user_data = this;
spa_poll_add_item (state->data_loop, &state->poll);
state->opened = true;
return 0;
@ -140,6 +157,9 @@ spa_v4l2_close (SpaV4l2Source *this)
return 0;
spa_log_info (state->log, "v4l2: close\n");
spa_poll_remove_item (state->data_loop, &state->poll);
if (close(state->fd))
perror ("close");
@ -1132,19 +1152,8 @@ spa_v4l2_start (SpaV4l2Source *this)
state->started = true;
update_state (this, SPA_NODE_STATE_STREAMING);
state->fds[0].fd = state->fd;
state->fds[0].events = POLLIN | POLLPRI | POLLERR;
state->fds[0].revents = 0;
state->poll.id = 0;
state->poll.enabled = true;
state->poll.fds = state->fds;
state->poll.n_fds = 1;
state->poll.idle_cb = NULL;
state->poll.before_cb = NULL;
state->poll.after_cb = v4l2_on_fd_events;
state->poll.user_data = this;
spa_poll_add_item (state->data_loop, &state->poll);
spa_poll_update_item (state->data_loop, &state->poll);
return SPA_RESULT_OK;
}
@ -1161,7 +1170,8 @@ spa_v4l2_pause (SpaV4l2Source *this)
state->started = false;
spa_poll_remove_item (state->data_loop, &state->poll);
state->poll.enabled = false;
spa_poll_update_item (state->data_loop, &state->poll);
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (xioctl (state->fd, VIDIOC_STREAMOFF, &type) < 0) {

View file

@ -807,10 +807,10 @@ spa_videotestsrc_node_port_reuse_buffer (SpaNode *node,
}
static SpaResult
spa_videotestsrc_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
spa_videotestsrc_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -839,7 +839,7 @@ static const SpaNode videotestsrc_node = {
spa_videotestsrc_node_port_push_input,
spa_videotestsrc_node_port_pull_output,
spa_videotestsrc_node_port_reuse_buffer,
spa_videotestsrc_node_port_push_event,
spa_videotestsrc_node_port_send_command,
};
static SpaResult

View file

@ -618,10 +618,10 @@ spa_volume_node_port_reuse_buffer (SpaNode *node,
}
static SpaResult
spa_volume_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
spa_volume_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -650,7 +650,7 @@ static const SpaNode volume_node = {
spa_volume_node_port_push_input,
spa_volume_node_port_pull_output,
spa_volume_node_port_reuse_buffer,
spa_volume_node_port_push_event,
spa_volume_node_port_send_command,
};
static SpaResult

View file

@ -500,10 +500,10 @@ spa_xv_sink_node_port_reuse_buffer (SpaNode *node,
}
static SpaResult
spa_xv_sink_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
spa_xv_sink_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeCommand *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -532,7 +532,7 @@ static const SpaNode xvsink_node = {
spa_xv_sink_node_port_push_input,
spa_xv_sink_node_port_pull_output,
spa_xv_sink_node_port_reuse_buffer,
spa_xv_sink_node_port_push_event,
spa_xv_sink_node_port_send_command,
};
static SpaResult