node: remove port_alloc_buffers

Remove the now obsolete port_alloc_buffer, rework to use the
port_use_buffers with the ALLOC flag.
This commit is contained in:
Wim Taymans 2019-07-25 14:08:43 +02:00
parent 2f3351ef9b
commit deb6c52f76
21 changed files with 60 additions and 462 deletions

View file

@ -699,37 +699,14 @@ static int impl_node_port_use_buffers(void *object,
if ((res = spa_v4l2_clear_buffers(this)) < 0)
return res;
}
if (buffers != NULL) {
if ((res = spa_v4l2_use_buffers(this, buffers, n_buffers)) < 0)
return res;
if (buffers == NULL)
return 0;
if (flags & SPA_NODE_BUFFERS_FLAG_ALLOC) {
res = spa_v4l2_alloc_buffers(this, buffers, n_buffers);
} else {
res = spa_v4l2_use_buffers(this, buffers, n_buffers);
}
return 0;
}
static int
impl_node_port_alloc_buffers(void *object,
enum spa_direction direction,
uint32_t port_id,
struct spa_pod **params,
uint32_t n_params,
struct spa_buffer **buffers,
uint32_t *n_buffers)
{
struct impl *this = object;
struct port *port;
int res;
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(buffers != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
port = GET_PORT(this, direction, port_id);
if (!port->have_format)
return -EIO;
res = spa_v4l2_alloc_buffers(this, params, n_params, buffers, n_buffers);
return res;
}
@ -903,7 +880,6 @@ static const struct spa_node_methods impl_node = {
.port_enum_params = impl_node_port_enum_params,
.port_set_param = impl_node_port_set_param,
.port_use_buffers = impl_node_port_use_buffers,
.port_alloc_buffers = impl_node_port_alloc_buffers,
.port_set_io = impl_node_port_set_io,
.port_reuse_buffer = impl_node_port_reuse_buffer,
.process = impl_node_process,

View file

@ -1338,10 +1338,8 @@ static int spa_v4l2_use_buffers(struct impl *this, struct spa_buffer **buffers,
static int
mmap_init(struct impl *this,
struct spa_pod **params,
uint32_t n_params,
struct spa_buffer **buffers,
uint32_t *n_buffers)
uint32_t n_buffers)
{
struct port *port = &this->out_ports[0];
struct spa_v4l2_device *dev = &port->dev;
@ -1353,7 +1351,7 @@ mmap_init(struct impl *this,
spa_zero(reqbuf);
reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
reqbuf.memory = port->memtype;
reqbuf.count = *n_buffers;
reqbuf.count = n_buffers;
if (xioctl(dev->fd, VIDIOC_REQBUFS, &reqbuf) < 0) {
spa_log_error(this->log, "VIDIOC_REQBUFS: %m");
@ -1361,7 +1359,7 @@ mmap_init(struct impl *this,
}
spa_log_info(this->log, "v4l2: got %d buffers", reqbuf.count);
*n_buffers = reqbuf.count;
n_buffers = reqbuf.count;
if (reqbuf.count < 2) {
spa_log_error(this->log, "v4l2: can't allocate enough buffers");
@ -1454,10 +1452,8 @@ static int read_init(struct impl *this)
static int
spa_v4l2_alloc_buffers(struct impl *this,
struct spa_pod **params,
uint32_t n_params,
struct spa_buffer **buffers,
uint32_t *n_buffers)
uint32_t n_buffers)
{
int res;
struct port *port = &this->out_ports[0];
@ -1467,7 +1463,7 @@ spa_v4l2_alloc_buffers(struct impl *this,
return -EIO;
if (dev->cap.capabilities & V4L2_CAP_STREAMING) {
if ((res = mmap_init(this, params, n_params, buffers, n_buffers)) < 0)
if ((res = mmap_init(this, buffers, n_buffers)) < 0)
if ((res = userptr_init(this)) < 0)
return res;
} else if (dev->cap.capabilities & V4L2_CAP_READWRITE) {