diff options
author | Wim Taymans <wtaymans@redhat.com> | 2019-07-25 14:08:43 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2019-07-25 14:08:43 +0200 |
commit | deb6c52f76bf7598437ac69a8b8392adcb8ecf0d (patch) | |
tree | 80501caaab67ad2ea48f45eaa7cab208e966d960 | |
parent | 2f3351ef9b73c715406e4ec9601fe0e34f96f4c8 (diff) |
node: remove port_alloc_buffers
Remove the now obsolete port_alloc_buffer, rework to use the
port_use_buffers with the ALLOC flag.
-rw-r--r-- | spa/examples/local-v4l2.c | 7 | ||||
-rw-r--r-- | spa/include/spa/node/node.h | 44 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-sink.c | 23 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-source.c | 23 | ||||
-rw-r--r-- | spa/plugins/audioconvert/audioadapter.c | 61 | ||||
-rw-r--r-- | spa/plugins/audioconvert/audioconvert.c | 62 | ||||
-rw-r--r-- | spa/plugins/audioconvert/channelmix.c | 13 | ||||
-rw-r--r-- | spa/plugins/audioconvert/fmtconvert.c | 13 | ||||
-rw-r--r-- | spa/plugins/audioconvert/merger.c | 13 | ||||
-rw-r--r-- | spa/plugins/audioconvert/resample.c | 13 | ||||
-rw-r--r-- | spa/plugins/audioconvert/splitter.c | 13 | ||||
-rw-r--r-- | spa/plugins/bluez5/a2dp-sink.c | 24 | ||||
-rw-r--r-- | spa/plugins/bluez5/a2dp-source.c | 25 | ||||
-rw-r--r-- | spa/plugins/v4l2/v4l2-source.c | 38 | ||||
-rw-r--r-- | spa/plugins/v4l2/v4l2-utils.c | 14 | ||||
-rw-r--r-- | spa/plugins/videoconvert/videoadapter.c | 59 | ||||
-rw-r--r-- | src/modules/module-adapter/floatmix.c | 13 | ||||
-rw-r--r-- | src/modules/module-audio-dsp/floatmix.c | 13 | ||||
-rw-r--r-- | src/modules/module-client-node/client-node.c | 39 | ||||
-rw-r--r-- | src/pipewire/port.c | 9 | ||||
-rw-r--r-- | src/pipewire/private.h | 3 |
21 files changed, 60 insertions, 462 deletions
diff --git a/spa/examples/local-v4l2.c b/spa/examples/local-v4l2.c index dab3f309..d123e2a1 100644 --- a/spa/examples/local-v4l2.c +++ b/spa/examples/local-v4l2.c @@ -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; } diff --git a/spa/include/spa/node/node.h b/spa/include/spa/node/node.h index 59eaf5ea..c642474f 100644 --- a/spa/include/spa/node/node.h +++ b/spa/include/spa/node/node.h @@ -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__) diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 2b739173..0db67712 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -554,28 +554,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t port_id, @@ -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, diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index 05aa81e2..1db77a81 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -565,28 +565,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t port_id, @@ -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, diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index d024e5a4..d7299d7a 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -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; } @@ -758,26 +742,6 @@ impl_node_port_use_buffers(void *object, } 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) { struct impl *this = object; @@ -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, diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index e99f47be..b928f044 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -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; } @@ -827,29 +813,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t id, void *data, size_t size) @@ -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, diff --git a/spa/plugins/audioconvert/channelmix.c b/spa/plugins/audioconvert/channelmix.c index 32e1924e..1a997bf3 100644 --- a/spa/plugins/audioconvert/channelmix.c +++ b/spa/plugins/audioconvert/channelmix.c @@ -752,18 +752,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t id, void *data, size_t size) @@ -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, diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index b2b08d09..af39e345 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -716,18 +716,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t id, void *data, size_t size) @@ -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, diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index 263649ca..89610335 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -799,18 +799,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t id, void *data, size_t size) @@ -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, diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index 64ca313e..ffb09989 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -628,18 +628,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t id, void *data, size_t size) @@ -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, diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index 1bec4506..914f137d 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -764,18 +764,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t id, void *data, size_t size) @@ -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, diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index 0d27d128..06c4406d 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -1251,29 +1251,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t port_id, @@ -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, diff --git a/spa/plugins/bluez5/a2dp-source.c b/spa/plugins/bluez5/a2dp-source.c index 7ac8157a..4d0ad14f 100644 --- a/spa/plugins/bluez5/a2dp-source.c +++ b/spa/plugins/bluez5/a2dp-source.c @@ -903,30 +903,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t port_id, @@ -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, diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 92231a66..8236d574 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -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; - } - 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); + 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 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, diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index a8c232f7..46c402ed 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -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) { diff --git a/spa/plugins/videoconvert/videoadapter.c b/spa/plugins/videoconvert/videoadapter.c index 9c4516bb..3f00a342 100644 --- a/spa/plugins/videoconvert/videoadapter.c +++ b/spa/plugins/videoconvert/videoadapter.c @@ -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; } @@ -761,26 +745,6 @@ impl_node_port_use_buffers(void *object, } 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) { struct impl *this = object; @@ -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, diff --git a/src/modules/module-adapter/floatmix.c b/src/modules/module-adapter/floatmix.c index b55c6d98..6fa28096 100644 --- a/src/modules/module-adapter/floatmix.c +++ b/src/modules/module-adapter/floatmix.c @@ -595,18 +595,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t id, void *data, size_t size) @@ -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, diff --git a/src/modules/module-audio-dsp/floatmix.c b/src/modules/module-audio-dsp/floatmix.c index 0a7ed790..2b62cef5 100644 --- a/src/modules/module-audio-dsp/floatmix.c +++ b/src/modules/module-audio-dsp/floatmix.c @@ -595,18 +595,6 @@ impl_node_port_use_buffers(void *object, } 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, uint32_t id, void *data, size_t size) @@ -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, diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index e017b44b..ecbdec47 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -838,31 +838,6 @@ impl_node_port_use_buffers(void *object, } 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) { struct node *this = object; @@ -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, diff --git a/src/pipewire/port.c b/src/pipewire/port.c index 49520fce..54e3d18f 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -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)); diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 4e72f922..0ccaa957 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -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) |