v4l2: recycle buffers when no io area

When there is no io area to place our buffers, recycle them immediately.
Otherwise we would run out of buffers and stall.
This commit is contained in:
Wim Taymans 2022-10-24 13:16:08 +02:00
parent a57602cc4d
commit df094b3649

View file

@ -41,7 +41,6 @@ static int xioctl(int fd, int request, void *arg)
return err; return err;
} }
int spa_v4l2_open(struct spa_v4l2_device *dev, const char *path) int spa_v4l2_open(struct spa_v4l2_device *dev, const char *path)
{ {
struct stat st; struct stat st;
@ -1305,7 +1304,13 @@ static void v4l2_on_fd_events(struct spa_source *source)
return; return;
io = port->io; io = port->io;
if (io != NULL && io->status != SPA_STATUS_HAVE_DATA) { if (io == NULL) {
b = spa_list_first(&port->queue, struct buffer, link);
spa_list_remove(&b->link);
SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUTSTANDING);
spa_v4l2_buffer_recycle(this, b->id);
}
else if (io->status != SPA_STATUS_HAVE_DATA) {
if (io->buffer_id < port->n_buffers) if (io->buffer_id < port->n_buffers)
spa_v4l2_buffer_recycle(this, io->buffer_id); spa_v4l2_buffer_recycle(this, io->buffer_id);