mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
Fix stream restart
Make sure we always send a clock update before sending a start command. Fix memory size. Follow the state of the node to do allocation Use the pinos node to control the state When doing STREAMOFF, all buffers will be dequeued. requeue them buffers for when we go to playing again.
This commit is contained in:
parent
e34ef88dac
commit
021eccb8ad
7 changed files with 107 additions and 63 deletions
|
|
@ -256,7 +256,6 @@ spa_proxy_node_send_command (SpaNode *node,
|
|||
|
||||
spa_control_clear (&control);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -703,6 +702,9 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
|
|||
if (!port->format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (port->n_buffers == n_buffers && port->buffers == buffers)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
spa_control_builder_init_into (&builder, buf, sizeof (buf), fds, sizeof (fds));
|
||||
|
||||
if (buffers == NULL || n_buffers == 0) {
|
||||
|
|
|
|||
|
|
@ -272,8 +272,12 @@ spa_v4l2_source_node_send_command (SpaNode *node,
|
|||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -592,8 +596,12 @@ spa_v4l2_source_node_port_alloc_buffers (SpaNode *node,
|
|||
|
||||
res = spa_v4l2_alloc_buffers (this, params, n_params, buffers, n_buffers);
|
||||
|
||||
if (state->have_buffers)
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
if (state->have_buffers) {
|
||||
if (state->started)
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
else
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -862,6 +862,13 @@ v4l2_on_fd_events (SpaPollNotifyData *data)
|
|||
SpaNodeEvent event;
|
||||
SpaNodeEventHaveOutput ho;
|
||||
|
||||
if (data->fds[0].revents & POLLERR) {
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (mmap_read (this) < 0)
|
||||
return 0;
|
||||
|
||||
|
|
@ -1171,22 +1178,31 @@ spa_v4l2_pause (SpaV4l2Source *this)
|
|||
SpaV4l2State *state = &this->state[0];
|
||||
enum v4l2_buf_type type;
|
||||
SpaNodeEvent event;
|
||||
int i;
|
||||
|
||||
if (!state->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
state->started = false;
|
||||
|
||||
event.type = SPA_NODE_EVENT_TYPE_REMOVE_POLL;
|
||||
event.data = &state->poll;
|
||||
event.size = sizeof (state->poll);
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
|
||||
state->started = false;
|
||||
|
||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
if (xioctl (state->fd, VIDIOC_STREAMOFF, &type) < 0) {
|
||||
perror ("VIDIOC_STREAMOFF");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
for (i = 0; i < state->reqbuf.count; i++) {
|
||||
V4l2Buffer *b;
|
||||
|
||||
b = &state->alloc_buffers[i];
|
||||
if (!b->outstanding)
|
||||
if (xioctl (state->fd, VIDIOC_QBUF, &b->v4l2_buffer) < 0)
|
||||
perror ("VIDIOC_QBUF");
|
||||
}
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue