diff options
author | Wim Taymans <wtaymans@redhat.com> | 2019-07-25 13:19:39 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2019-07-25 13:19:39 +0200 |
commit | 8590ac158bb4f295f41e2c1acd6950f838e5e1d2 (patch) | |
tree | 939f632910b6ae12659172b60b5267cb8d6c097d | |
parent | b314547702953a82ec5cacbd7b716b654a8cd728 (diff) |
node: add flags to port_use_buffer
Remove the CAN_USE_BUFFERS flag, it is redundant. We can know this
because of the IO params and buffer params.
Add flags to the port_use_buffer call. We also want this call to
replace port_alloc_buffer. Together with a new result event we can
ask the node to (a)synchronously fill up the buffer data for us. This
is part of a plan to let remote nodes provide buffer data.
33 files changed, 157 insertions, 126 deletions
diff --git a/pipewire-jack b/pipewire-jack -Subproject 3a9035a44cb1927ac1b20937d3d1e9c6e32ffe5 +Subproject 8428103e925966c2d3c1c623f38452a8f6fdfea diff --git a/spa/examples/example-control.c b/spa/examples/example-control.c index e7e0f70c..1a118bfb 100644 --- a/spa/examples/example-control.c +++ b/spa/examples/example-control.c @@ -394,11 +394,11 @@ static int negotiate_formats(struct data *data) init_buffer(data, data->source_buffers, data->source_buffer, 1, BUFFER_SIZE); if ((res = - spa_node_port_use_buffers(data->sink, SPA_DIRECTION_INPUT, 0, data->source_buffers, + spa_node_port_use_buffers(data->sink, SPA_DIRECTION_INPUT, 0, 0, data->source_buffers, 1)) < 0) return res; if ((res = - spa_node_port_use_buffers(data->source, SPA_DIRECTION_OUTPUT, 0, data->source_buffers, + spa_node_port_use_buffers(data->source, SPA_DIRECTION_OUTPUT, 0, 0, data->source_buffers, 1)) < 0) return res; diff --git a/spa/examples/local-v4l2.c b/spa/examples/local-v4l2.c index 23435304..dab3f309 100644 --- a/spa/examples/local-v4l2.c +++ b/spa/examples/local-v4l2.c @@ -390,7 +390,7 @@ static int negotiate_formats(struct data *data) if ((res = sdl_alloc_buffers(data)) < 0) return res; - if ((res = spa_node_port_use_buffers(data->source, SPA_DIRECTION_OUTPUT, 0, data->bp, + if ((res = spa_node_port_use_buffers(data->source, SPA_DIRECTION_OUTPUT, 0, 0, data->bp, data->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 516921c1..59eaf5ea 100644 --- a/spa/include/spa/node/node.h +++ b/spa/include/spa/node/node.h @@ -87,20 +87,19 @@ struct spa_port_info { #define SPA_PORT_FLAG_REMOVABLE (1u<<0) /**< port can be removed */ #define SPA_PORT_FLAG_OPTIONAL (1u<<1) /**< processing on port is optional */ #define SPA_PORT_FLAG_CAN_ALLOC_BUFFERS (1u<<2) /**< the port can allocate buffer data */ -#define SPA_PORT_FLAG_CAN_USE_BUFFERS (1u<<3) /**< the port can use a provided buffer */ -#define SPA_PORT_FLAG_IN_PLACE (1u<<4) /**< the port can process data in-place and +#define SPA_PORT_FLAG_IN_PLACE (1u<<3) /**< the port can process data in-place and * will need a writable input buffer */ -#define SPA_PORT_FLAG_NO_REF (1u<<5) /**< the port does not keep a ref on the buffer. +#define SPA_PORT_FLAG_NO_REF (1u<<4) /**< the port does not keep a ref on the buffer. * This means the node will always completely * consume the input buffer and it will be * recycled after process. */ -#define SPA_PORT_FLAG_LIVE (1u<<6) /**< output buffers from this port are +#define SPA_PORT_FLAG_LIVE (1u<<5) /**< output buffers from this port are * timestamped against a live clock. */ -#define SPA_PORT_FLAG_PHYSICAL (1u<<7) /**< connects to some device */ -#define SPA_PORT_FLAG_TERMINAL (1u<<8) /**< data was not created from this port +#define SPA_PORT_FLAG_PHYSICAL (1u<<6) /**< connects to some device */ +#define SPA_PORT_FLAG_TERMINAL (1u<<7) /**< data was not created from this port * or will not be made available on another * port */ -#define SPA_PORT_FLAG_DYNAMIC_DATA (1u<<9) /**< data pointer on buffers can be changed. +#define SPA_PORT_FLAG_DYNAMIC_DATA (1u<<8) /**< data pointer on buffers can be changed. * Only the buffer data marked as DYNAMIC * can be changed. */ uint64_t flags; /**< port flags */ @@ -114,13 +113,14 @@ struct spa_port_info { #define SPA_RESULT_TYPE_NODE_ERROR 1 #define SPA_RESULT_TYPE_NODE_PARAMS 2 +#define SPA_RESULT_TYPE_NODE_BUFFERS 3 /** an error result */ struct spa_result_node_error { const char *message; }; -/** the result of enum_param. */ +/** the result of enum_params or port_enum_params. */ struct spa_result_node_params { uint32_t id; /**< id of parameter */ uint32_t index; /**< index of parameter */ @@ -128,6 +128,12 @@ struct spa_result_node_params { struct spa_pod *param; /**< the result param */ }; +/** the result of use_buffers. */ +struct spa_result_node_buffers { + uint32_t n_buffers; + struct spa_buffer **buffers; +}; + #define SPA_NODE_EVENT_INFO 0 #define SPA_NODE_EVENT_PORT_INFO 1 #define SPA_NODE_EVENT_RESULT 2 @@ -220,10 +226,16 @@ struct spa_node_callbacks { /** flags that can be passed to set_param and port_set_param functions */ -#define SPA_NODE_PARAM_FLAG_TEST_ONLY (1 << 0) /* just check if the param is accepted */ -#define SPA_NODE_PARAM_FLAG_FIXATE (1 << 1) /* fixate the non-optional unset fields */ -#define SPA_NODE_PARAM_FLAG_NEAREST (1 << 2) /* allow set fields to be rounded to the - * nearest allowed field value. */ +#define SPA_NODE_PARAM_FLAG_TEST_ONLY (1 << 0) /**< Just check if the param is accepted */ +#define SPA_NODE_PARAM_FLAG_FIXATE (1 << 1) /**< Fixate the non-optional unset fields */ +#define SPA_NODE_PARAM_FLAG_NEAREST (1 << 2) /**< Allow set fields to be rounded to the + * nearest allowed field value. */ + +/** flags to pass to the use_buffers functions */ +#define SPA_NODE_BUFFERS_FLAG_ALLOC (1 << 0) /**< Allocate memory for the buffers. This flag + * is ignored when the port does not have the + * SPA_PORT_FLAG_CAN_ALLOC_BUFFERS set. */ + #define SPA_NODE_METHOD_ADD_LISTENER 0 #define SPA_NODE_METHOD_SET_CALLBACKS 1 @@ -520,11 +532,15 @@ struct spa_node_methods { * Passing NULL as \a buffers will remove the reference that the port has * on the buffers. * + * The function will emit the result event of type SPA_RESULT_TYPE_NODE_BUFFERS + * with the final allocation of the buffers. + * * This function must be called from the main thread. * - * \param node an spa_node + * \param object an object implementing the interface * \param direction an spa_direction * \param port_id a port id + * \param flags extra flags * \param buffers an array of buffer pointers * \param n_buffers number of elements in \a buffers * \return 0 on success @@ -532,6 +548,7 @@ struct spa_node_methods { int (*port_use_buffers) (void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers); /** diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 3408ce52..2b739173 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -506,8 +506,9 @@ impl_node_port_set_param(void *object, static int impl_node_port_use_buffers(void *object, - enum spa_direction direction, - uint32_t port_id, struct spa_buffer **buffers, uint32_t n_buffers) + enum spa_direction direction, uint32_t port_id, + uint32_t flags, + struct spa_buffer **buffers, uint32_t n_buffers) { struct state *this = object; uint32_t i; @@ -756,8 +757,7 @@ impl_init(const struct spa_handle_factory *factory, this->port_info_all = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PARAMS; this->port_info = SPA_PORT_INFO_INIT(); - this->port_info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_LIVE | + this->port_info.flags = SPA_PORT_FLAG_LIVE | SPA_PORT_FLAG_PHYSICAL | SPA_PORT_FLAG_TERMINAL; this->port_params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index f5603c19..05aa81e2 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -521,8 +521,9 @@ impl_node_port_set_param(void *object, static int impl_node_port_use_buffers(void *object, - enum spa_direction direction, - uint32_t port_id, struct spa_buffer **buffers, uint32_t n_buffers) + enum spa_direction direction, uint32_t port_id, + uint32_t flags, + struct spa_buffer **buffers, uint32_t n_buffers) { struct state *this = object; int res; @@ -779,8 +780,7 @@ impl_init(const struct spa_handle_factory *factory, this->port_info_all = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PARAMS; this->port_info = SPA_PORT_INFO_INIT(); - this->port_info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_LIVE | + this->port_info.flags = SPA_PORT_FLAG_LIVE | SPA_PORT_FLAG_PHYSICAL | SPA_PORT_FLAG_TERMINAL; this->port_params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index 210ca918..d024e5a4 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -649,7 +649,7 @@ static int negotiate_buffers(struct impl *this) } else { if ((res = spa_node_port_use_buffers(this->convert, - SPA_DIRECTION_REVERSE(this->direction), 0, + SPA_DIRECTION_REVERSE(this->direction), 0, 0, this->buffers, this->n_buffers)) < 0) return res; } @@ -663,7 +663,7 @@ static int negotiate_buffers(struct impl *this) } else { if ((res = spa_node_port_use_buffers(this->slave, - this->direction, 0, + this->direction, 0, 0, this->buffers, this->n_buffers)) < 0) { return res; } @@ -730,6 +730,7 @@ static int impl_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { @@ -742,7 +743,7 @@ impl_node_port_use_buffers(void *object, port_id++; if ((res = spa_node_port_use_buffers(this->target, - direction, port_id, buffers, n_buffers)) < 0) + direction, port_id, flags, buffers, n_buffers)) < 0) return res; diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index a09a41b2..e99f47be 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -344,7 +344,7 @@ static int negotiate_link_buffers(struct impl *this, struct link *link) } else { if ((res = spa_node_port_use_buffers(link->out_node, - SPA_DIRECTION_OUTPUT, link->out_port, + SPA_DIRECTION_OUTPUT, link->out_port, 0, link->buffers, link->n_buffers)) < 0) return res; } @@ -357,7 +357,7 @@ static int negotiate_link_buffers(struct impl *this, struct link *link) } else { if ((res = spa_node_port_use_buffers(link->in_node, - SPA_DIRECTION_INPUT, link->in_port, + SPA_DIRECTION_INPUT, link->in_port, 0, link->buffers, link->n_buffers)) < 0) return res; } @@ -799,6 +799,7 @@ static int impl_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { @@ -814,7 +815,7 @@ impl_node_port_use_buffers(void *object, target = this->fmt[direction]; if ((res = spa_node_port_use_buffers(target, - direction, port_id, buffers, n_buffers)) < 0) + direction, port_id, flags, buffers, n_buffers)) < 0) return res; if (buffers && this->buffers_set[SPA_DIRECTION_REVERSE(direction)]) { diff --git a/spa/plugins/audioconvert/channelmix.c b/spa/plugins/audioconvert/channelmix.c index d961604b..32e1924e 100644 --- a/spa/plugins/audioconvert/channelmix.c +++ b/spa/plugins/audioconvert/channelmix.c @@ -688,10 +688,9 @@ impl_node_port_set_param(void *object, static int impl_node_port_use_buffers(void *object, - enum spa_direction direction, - uint32_t port_id, - struct spa_buffer **buffers, - uint32_t n_buffers) + enum spa_direction direction, uint32_t port_id, + uint32_t flags, + struct spa_buffer **buffers, uint32_t n_buffers) { struct impl *this = object; struct port *port; @@ -1028,8 +1027,7 @@ impl_init(const struct spa_handle_factory *factory, port->info_all = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PARAMS; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_DYNAMIC_DATA; + port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ); @@ -1045,8 +1043,7 @@ impl_init(const struct spa_handle_factory *factory, port->info_all = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PARAMS; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_NO_REF | + port->info.flags = SPA_PORT_FLAG_NO_REF | SPA_PORT_FLAG_DYNAMIC_DATA; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index 5d8175cc..b2b08d09 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -639,6 +639,7 @@ static int impl_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { @@ -935,8 +936,7 @@ static int init_port(struct impl *this, enum spa_direction direction, uint32_t p spa_list_init(&port->queue); port->info_all = SPA_PORT_CHANGE_MASK_FLAGS; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_NO_REF | + port->info.flags = SPA_PORT_FLAG_NO_REF | SPA_PORT_FLAG_DYNAMIC_DATA; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index 154334f8..263649ca 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -166,8 +166,7 @@ static int init_port(struct impl *this, enum spa_direction direction, uint32_t p SPA_PORT_CHANGE_MASK_PROPS | SPA_PORT_CHANGE_MASK_PARAMS; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_NO_REF | + port->info.flags = SPA_PORT_FLAG_NO_REF | SPA_PORT_FLAG_DYNAMIC_DATA; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); @@ -736,6 +735,7 @@ static int impl_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { @@ -1101,8 +1101,7 @@ impl_init(const struct spa_handle_factory *factory, port->info_all = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PARAMS; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_DYNAMIC_DATA; + port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ); diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index a6884d17..64ca313e 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -568,6 +568,7 @@ static int impl_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { @@ -953,7 +954,7 @@ impl_init(const struct spa_handle_factory *factory, port->info_all = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PARAMS; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS; + port->info.flags = 0; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ); @@ -969,8 +970,7 @@ impl_init(const struct spa_handle_factory *factory, port->info_all = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PARAMS; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_DYNAMIC_DATA; + port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ); diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index a79b998c..1bec4506 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -158,8 +158,7 @@ static int init_port(struct impl *this, enum spa_direction direction, SPA_PORT_CHANGE_MASK_PARAMS; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_DYNAMIC_DATA; + port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA; port->info_props_items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_FORMAT_DSP, "32 bit float mono audio"); port->info_props_items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_AUDIO_CHANNEL, port->position); port->info_props = SPA_DICT_INIT(port->info_props_items, 2); @@ -706,6 +705,7 @@ static int impl_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { @@ -1017,8 +1017,7 @@ impl_init(const struct spa_handle_factory *factory, port->direction = SPA_DIRECTION_INPUT; port->id = 0; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_NO_REF | + port->info.flags = SPA_PORT_FLAG_NO_REF | SPA_PORT_FLAG_DYNAMIC_DATA; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index 3db513a5..0d27d128 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -1166,7 +1166,7 @@ static int port_set_format(struct impl *this, struct port *port, port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS; if (port->have_format) { port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS; - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | SPA_PORT_FLAG_LIVE; + port->info.flags = SPA_PORT_FLAG_LIVE; port->info.change_mask |= SPA_PORT_CHANGE_MASK_RATE; port->info.rate = SPA_FRACTION(1, port->current_format.info.raw.rate); port->params[3] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_READWRITE); @@ -1207,8 +1207,9 @@ impl_node_port_set_param(void *object, static int impl_node_port_use_buffers(void *object, - enum spa_direction direction, - uint32_t port_id, struct spa_buffer **buffers, uint32_t n_buffers) + enum spa_direction direction, uint32_t port_id, + uint32_t flags, + struct spa_buffer **buffers, uint32_t n_buffers) { struct impl *this = object; struct port *port; @@ -1474,7 +1475,7 @@ impl_init(const struct spa_handle_factory *factory, port->info_all = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PARAMS; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS; + port->info.flags = 0; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ); diff --git a/spa/plugins/bluez5/a2dp-source.c b/spa/plugins/bluez5/a2dp-source.c index 5ac8861a..7ac8157a 100644 --- a/spa/plugins/bluez5/a2dp-source.c +++ b/spa/plugins/bluez5/a2dp-source.c @@ -817,7 +817,7 @@ static int port_set_format(struct impl *this, struct port *port, port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS; if (port->have_format) { port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS; - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | SPA_PORT_FLAG_LIVE; + port->info.flags = SPA_PORT_FLAG_LIVE; port->info.change_mask |= SPA_PORT_CHANGE_MASK_RATE; port->info.rate = SPA_FRACTION(1, port->current_format.info.raw.rate); port->params[3] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_READWRITE); @@ -859,8 +859,9 @@ impl_node_port_set_param(void *object, static int impl_node_port_use_buffers(void *object, - enum spa_direction direction, - uint32_t port_id, struct spa_buffer **buffers, uint32_t n_buffers) + enum spa_direction direction, uint32_t port_id, + uint32_t flags, + struct spa_buffer **buffers, uint32_t n_buffers) { struct impl *this = object; struct port *port; @@ -1163,8 +1164,7 @@ impl_init(const struct spa_handle_factory *factory, SPA_PORT_CHANGE_MASK_PARAMS; port->info = SPA_PORT_INFO_INIT(); port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS; - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_LIVE | + port->info.flags = SPA_PORT_FLAG_LIVE | SPA_PORT_FLAG_TERMINAL; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 31d9770f..92231a66 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -678,6 +678,7 @@ static int impl_node_port_set_param(void *object, static int impl_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index 8811592d..a8c232f7 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -925,7 +925,6 @@ static int spa_v4l2_set_format(struct impl *this, struct spa_video_info *format, port->fmt = fmt; port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_RATE; port->info.flags = (port->export_buf ? SPA_PORT_FLAG_CAN_ALLOC_BUFFERS : 0) | - SPA_PORT_FLAG_CAN_USE_BUFFERS | SPA_PORT_FLAG_LIVE | SPA_PORT_FLAG_PHYSICAL | SPA_PORT_FLAG_TERMINAL; diff --git a/spa/plugins/videoconvert/videoadapter.c b/spa/plugins/videoconvert/videoadapter.c index 74e26fb5..9c4516bb 100644 --- a/spa/plugins/videoconvert/videoadapter.c +++ b/spa/plugins/videoconvert/videoadapter.c @@ -652,7 +652,7 @@ static int negotiate_buffers(struct impl *this) } else { if ((res = spa_node_port_use_buffers(this->convert, - SPA_DIRECTION_REVERSE(this->direction), 0, + SPA_DIRECTION_REVERSE(this->direction), 0, 0, this->buffers, this->n_buffers)) < 0) return res; } @@ -665,7 +665,7 @@ static int negotiate_buffers(struct impl *this) } } else { - if ((res = spa_node_port_use_buffers(this->slave, + if ((res = spa_node_port_use_buffers(this->slave, 0, this->direction, 0, this->buffers, this->n_buffers)) < 0) { return res; @@ -733,6 +733,7 @@ static int impl_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { @@ -745,7 +746,7 @@ impl_node_port_use_buffers(void *object, port_id++; if ((res = spa_node_port_use_buffers(this->target, - direction, port_id, buffers, n_buffers)) < 0) + direction, port_id, flags, buffers, n_buffers)) < 0) return res; diff --git a/src/examples/export-sink.c b/src/examples/export-sink.c index a7c4af0e..82815b43 100644 --- a/src/examples/export-sink.c +++ b/src/examples/export-sink.c @@ -340,7 +340,8 @@ static int impl_port_set_param(void *object, } static int impl_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, - struct spa_buffer **buffers, uint32_t n_buffers) + uint32_t flags, + struct spa_buffer **buffers, uint32_t n_buffers) { struct data *d = object; uint32_t i; @@ -527,7 +528,7 @@ int main(int argc, char *argv[]) data.info = SPA_PORT_INFO_INIT(); data.info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS; - data.info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS; + data.info.flags = 0; data.info.change_mask = SPA_PORT_CHANGE_MASK_PARAMS; data.params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); data.params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); diff --git a/src/examples/export-source.c b/src/examples/export-source.c index 5f7dacc7..a69babdf 100644 --- a/src/examples/export-source.c +++ b/src/examples/export-source.c @@ -304,10 +304,12 @@ static int impl_port_set_param(void *object, } static int impl_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, - struct spa_buffer **buffers, uint32_t n_buffers) + uint32_t flags, + struct spa_buffer **buffers, uint32_t n_buffers) { struct data *d = object; uint32_t i; + for (i = 0; i < n_buffers; i++) { struct buffer *b = &d->buffers[i]; struct spa_data *datas = buffers[i]->datas; @@ -521,7 +523,7 @@ int main(int argc, char *argv[]) SPA_PORT_CHANGE_MASK_PROPS | SPA_PORT_CHANGE_MASK_PARAMS; data.info = SPA_PORT_INFO_INIT(); - data.info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS; + data.info.flags = 0; data.items[0] = SPA_DICT_ITEM_INIT(PW_KEY_FORMAT_DSP, "32 bit float mono audio"); data.dict = SPA_DICT_INIT_ARRAY(data.items); data.info.props = &data.dict; diff --git a/src/examples/local-v4l2.c b/src/examples/local-v4l2.c index 4d52d4ac..1fd4161c 100644 --- a/src/examples/local-v4l2.c +++ b/src/examples/local-v4l2.c @@ -104,7 +104,7 @@ static int impl_add_listener(void *object, info = SPA_PORT_INFO_INIT(); info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS; - info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS; + info.flags = 0; spa_node_emit_port_info(&d->hooks, SPA_DIRECTION_INPUT, 0, &info); @@ -243,7 +243,7 @@ static int impl_port_set_param(void *object, } static int impl_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, - struct spa_buffer **buffers, uint32_t n_buffers) + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { struct data *d = object; uint32_t i; diff --git a/src/extensions/client-node.h b/src/extensions/client-node.h index 05d8c8b9..ec0227fc 100644 --- a/src/extensions/client-node.h +++ b/src/extensions/client-node.h @@ -171,6 +171,7 @@ struct pw_client_node_proxy_events { enum spa_direction direction, uint32_t port_id, uint32_t mix_id, + uint32_t flags, uint32_t n_buffers, struct pw_client_node_buffer *buffers); /** diff --git a/src/modules/module-adapter/adapter.c b/src/modules/module-adapter/adapter.c index 4483b732..fc1fd9e2 100644 --- a/src/modules/module-adapter/adapter.c +++ b/src/modules/module-adapter/adapter.c @@ -125,8 +125,8 @@ static void init_port(struct port *p, enum spa_direction direction) } static int port_use_buffers(void *data, - struct spa_buffer **buffers, - uint32_t n_buffers) + uint32_t flags, + struct spa_buffer **buffers, uint32_t n_buffers) { struct port *p = data; struct pw_port *port = p->port; @@ -144,15 +144,13 @@ static int port_use_buffers(void *data, } res = spa_node_port_use_buffers(port->mix, - pw_direction_reverse(port->direction), - 0, - buffers, - n_buffers); + pw_direction_reverse(port->direction), 0, + flags, + buffers, n_buffers); res = spa_node_port_use_buffers(node->node, - port->direction, - port->port_id, - buffers, - n_buffers); + port->direction, port->port_id, + flags, + buffers, n_buffers); return res; } diff --git a/src/modules/module-adapter/floatmix.c b/src/modules/module-adapter/floatmix.c index eb65ef0d..b55c6d98 100644 --- a/src/modules/module-adapter/floatmix.c +++ b/src/modules/module-adapter/floatmix.c @@ -236,8 +236,7 @@ static int impl_node_add_port(void *object, enum spa_direction direction, uint32 port->info_all = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PARAMS; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_NO_REF | + port->info.flags = SPA_PORT_FLAG_NO_REF | SPA_PORT_FLAG_DYNAMIC_DATA | SPA_PORT_FLAG_REMOVABLE | SPA_PORT_FLAG_OPTIONAL; @@ -548,6 +547,7 @@ static int impl_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { @@ -893,8 +893,7 @@ impl_init(const struct spa_handle_factory *factory, port->id = 0; port->info = SPA_PORT_INFO_INIT(); port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS; - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_DYNAMIC_DATA; + port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA; port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); diff --git a/src/modules/module-audio-dsp/audio-dsp.c b/src/modules/module-audio-dsp/audio-dsp.c index 3434bd97..ca30194e 100644 --- a/src/modules/module-audio-dsp/audio-dsp.c +++ b/src/modules/module-audio-dsp/audio-dsp.c @@ -121,8 +121,8 @@ static void init_port(struct port *p, enum spa_direction direction) } static int port_use_buffers(void *data, - struct spa_buffer **buffers, - uint32_t n_buffers) + uint32_t flags, + struct spa_buffer **buffers, uint32_t n_buffers) { struct port *p = data; struct pw_port *port = p->port; @@ -140,15 +140,13 @@ static int port_use_buffers(void *data, } res = spa_node_port_use_buffers(port->mix, - pw_direction_reverse(port->direction), - 0, - buffers, - n_buffers); + pw_direction_reverse(port->direction), 0, + flags, + buffers, n_buffers); res = spa_node_port_use_buffers(node->node, - port->direction, - port->port_id, - buffers, - n_buffers); + port->direction, port->port_id, + flags, + buffers, n_buffers); return res; } diff --git a/src/modules/module-audio-dsp/floatmix.c b/src/modules/module-audio-dsp/floatmix.c index 5e665b9f..0a7ed790 100644 --- a/src/modules/module-audio-dsp/floatmix.c +++ b/src/modules/module-audio-dsp/floatmix.c @@ -236,8 +236,7 @@ static int impl_node_add_port(void *object, enum spa_direction direction, uint32 port->info_all = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PARAMS; port->info = SPA_PORT_INFO_INIT(); - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_NO_REF | + port->info.flags = SPA_PORT_FLAG_NO_REF | SPA_PORT_FLAG_DYNAMIC_DATA | SPA_PORT_FLAG_REMOVABLE | SPA_PORT_FLAG_OPTIONAL; @@ -548,6 +547,7 @@ static int impl_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { @@ -890,8 +890,7 @@ impl_init(const struct spa_handle_factory *factory, port->id = 0; port->info = SPA_PORT_INFO_INIT(); port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS; - port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | - SPA_PORT_FLAG_DYNAMIC_DATA; + port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA; port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS; port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ); diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index 2524fd5d..e017b44b 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -187,11 +187,13 @@ struct impl { pw_client_node_resource(r,port_set_io,0,__VA_ARGS__) #define pw_client_node_resource_set_activation(r,...) \ pw_client_node_resource(r,set_activation,0,__VA_ARGS__) + static int do_port_use_buffers(struct impl *impl, enum spa_direction direction, uint32_t port_id, uint32_t mix_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers); @@ -268,7 +270,7 @@ static void mix_clear(struct node *this, struct mix *mix) if (!mix->valid) return; do_port_use_buffers(this->impl, port->direction, port->id, - mix->id, NULL, 0); + mix->id, 0, NULL, 0); mix->valid = false; } @@ -695,6 +697,7 @@ do_port_use_buffers(struct impl *impl, enum spa_direction direction, uint32_t port_id, uint32_t mix_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { @@ -811,7 +814,7 @@ do_port_use_buffers(struct impl *impl, } return pw_client_node_resource_port_use_buffers(this->resource, - direction, port_id, mix_id, + direction, port_id, mix_id, flags, n_buffers, mb); } @@ -819,6 +822,7 @@ static int impl_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { @@ -830,7 +834,7 @@ impl_node_port_use_buffers(void *object, impl = this->impl; return do_port_use_buffers(impl, direction, port_id, - SPA_ID_INVALID, buffers, n_buffers); + SPA_ID_INVALID, flags, buffers, n_buffers); } static int @@ -1344,13 +1348,14 @@ static int impl_mix_port_use_buffers(void *object, enum spa_direction direction, uint32_t mix_id, + uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { struct port *port = object; struct impl *impl = port->impl; - return do_port_use_buffers(impl, direction, port->id, mix_id, buffers, n_buffers); + return do_port_use_buffers(impl, direction, port->id, mix_id, flags, buffers, n_buffers); } static int diff --git a/src/modules/module-client-node/protocol-native.c b/src/modules/module-client-node/protocol-native.c index 5d84bc50..b90264de 100644 --- a/src/modules/module-client-node/protocol-native.c +++ b/src/modules/module-client-node/protocol-native.c @@ -413,7 +413,7 @@ static int client_node_demarshal_port_use_buffers(void *object, const struct pw_ struct pw_proxy *proxy = object; struct spa_pod_parser prs; struct spa_pod_frame f; - uint32_t direction, port_id, mix_id, n_buffers, data_id; + uint32_t direction, port_id, mix_id, flags, n_buffers, data_id; struct pw_client_node_buffer *buffers; uint32_t i, j; @@ -423,6 +423,7 @@ static int client_node_demarshal_port_use_buffers(void *object, const struct pw_ SPA_POD_Int(&direction), SPA_POD_Int(&port_id), SPA_POD_Int(&mix_id), + SPA_POD_Int(&flags), SPA_POD_Int(&n_buffers), NULL) < 0) return -EINVAL; @@ -469,6 +470,7 @@ static int client_node_demarshal_port_use_buffers(void *object, const struct pw_ direction, port_id, mix_id, + flags, n_buffers, buffers); return 0; } @@ -673,6 +675,7 @@ client_node_marshal_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, uint32_t mix_id, + uint32_t flags, uint32_t n_buffers, struct pw_client_node_buffer *buffers) { struct pw_resource *resource = object; @@ -687,6 +690,7 @@ client_node_marshal_port_use_buffers(void *object, SPA_POD_Int(direction), SPA_POD_Int(port_id), SPA_POD_Int(mix_id), + SPA_POD_Int(flags), SPA_POD_Int(n_buffers), NULL); for (i = 0; i < n_buffers; i++) { diff --git a/src/modules/module-client-node/remote-node.c b/src/modules/module-client-node/remote-node.c index 4e06bd3f..a06f3034 100644 --- a/src/modules/module-client-node/remote-node.c +++ b/src/modules/module-client-node/remote-node.c @@ -496,7 +496,7 @@ static int clear_buffers(struct node_data *data, struct mix *mix) int res; pw_log_debug("port %p: clear buffers mix:%d", port, mix->mix_id); - if ((res = pw_port_use_buffers(port, mix->mix_id, NULL, 0)) < 0) { + if ((res = pw_port_use_buffers(port, mix->mix_id, 0, NULL, 0)) < 0) { pw_log_error("port %p: error clear buffers %s", port, spa_strerror(res)); return res; } @@ -553,6 +553,7 @@ error_exit: static int client_node_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, uint32_t mix_id, + uint32_t flags, uint32_t n_buffers, struct pw_client_node_buffer *buffers) { struct pw_proxy *proxy = object; @@ -666,7 +667,7 @@ client_node_port_use_buffers(void *object, bufs[i] = b; } - if ((res = pw_port_use_buffers(mix->port, mix->mix_id, bufs, n_buffers)) < 0) + if ((res = pw_port_use_buffers(mix->port, mix->mix_id, flags, bufs, n_buffers)) < 0) goto error_exit_cleanup; return res; diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 515b5b0c..657b0b15 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -561,6 +561,7 @@ static int do_allocation(struct pw_link *this) char *error = NULL; struct pw_port *input, *output; struct allocation allocation = { NULL, }; + bool in_use, out_use; if (this->info.state > PW_LINK_STATE_ALLOCATING) return 0; @@ -574,6 +575,7 @@ static int do_allocation(struct pw_link *this) in_flags = input->spa_flags; out_flags = output->spa_flags; + in_use = out_use = true; pw_log_debug("link %p: doing alloc buffers %p %p: in_flags:%08x out_flags:%08x", this, output->node, input->node, in_flags, out_flags); @@ -683,18 +685,19 @@ static int do_allocation(struct pw_link *this) goto error; } out_res = res; - SPA_FLAG_UNSET(out_flags, SPA_PORT_FLAG_CAN_USE_BUFFERS); + out_use = false; move_allocation(&allocation, &output->allocation); pw_log_debug("link %p: allocated %d buffers %p from output port", this, allocation.n_buffers, allocation.buffers); } } - if (out_flags & SPA_PORT_FLAG_CAN_USE_BUFFERS) { + if (out_use) { pw_log_debug("link %p: using %d buffers %p on output port", this, allocation.n_buffers, allocation.buffers); if ((res = pw_port_use_buffers(output, this->rt.out_mix.port.port_id, + 0, allocation.buffers, allocation.n_buffers)) < 0) { asprintf(&error, "link %p: error use output buffers: %s", this, @@ -704,11 +707,12 @@ static int do_allocation(struct pw_link *this) out_res = res; move_allocation(&allocation, &output->allocation); } - if (in_flags & SPA_PORT_FLAG_CAN_USE_BUFFERS) { + if (in_use) { pw_log_debug("link %p: using %d buffers %p on input port", this, allocation.n_buffers, allocation.buffers); if ((res = pw_port_use_buffers(input, this->rt.in_mix.port.port_id, + 0, allocation.buffers, allocation.n_buffers)) < 0) { asprintf(&error, "link %p: error use input buffers: %s", this, @@ -875,7 +879,7 @@ static void clear_port_buffers(struct pw_link *link, struct pw_port *port) else mix = &link->rt.in_mix; - if ((res = pw_port_use_buffers(port, mix->port.port_id, NULL, 0)) < 0) + if ((res = pw_port_use_buffers(port, mix->port.port_id, 0, NULL, 0)) < 0) pw_log_warn("link %p: port %p clear error %s", link, port, spa_strerror(res)); } diff --git a/src/pipewire/port.c b/src/pipewire/port.c index 5bbd8a0d..49520fce 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -1024,7 +1024,7 @@ int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags, } SPA_EXPORT -int pw_port_use_buffers(struct pw_port *port, uint32_t mix_id, +int pw_port_use_buffers(struct pw_port *port, uint32_t mix_id, uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { int res = 0; @@ -1045,7 +1045,7 @@ int pw_port_use_buffers(struct pw_port *port, uint32_t mix_id, { res = spa_node_port_use_buffers(port->mix, - mix->port.direction, mix->port.port_id, + mix->port.direction, mix->port.port_id, flags, buffers, n_buffers); if (res == -ENOTSUP) res = 0; @@ -1063,7 +1063,8 @@ int pw_port_use_buffers(struct pw_port *port, uint32_t mix_id, pw_log_debug("port %p: use buffers on node: %p", port, node->node); res = spa_node_port_use_buffers(node->node, - port->direction, port->port_id, buffers, n_buffers); + port->direction, port->port_id, + flags, buffers, n_buffers); if (res < 0) pw_log_error("port %p: use buffers on node: %d (%s)", port, res, spa_strerror(res)); @@ -1071,7 +1072,7 @@ int pw_port_use_buffers(struct pw_port *port, uint32_t mix_id, port->allocated = false; free_allocation(&port->allocation); - res = pw_port_call_use_buffers(port, buffers, n_buffers); + res = pw_port_call_use_buffers(port, flags, buffers, n_buffers); } if (n_buffers > 0 && !SPA_RESULT_IS_ASYNC(res)) { diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 52d0f81f..4e72f922 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -476,7 +476,7 @@ 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, struct spa_buffer **buffers, uint32_t n_buffers); + 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); }; @@ -492,7 +492,7 @@ 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,b,n) pw_port_call(p,use_buffers,0,b,n) +#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__) @@ -876,7 +876,7 @@ int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags, const struct spa_pod *param); /** Use buffers on a port \memberof pw_port */ -int pw_port_use_buffers(struct pw_port *port, uint32_t mix_id, +int pw_port_use_buffers(struct pw_port *port, uint32_t mix_id, uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers); /** Allocate memory for buffers on a port \memberof pw_port */ diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index 340ed562..61fc3d94 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -385,7 +385,7 @@ static void emit_port_info(struct stream *d) info = SPA_PORT_INFO_INIT(); info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS; - info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS; + info.flags = 0; info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS; info.params = d->params; info.n_params = 5; @@ -601,12 +601,14 @@ static void clear_buffers(struct pw_stream *stream) clear_queue(impl, &impl->queued); } -static int impl_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, - struct spa_buffer **buffers, uint32_t n_buffers) +static int impl_port_use_buffers(void *object, + enum spa_direction direction, uint32_t port_id, + uint32_t flags, + struct spa_buffer **buffers, uint32_t n_buffers) { struct stream *impl = object; struct pw_stream *stream = &impl->this; - uint32_t i, j, flags = impl->flags; + uint32_t i, j, impl_flags = impl->flags; int prot, res; int size = 0; @@ -621,7 +623,7 @@ static int impl_port_use_buffers(void *object, enum spa_direction direction, uin b->flags = 0; b->id = i; - if (SPA_FLAG_CHECK(flags, PW_STREAM_FLAG_MAP_BUFFERS)) { + if (SPA_FLAG_CHECK(impl_flags, PW_STREAM_FLAG_MAP_BUFFERS)) { for (j = 0; j < buffers[i]->n_datas; j++) { struct spa_data *d = &buffers[i]->datas[j]; if (d->type == SPA_DATA_MemFd || |