mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-09-20 00:11:31 +00:00
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:
parent
2f3351ef9b
commit
deb6c52f76
|
@ -406,9 +406,10 @@ static int negotiate_formats(struct data *data)
|
|||
return -1;
|
||||
}
|
||||
n_buffers = MAX_BUFFERS;
|
||||
if ((res =
|
||||
spa_node_port_alloc_buffers(data->source, SPA_DIRECTION_OUTPUT, 0, NULL, 0,
|
||||
data->bp, &n_buffers)) < 0) {
|
||||
if ((res = spa_node_port_use_buffers(data->source,
|
||||
SPA_DIRECTION_OUTPUT, 0,
|
||||
SPA_NODE_BUFFERS_FLAG_ALLOC,
|
||||
data->bp, n_buffers)) < 0) {
|
||||
printf("can't allocate buffers: %s\n", spa_strerror(res));
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -512,6 +512,10 @@ struct spa_node_methods {
|
|||
/**
|
||||
* Tell the port to use the given buffers
|
||||
*
|
||||
* When \a flags contains SPA_NODE_BUFFERS_FLAG_ALLOC, the data
|
||||
* in the buffers should point to an array of at least 1 data entry
|
||||
* with the desired supported type that will be filled by this function.
|
||||
*
|
||||
* The port should also have a spa_io_buffers io area configured to exchange
|
||||
* the buffers with the port.
|
||||
*
|
||||
|
@ -551,45 +555,6 @@ struct spa_node_methods {
|
|||
uint32_t flags,
|
||||
struct spa_buffer **buffers,
|
||||
uint32_t n_buffers);
|
||||
/**
|
||||
* Tell the port to allocate memory for \a buffers.
|
||||
*
|
||||
* The port should also have a spa_io_buffers io area configured to exchange
|
||||
* the buffers with the port.
|
||||
*
|
||||
* \a buffers should contain an array of pointers to buffers. The data
|
||||
* in the buffers should point to an array of at least 1 data entry
|
||||
* with a 0 type that will be filled by this function.
|
||||
*
|
||||
* For input ports, the buffers will be dequeued and ready to be filled
|
||||
* and pushed into the port. A callback should be configured so that you can
|
||||
* know when a buffer can be reused.
|
||||
*
|
||||
* For output ports, the buffers remain queued. port_reuse_buffer() should
|
||||
* be called when a buffer can be reused.
|
||||
*
|
||||
* Once the port has allocated buffers, the memory of the buffers can be
|
||||
* released again by calling struct port_use_buffers with NULL.
|
||||
*
|
||||
* This function must be called from the main thread.
|
||||
*
|
||||
* \param node a spa_node
|
||||
* \param direction a spa_direction
|
||||
* \param port_id a port id
|
||||
* \param params allocation parameters
|
||||
* \param n_params number of elements in \a params
|
||||
* \param buffers an array of buffer pointers
|
||||
* \param n_buffers number of elements in \a buffers
|
||||
* \return 0 on success
|
||||
* -EBUSY when the node already has allocated buffers.
|
||||
*/
|
||||
int (*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);
|
||||
|
||||
/**
|
||||
* Configure the given memory area with \a id on \a port_id. This
|
||||
|
@ -670,7 +635,6 @@ struct spa_node_methods {
|
|||
#define spa_node_port_enum_params(n,...) spa_node_method(n, port_enum_params, 0, __VA_ARGS__)
|
||||
#define spa_node_port_set_param(n,...) spa_node_method(n, port_set_param, 0, __VA_ARGS__)
|
||||
#define spa_node_port_use_buffers(n,...) spa_node_method(n, port_use_buffers, 0, __VA_ARGS__)
|
||||
#define spa_node_port_alloc_buffers(n,...) spa_node_method(n, port_alloc_buffers, 0, __VA_ARGS__)
|
||||
#define spa_node_port_set_io(n,...) spa_node_method(n, port_set_io, 0, __VA_ARGS__)
|
||||
|
||||
#define spa_node_port_reuse_buffer(n,...) spa_node_method(n, port_reuse_buffer, 0, __VA_ARGS__)
|
||||
|
|
|
@ -553,28 +553,6 @@ impl_node_port_use_buffers(void *object,
|
|||
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 state *this = object;
|
||||
|
||||
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);
|
||||
|
||||
if (!this->have_format)
|
||||
return -EIO;
|
||||
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction,
|
||||
|
@ -661,7 +639,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,
|
||||
|
|
|
@ -564,28 +564,6 @@ impl_node_port_use_buffers(void *object,
|
|||
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 state *this = object;
|
||||
|
||||
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);
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return -EIO;
|
||||
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction,
|
||||
|
@ -686,7 +664,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,
|
||||
|
|
|
@ -640,34 +640,18 @@ static int negotiate_buffers(struct impl *this)
|
|||
return -errno;
|
||||
this->n_buffers = buffers;
|
||||
|
||||
if (conv_alloc) {
|
||||
if ((res = spa_node_port_alloc_buffers(this->convert,
|
||||
SPA_DIRECTION_REVERSE(this->direction), 0,
|
||||
NULL, 0,
|
||||
this->buffers, &this->n_buffers)) < 0)
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
if ((res = spa_node_port_use_buffers(this->convert,
|
||||
SPA_DIRECTION_REVERSE(this->direction), 0, 0,
|
||||
this->buffers, this->n_buffers)) < 0)
|
||||
return res;
|
||||
}
|
||||
if (slave_alloc) {
|
||||
if ((res = spa_node_port_alloc_buffers(this->slave,
|
||||
this->direction, 0,
|
||||
NULL, 0,
|
||||
this->buffers, &this->n_buffers)) < 0) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((res = spa_node_port_use_buffers(this->slave,
|
||||
this->direction, 0, 0,
|
||||
this->buffers, this->n_buffers)) < 0) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
if ((res = spa_node_port_use_buffers(this->convert,
|
||||
SPA_DIRECTION_REVERSE(this->direction), 0,
|
||||
conv_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
|
||||
this->buffers, this->n_buffers)) < 0)
|
||||
return res;
|
||||
|
||||
if ((res = spa_node_port_use_buffers(this->slave,
|
||||
this->direction, 0,
|
||||
slave_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
|
||||
this->buffers, this->n_buffers)) < 0)
|
||||
return res;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -757,26 +741,6 @@ impl_node_port_use_buffers(void *object,
|
|||
return res;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
spa_return_val_if_fail(this != NULL, -EINVAL);
|
||||
|
||||
if (direction != this->direction)
|
||||
port_id++;
|
||||
|
||||
return spa_node_port_alloc_buffers(this->target, direction, port_id,
|
||||
params, n_params, buffers, n_buffers);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_reuse_buffer(void *object, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
|
@ -826,7 +790,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,
|
||||
|
|
|
@ -335,32 +335,18 @@ static int negotiate_link_buffers(struct impl *this, struct link *link)
|
|||
|
||||
link->n_buffers = buffers;
|
||||
|
||||
if (out_alloc) {
|
||||
if ((res = spa_node_port_alloc_buffers(link->out_node,
|
||||
SPA_DIRECTION_OUTPUT, link->out_port,
|
||||
NULL, 0,
|
||||
link->buffers, &link->n_buffers)) < 0)
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
if ((res = spa_node_port_use_buffers(link->out_node,
|
||||
SPA_DIRECTION_OUTPUT, link->out_port, 0,
|
||||
link->buffers, link->n_buffers)) < 0)
|
||||
return res;
|
||||
}
|
||||
if (in_alloc) {
|
||||
if ((res = spa_node_port_alloc_buffers(link->in_node,
|
||||
SPA_DIRECTION_INPUT, link->in_port,
|
||||
NULL, 0,
|
||||
link->buffers, &link->n_buffers)) < 0)
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
if ((res = spa_node_port_use_buffers(link->in_node,
|
||||
SPA_DIRECTION_INPUT, link->in_port, 0,
|
||||
link->buffers, link->n_buffers)) < 0)
|
||||
return res;
|
||||
}
|
||||
if ((res = spa_node_port_use_buffers(link->out_node,
|
||||
SPA_DIRECTION_OUTPUT, link->out_port,
|
||||
out_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
|
||||
link->buffers, link->n_buffers)) < 0)
|
||||
return res;
|
||||
|
||||
if ((res = spa_node_port_use_buffers(link->in_node,
|
||||
SPA_DIRECTION_INPUT, link->in_port,
|
||||
in_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
|
||||
link->buffers, link->n_buffers)) < 0)
|
||||
return res;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -826,29 +812,6 @@ impl_node_port_use_buffers(void *object,
|
|||
return res;
|
||||
}
|
||||
|
||||
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 spa_node *target;
|
||||
|
||||
spa_return_val_if_fail(this != NULL, -EINVAL);
|
||||
|
||||
if (this->mode == MODE_MERGE && port_id > 0 && direction == SPA_DIRECTION_OUTPUT)
|
||||
target = this->fmt[SPA_DIRECTION_INPUT];
|
||||
else
|
||||
target = this->fmt[direction];
|
||||
|
||||
return spa_node_port_alloc_buffers(target, direction, port_id,
|
||||
params, n_params, buffers, n_buffers);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
@ -948,7 +911,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,
|
||||
|
|
|
@ -751,18 +751,6 @@ impl_node_port_use_buffers(void *object,
|
|||
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)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
@ -937,7 +925,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,
|
||||
|
|
|
@ -715,18 +715,6 @@ impl_node_port_use_buffers(void *object,
|
|||
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)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
@ -897,7 +885,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,
|
||||
|
|
|
@ -798,18 +798,6 @@ impl_node_port_use_buffers(void *object,
|
|||
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)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
@ -1007,7 +995,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,
|
||||
|
|
|
@ -627,18 +627,6 @@ impl_node_port_use_buffers(void *object,
|
|||
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)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
@ -846,7 +834,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,
|
||||
|
|
|
@ -763,18 +763,6 @@ impl_node_port_use_buffers(void *object,
|
|||
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)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
@ -928,7 +916,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,
|
||||
|
|
|
@ -1250,29 +1250,6 @@ impl_node_port_use_buffers(void *object,
|
|||
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;
|
||||
|
||||
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 = &this->port;
|
||||
|
||||
if (!port->have_format)
|
||||
return -EIO;
|
||||
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction,
|
||||
|
@ -1361,7 +1338,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,
|
||||
|
|
|
@ -902,30 +902,6 @@ impl_node_port_use_buffers(void *object,
|
|||
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;
|
||||
|
||||
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 = &this->port;
|
||||
|
||||
if (!port->have_format)
|
||||
return -EIO;
|
||||
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction,
|
||||
|
@ -1038,7 +1014,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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -643,33 +643,17 @@ static int negotiate_buffers(struct impl *this)
|
|||
return -errno;
|
||||
this->n_buffers = buffers;
|
||||
|
||||
if (conv_alloc) {
|
||||
if ((res = spa_node_port_alloc_buffers(this->convert,
|
||||
SPA_DIRECTION_REVERSE(this->direction), 0,
|
||||
NULL, 0,
|
||||
this->buffers, &this->n_buffers)) < 0)
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
if ((res = spa_node_port_use_buffers(this->convert,
|
||||
SPA_DIRECTION_REVERSE(this->direction), 0, 0,
|
||||
this->buffers, this->n_buffers)) < 0)
|
||||
return res;
|
||||
}
|
||||
if (slave_alloc) {
|
||||
if ((res = spa_node_port_alloc_buffers(this->slave,
|
||||
this->direction, 0,
|
||||
NULL, 0,
|
||||
this->buffers, &this->n_buffers)) < 0) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((res = spa_node_port_use_buffers(this->slave, 0,
|
||||
this->direction, 0,
|
||||
this->buffers, this->n_buffers)) < 0) {
|
||||
return res;
|
||||
}
|
||||
if ((res = spa_node_port_use_buffers(this->convert,
|
||||
SPA_DIRECTION_REVERSE(this->direction), 0,
|
||||
conv_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
|
||||
this->buffers, this->n_buffers)) < 0)
|
||||
return res;
|
||||
|
||||
if ((res = spa_node_port_use_buffers(this->slave,
|
||||
this->direction, 0,
|
||||
slave_alloc ? SPA_NODE_BUFFERS_FLAG_ALLOC : 0,
|
||||
this->buffers, this->n_buffers)) < 0) {
|
||||
return res;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -760,26 +744,6 @@ impl_node_port_use_buffers(void *object,
|
|||
return res;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
spa_return_val_if_fail(this != NULL, -EINVAL);
|
||||
|
||||
if (direction != this->direction)
|
||||
port_id++;
|
||||
|
||||
return spa_node_port_alloc_buffers(this->target, direction, port_id,
|
||||
params, n_params, buffers, n_buffers);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_reuse_buffer(void *object, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
|
@ -829,7 +793,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,
|
||||
|
|
|
@ -594,18 +594,6 @@ impl_node_port_use_buffers(void *object,
|
|||
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)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
@ -816,7 +804,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,
|
||||
|
|
|
@ -594,18 +594,6 @@ impl_node_port_use_buffers(void *object,
|
|||
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)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io(void *object,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
@ -813,7 +801,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,
|
||||
|
|
|
@ -837,31 +837,6 @@ impl_node_port_use_buffers(void *object,
|
|||
SPA_ID_INVALID, flags, buffers, n_buffers);
|
||||
}
|
||||
|
||||
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 node *this = object;
|
||||
struct port *port;
|
||||
|
||||
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;
|
||||
|
||||
spa_log_warn(this->log, "not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_reuse_buffer(void *object, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
|
@ -1043,7 +1018,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,
|
||||
|
@ -1358,18 +1332,6 @@ impl_mix_port_use_buffers(void *object,
|
|||
return do_port_use_buffers(impl, direction, port->id, mix_id, flags, buffers, n_buffers);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_mix_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)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_mix_port_set_io(void *object,
|
||||
enum spa_direction direction, uint32_t mix_id,
|
||||
uint32_t id, void *data, size_t size)
|
||||
|
@ -1414,7 +1376,6 @@ static const struct spa_node_methods impl_port_mix = {
|
|||
.add_port = impl_mix_add_port,
|
||||
.remove_port = impl_mix_remove_port,
|
||||
.port_use_buffers = impl_mix_port_use_buffers,
|
||||
.port_alloc_buffers = impl_mix_port_alloc_buffers,
|
||||
.port_set_io = impl_mix_port_set_io,
|
||||
.port_reuse_buffer = impl_mix_port_reuse_buffer,
|
||||
.process = impl_mix_process,
|
||||
|
|
|
@ -1092,15 +1092,16 @@ int pw_port_alloc_buffers(struct pw_port *port,
|
|||
if (port->state < PW_PORT_STATE_READY)
|
||||
return -EIO;
|
||||
|
||||
if ((res = spa_node_port_alloc_buffers(node->node, port->direction, port->port_id,
|
||||
params, n_params,
|
||||
buffers, n_buffers)) < 0) {
|
||||
if ((res = spa_node_port_use_buffers(node->node,
|
||||
port->direction, port->port_id,
|
||||
SPA_NODE_BUFFERS_FLAG_ALLOC,
|
||||
buffers, *n_buffers)) < 0) {
|
||||
pw_log_error("port %p: %d alloc failed: %d (%s)", port, port->port_id,
|
||||
res, spa_strerror(res));
|
||||
}
|
||||
|
||||
if (res >= 0) {
|
||||
res = pw_port_call_alloc_buffers(port, params, n_params, buffers, n_buffers);
|
||||
res = pw_port_call_use_buffers(port, SPA_NODE_BUFFERS_FLAG_ALLOC, buffers, *n_buffers);
|
||||
if (res < 0) {
|
||||
pw_log_error("port %p: %d implementation alloc failed: %d (%s)",
|
||||
port, port->port_id, res, spa_strerror(res));
|
||||
|
|
|
@ -477,8 +477,6 @@ struct pw_port_implementation {
|
|||
int (*init_mix) (void *data, struct pw_port_mix *mix);
|
||||
int (*release_mix) (void *data, struct pw_port_mix *mix);
|
||||
int (*use_buffers) (void *data, uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers);
|
||||
int (*alloc_buffers) (void *data, struct spa_pod **params, uint32_t n_params,
|
||||
struct spa_buffer **buffers, uint32_t *n_buffers);
|
||||
};
|
||||
|
||||
#define pw_port_call(p,m,v,...) \
|
||||
|
@ -493,7 +491,6 @@ struct pw_port_implementation {
|
|||
#define pw_port_call_init_mix(p,m) pw_port_call(p,init_mix,0,m)
|
||||
#define pw_port_call_release_mix(p,m) pw_port_call(p,release_mix,0,m)
|
||||
#define pw_port_call_use_buffers(p,f,b,n) pw_port_call(p,use_buffers,0,f,b,n)
|
||||
#define pw_port_call_alloc_buffers(p,pp,np,b,n) pw_port_call(p,alloc_buffers,0,pp,np,b,n)
|
||||
|
||||
#define pw_port_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_port_events, m, v, ##__VA_ARGS__)
|
||||
#define pw_port_emit_destroy(p) pw_port_emit(p, destroy, 0)
|
||||
|
|
Loading…
Reference in a new issue