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.
This commit is contained in:
Wim Taymans 2019-07-25 13:19:39 +02:00
parent b314547702
commit 8590ac158b
33 changed files with 153 additions and 122 deletions

@ -1 +1 @@
Subproject commit 3a9035a44cb1927ac1b20937d3d1e9c6e32ffe5c Subproject commit 8428103e925966c2d3c1c623f38452a8f6fdfeac

View file

@ -394,11 +394,11 @@ static int negotiate_formats(struct data *data)
init_buffer(data, data->source_buffers, data->source_buffer, 1, BUFFER_SIZE); init_buffer(data, data->source_buffers, data->source_buffer, 1, BUFFER_SIZE);
if ((res = 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) 1)) < 0)
return res; return res;
if ((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) 1)) < 0)
return res; return res;

View file

@ -390,7 +390,7 @@ static int negotiate_formats(struct data *data)
if ((res = sdl_alloc_buffers(data)) < 0) if ((res = sdl_alloc_buffers(data)) < 0)
return res; 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) { data->n_buffers)) < 0) {
printf("can't allocate buffers: %s\n", spa_strerror(res)); printf("can't allocate buffers: %s\n", spa_strerror(res));
return -1; return -1;

View file

@ -87,20 +87,19 @@ struct spa_port_info {
#define SPA_PORT_FLAG_REMOVABLE (1u<<0) /**< port can be removed */ #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_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_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<<3) /**< the port can process data in-place and
#define SPA_PORT_FLAG_IN_PLACE (1u<<4) /**< the port can process data in-place and
* will need a writable input buffer */ * 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 * This means the node will always completely
* consume the input buffer and it will be * consume the input buffer and it will be
* recycled after process. */ * 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. */ * timestamped against a live clock. */
#define SPA_PORT_FLAG_PHYSICAL (1u<<7) /**< connects to some device */ #define SPA_PORT_FLAG_PHYSICAL (1u<<6) /**< connects to some device */
#define SPA_PORT_FLAG_TERMINAL (1u<<8) /**< data was not created from this port #define SPA_PORT_FLAG_TERMINAL (1u<<7) /**< data was not created from this port
* or will not be made available on another * or will not be made available on another
* port */ * 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 * Only the buffer data marked as DYNAMIC
* can be changed. */ * can be changed. */
uint64_t flags; /**< port flags */ 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_ERROR 1
#define SPA_RESULT_TYPE_NODE_PARAMS 2 #define SPA_RESULT_TYPE_NODE_PARAMS 2
#define SPA_RESULT_TYPE_NODE_BUFFERS 3
/** an error result */ /** an error result */
struct spa_result_node_error { struct spa_result_node_error {
const char *message; const char *message;
}; };
/** the result of enum_param. */ /** the result of enum_params or port_enum_params. */
struct spa_result_node_params { struct spa_result_node_params {
uint32_t id; /**< id of parameter */ uint32_t id; /**< id of parameter */
uint32_t index; /**< index of parameter */ uint32_t index; /**< index of parameter */
@ -128,6 +128,12 @@ struct spa_result_node_params {
struct spa_pod *param; /**< the result param */ 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_INFO 0
#define SPA_NODE_EVENT_PORT_INFO 1 #define SPA_NODE_EVENT_PORT_INFO 1
#define SPA_NODE_EVENT_RESULT 2 #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 */ /** 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_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_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 #define SPA_NODE_PARAM_FLAG_NEAREST (1 << 2) /**< Allow set fields to be rounded to the
* nearest allowed field value. */ * 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_ADD_LISTENER 0
#define SPA_NODE_METHOD_SET_CALLBACKS 1 #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 * Passing NULL as \a buffers will remove the reference that the port has
* on the buffers. * 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. * 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 direction an spa_direction
* \param port_id a port id * \param port_id a port id
* \param flags extra flags
* \param buffers an array of buffer pointers * \param buffers an array of buffer pointers
* \param n_buffers number of elements in \a buffers * \param n_buffers number of elements in \a buffers
* \return 0 on success * \return 0 on success
@ -532,6 +548,7 @@ struct spa_node_methods {
int (*port_use_buffers) (void *object, int (*port_use_buffers) (void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_buffers); uint32_t n_buffers);
/** /**

View file

@ -506,8 +506,9 @@ impl_node_port_set_param(void *object,
static int static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction, uint32_t port_id,
uint32_t port_id, struct spa_buffer **buffers, uint32_t n_buffers) uint32_t flags,
struct spa_buffer **buffers, uint32_t n_buffers)
{ {
struct state *this = object; struct state *this = object;
uint32_t i; uint32_t i;
@ -756,8 +757,7 @@ impl_init(const struct spa_handle_factory *factory,
this->port_info_all = SPA_PORT_CHANGE_MASK_FLAGS | this->port_info_all = SPA_PORT_CHANGE_MASK_FLAGS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
this->port_info = SPA_PORT_INFO_INIT(); this->port_info = SPA_PORT_INFO_INIT();
this->port_info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | this->port_info.flags = SPA_PORT_FLAG_LIVE |
SPA_PORT_FLAG_LIVE |
SPA_PORT_FLAG_PHYSICAL | SPA_PORT_FLAG_PHYSICAL |
SPA_PORT_FLAG_TERMINAL; SPA_PORT_FLAG_TERMINAL;
this->port_params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); this->port_params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);

View file

@ -521,8 +521,9 @@ impl_node_port_set_param(void *object,
static int static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction, uint32_t port_id,
uint32_t port_id, struct spa_buffer **buffers, uint32_t n_buffers) uint32_t flags,
struct spa_buffer **buffers, uint32_t n_buffers)
{ {
struct state *this = object; struct state *this = object;
int res; int res;
@ -779,8 +780,7 @@ impl_init(const struct spa_handle_factory *factory,
this->port_info_all = SPA_PORT_CHANGE_MASK_FLAGS | this->port_info_all = SPA_PORT_CHANGE_MASK_FLAGS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
this->port_info = SPA_PORT_INFO_INIT(); this->port_info = SPA_PORT_INFO_INIT();
this->port_info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | this->port_info.flags = SPA_PORT_FLAG_LIVE |
SPA_PORT_FLAG_LIVE |
SPA_PORT_FLAG_PHYSICAL | SPA_PORT_FLAG_PHYSICAL |
SPA_PORT_FLAG_TERMINAL; SPA_PORT_FLAG_TERMINAL;
this->port_params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); this->port_params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);

View file

@ -649,7 +649,7 @@ static int negotiate_buffers(struct impl *this)
} }
else { else {
if ((res = spa_node_port_use_buffers(this->convert, 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) this->buffers, this->n_buffers)) < 0)
return res; return res;
} }
@ -663,7 +663,7 @@ static int negotiate_buffers(struct impl *this)
} }
else { else {
if ((res = spa_node_port_use_buffers(this->slave, if ((res = spa_node_port_use_buffers(this->slave,
this->direction, 0, this->direction, 0, 0,
this->buffers, this->n_buffers)) < 0) { this->buffers, this->n_buffers)) < 0) {
return res; return res;
} }
@ -730,6 +730,7 @@ static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {
@ -742,7 +743,7 @@ impl_node_port_use_buffers(void *object,
port_id++; port_id++;
if ((res = spa_node_port_use_buffers(this->target, 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; return res;

View file

@ -344,7 +344,7 @@ static int negotiate_link_buffers(struct impl *this, struct link *link)
} }
else { else {
if ((res = spa_node_port_use_buffers(link->out_node, 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) link->buffers, link->n_buffers)) < 0)
return res; return res;
} }
@ -357,7 +357,7 @@ static int negotiate_link_buffers(struct impl *this, struct link *link)
} }
else { else {
if ((res = spa_node_port_use_buffers(link->in_node, 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) link->buffers, link->n_buffers)) < 0)
return res; return res;
} }
@ -799,6 +799,7 @@ static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {
@ -814,7 +815,7 @@ impl_node_port_use_buffers(void *object,
target = this->fmt[direction]; target = this->fmt[direction];
if ((res = spa_node_port_use_buffers(target, 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; return res;
if (buffers && this->buffers_set[SPA_DIRECTION_REVERSE(direction)]) { if (buffers && this->buffers_set[SPA_DIRECTION_REVERSE(direction)]) {

View file

@ -688,10 +688,9 @@ impl_node_port_set_param(void *object,
static int static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction, uint32_t port_id,
uint32_t port_id, uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers, uint32_t n_buffers)
uint32_t n_buffers)
{ {
struct impl *this = object; struct impl *this = object;
struct port *port; struct port *port;
@ -1028,8 +1027,7 @@ impl_init(const struct spa_handle_factory *factory,
port->info_all = SPA_PORT_CHANGE_MASK_FLAGS | port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA;
SPA_PORT_FLAG_DYNAMIC_DATA;
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); 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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, 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 | port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_DYNAMIC_DATA; SPA_PORT_FLAG_DYNAMIC_DATA;
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); 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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);

View file

@ -639,6 +639,7 @@ static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_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); spa_list_init(&port->queue);
port->info_all = SPA_PORT_CHANGE_MASK_FLAGS; port->info_all = SPA_PORT_CHANGE_MASK_FLAGS;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_DYNAMIC_DATA; SPA_PORT_FLAG_DYNAMIC_DATA;
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); 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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);

View file

@ -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_PROPS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_DYNAMIC_DATA; SPA_PORT_FLAG_DYNAMIC_DATA;
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); 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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
@ -736,6 +735,7 @@ static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_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 | port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA;
SPA_PORT_FLAG_DYNAMIC_DATA;
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); 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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ); port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);

View file

@ -568,6 +568,7 @@ static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_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 | port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
port->info = SPA_PORT_INFO_INIT(); 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[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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, 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 | port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA;
SPA_PORT_FLAG_DYNAMIC_DATA;
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); 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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ); port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);

View file

@ -158,8 +158,7 @@ static int init_port(struct impl *this, enum spa_direction direction,
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA;
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[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_items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_AUDIO_CHANNEL, port->position);
port->info_props = SPA_DICT_INIT(port->info_props_items, 2); port->info_props = SPA_DICT_INIT(port->info_props_items, 2);
@ -706,6 +705,7 @@ static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {
@ -1017,8 +1017,7 @@ impl_init(const struct spa_handle_factory *factory,
port->direction = SPA_DIRECTION_INPUT; port->direction = SPA_DIRECTION_INPUT;
port->id = 0; port->id = 0;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_DYNAMIC_DATA; SPA_PORT_FLAG_DYNAMIC_DATA;
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); 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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);

View file

@ -1166,7 +1166,7 @@ static int port_set_format(struct impl *this, struct port *port,
port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS; port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
if (port->have_format) { if (port->have_format) {
port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS; 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.change_mask |= SPA_PORT_CHANGE_MASK_RATE;
port->info.rate = SPA_FRACTION(1, port->current_format.info.raw.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); 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 static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction, uint32_t port_id,
uint32_t port_id, struct spa_buffer **buffers, uint32_t n_buffers) uint32_t flags,
struct spa_buffer **buffers, uint32_t n_buffers)
{ {
struct impl *this = object; struct impl *this = object;
struct port *port; struct port *port;
@ -1474,7 +1475,7 @@ impl_init(const struct spa_handle_factory *factory,
port->info_all = SPA_PORT_CHANGE_MASK_FLAGS | port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
port->info = SPA_PORT_INFO_INIT(); 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[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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ); port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);

View file

@ -817,7 +817,7 @@ static int port_set_format(struct impl *this, struct port *port,
port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS; port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
if (port->have_format) { if (port->have_format) {
port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS; 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.change_mask |= SPA_PORT_CHANGE_MASK_RATE;
port->info.rate = SPA_FRACTION(1, port->current_format.info.raw.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); 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 static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction, uint32_t port_id,
uint32_t port_id, struct spa_buffer **buffers, uint32_t n_buffers) uint32_t flags,
struct spa_buffer **buffers, uint32_t n_buffers)
{ {
struct impl *this = object; struct impl *this = object;
struct port *port; struct port *port;
@ -1163,8 +1164,7 @@ impl_init(const struct spa_handle_factory *factory,
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS; port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_LIVE |
SPA_PORT_FLAG_LIVE |
SPA_PORT_FLAG_TERMINAL; SPA_PORT_FLAG_TERMINAL;
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); 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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);

View file

@ -678,6 +678,7 @@ static int impl_node_port_set_param(void *object,
static int impl_node_port_use_buffers(void *object, static int impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {

View file

@ -925,7 +925,6 @@ static int spa_v4l2_set_format(struct impl *this, struct spa_video_info *format,
port->fmt = fmt; port->fmt = fmt;
port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_RATE; 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) | 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_LIVE |
SPA_PORT_FLAG_PHYSICAL | SPA_PORT_FLAG_PHYSICAL |
SPA_PORT_FLAG_TERMINAL; SPA_PORT_FLAG_TERMINAL;

View file

@ -652,7 +652,7 @@ static int negotiate_buffers(struct impl *this)
} }
else { else {
if ((res = spa_node_port_use_buffers(this->convert, 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) this->buffers, this->n_buffers)) < 0)
return res; return res;
} }
@ -665,7 +665,7 @@ static int negotiate_buffers(struct impl *this)
} }
} }
else { else {
if ((res = spa_node_port_use_buffers(this->slave, if ((res = spa_node_port_use_buffers(this->slave, 0,
this->direction, 0, this->direction, 0,
this->buffers, this->n_buffers)) < 0) { this->buffers, this->n_buffers)) < 0) {
return res; return res;
@ -733,6 +733,7 @@ static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {
@ -745,7 +746,7 @@ impl_node_port_use_buffers(void *object,
port_id++; port_id++;
if ((res = spa_node_port_use_buffers(this->target, 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; return res;

View file

@ -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, 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; struct data *d = object;
uint32_t i; uint32_t i;
@ -527,7 +528,7 @@ int main(int argc, char *argv[])
data.info = SPA_PORT_INFO_INIT(); data.info = SPA_PORT_INFO_INIT();
data.info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS; 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.info.change_mask = SPA_PORT_CHANGE_MASK_PARAMS;
data.params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); 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); data.params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);

View file

@ -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, 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; struct data *d = object;
uint32_t i; uint32_t i;
for (i = 0; i < n_buffers; i++) { for (i = 0; i < n_buffers; i++) {
struct buffer *b = &d->buffers[i]; struct buffer *b = &d->buffers[i];
struct spa_data *datas = buffers[i]->datas; 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_PROPS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
data.info = SPA_PORT_INFO_INIT(); 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.items[0] = SPA_DICT_ITEM_INIT(PW_KEY_FORMAT_DSP, "32 bit float mono audio");
data.dict = SPA_DICT_INIT_ARRAY(data.items); data.dict = SPA_DICT_INIT_ARRAY(data.items);
data.info.props = &data.dict; data.info.props = &data.dict;

View file

@ -104,7 +104,7 @@ static int impl_add_listener(void *object,
info = SPA_PORT_INFO_INIT(); info = SPA_PORT_INFO_INIT();
info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS; 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); 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, 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; struct data *d = object;
uint32_t i; uint32_t i;

View file

@ -171,6 +171,7 @@ struct pw_client_node_proxy_events {
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t mix_id, uint32_t mix_id,
uint32_t flags,
uint32_t n_buffers, uint32_t n_buffers,
struct pw_client_node_buffer *buffers); struct pw_client_node_buffer *buffers);
/** /**

View file

@ -125,8 +125,8 @@ static void init_port(struct port *p, enum spa_direction direction)
} }
static int port_use_buffers(void *data, static int port_use_buffers(void *data,
struct spa_buffer **buffers, uint32_t flags,
uint32_t n_buffers) struct spa_buffer **buffers, uint32_t n_buffers)
{ {
struct port *p = data; struct port *p = data;
struct pw_port *port = p->port; 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, res = spa_node_port_use_buffers(port->mix,
pw_direction_reverse(port->direction), pw_direction_reverse(port->direction), 0,
0, flags,
buffers, buffers, n_buffers);
n_buffers);
res = spa_node_port_use_buffers(node->node, res = spa_node_port_use_buffers(node->node,
port->direction, port->direction, port->port_id,
port->port_id, flags,
buffers, buffers, n_buffers);
n_buffers);
return res; return res;
} }

View file

@ -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 | port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_DYNAMIC_DATA | SPA_PORT_FLAG_DYNAMIC_DATA |
SPA_PORT_FLAG_REMOVABLE | SPA_PORT_FLAG_REMOVABLE |
SPA_PORT_FLAG_OPTIONAL; SPA_PORT_FLAG_OPTIONAL;
@ -548,6 +547,7 @@ static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {
@ -893,8 +893,7 @@ impl_init(const struct spa_handle_factory *factory,
port->id = 0; port->id = 0;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS; port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS;
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA;
SPA_PORT_FLAG_DYNAMIC_DATA;
port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS; port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); 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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);

View file

@ -121,8 +121,8 @@ static void init_port(struct port *p, enum spa_direction direction)
} }
static int port_use_buffers(void *data, static int port_use_buffers(void *data,
struct spa_buffer **buffers, uint32_t flags,
uint32_t n_buffers) struct spa_buffer **buffers, uint32_t n_buffers)
{ {
struct port *p = data; struct port *p = data;
struct pw_port *port = p->port; 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, res = spa_node_port_use_buffers(port->mix,
pw_direction_reverse(port->direction), pw_direction_reverse(port->direction), 0,
0, flags,
buffers, buffers, n_buffers);
n_buffers);
res = spa_node_port_use_buffers(node->node, res = spa_node_port_use_buffers(node->node,
port->direction, port->direction, port->port_id,
port->port_id, flags,
buffers, buffers, n_buffers);
n_buffers);
return res; return res;
} }

View file

@ -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 | port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |
SPA_PORT_CHANGE_MASK_PARAMS; SPA_PORT_CHANGE_MASK_PARAMS;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_NO_REF |
SPA_PORT_FLAG_DYNAMIC_DATA | SPA_PORT_FLAG_DYNAMIC_DATA |
SPA_PORT_FLAG_REMOVABLE | SPA_PORT_FLAG_REMOVABLE |
SPA_PORT_FLAG_OPTIONAL; SPA_PORT_FLAG_OPTIONAL;
@ -548,6 +547,7 @@ static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {
@ -890,8 +890,7 @@ impl_init(const struct spa_handle_factory *factory,
port->id = 0; port->id = 0;
port->info = SPA_PORT_INFO_INIT(); port->info = SPA_PORT_INFO_INIT();
port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS; port->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS;
port->info.flags = SPA_PORT_FLAG_CAN_USE_BUFFERS | port->info.flags = SPA_PORT_FLAG_DYNAMIC_DATA;
SPA_PORT_FLAG_DYNAMIC_DATA;
port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS; port->info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); 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[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);

View file

@ -187,11 +187,13 @@ struct impl {
pw_client_node_resource(r,port_set_io,0,__VA_ARGS__) pw_client_node_resource(r,port_set_io,0,__VA_ARGS__)
#define pw_client_node_resource_set_activation(r,...) \ #define pw_client_node_resource_set_activation(r,...) \
pw_client_node_resource(r,set_activation,0,__VA_ARGS__) pw_client_node_resource(r,set_activation,0,__VA_ARGS__)
static int static int
do_port_use_buffers(struct impl *impl, do_port_use_buffers(struct impl *impl,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t mix_id, uint32_t mix_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_buffers); uint32_t n_buffers);
@ -268,7 +270,7 @@ static void mix_clear(struct node *this, struct mix *mix)
if (!mix->valid) if (!mix->valid)
return; return;
do_port_use_buffers(this->impl, port->direction, port->id, do_port_use_buffers(this->impl, port->direction, port->id,
mix->id, NULL, 0); mix->id, 0, NULL, 0);
mix->valid = false; mix->valid = false;
} }
@ -695,6 +697,7 @@ do_port_use_buffers(struct impl *impl,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t mix_id, uint32_t mix_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_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, return pw_client_node_resource_port_use_buffers(this->resource,
direction, port_id, mix_id, direction, port_id, mix_id, flags,
n_buffers, mb); n_buffers, mb);
} }
@ -819,6 +822,7 @@ static int
impl_node_port_use_buffers(void *object, impl_node_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {
@ -830,7 +834,7 @@ impl_node_port_use_buffers(void *object,
impl = this->impl; impl = this->impl;
return do_port_use_buffers(impl, direction, port_id, return do_port_use_buffers(impl, direction, port_id,
SPA_ID_INVALID, buffers, n_buffers); SPA_ID_INVALID, flags, buffers, n_buffers);
} }
static int static int
@ -1344,13 +1348,14 @@ static int
impl_mix_port_use_buffers(void *object, impl_mix_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t mix_id, uint32_t mix_id,
uint32_t flags,
struct spa_buffer **buffers, struct spa_buffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {
struct port *port = object; struct port *port = object;
struct impl *impl = port->impl; 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 static int

View file

@ -413,7 +413,7 @@ static int client_node_demarshal_port_use_buffers(void *object, const struct pw_
struct pw_proxy *proxy = object; struct pw_proxy *proxy = object;
struct spa_pod_parser prs; struct spa_pod_parser prs;
struct spa_pod_frame f; 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; struct pw_client_node_buffer *buffers;
uint32_t i, j; 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(&direction),
SPA_POD_Int(&port_id), SPA_POD_Int(&port_id),
SPA_POD_Int(&mix_id), SPA_POD_Int(&mix_id),
SPA_POD_Int(&flags),
SPA_POD_Int(&n_buffers), NULL) < 0) SPA_POD_Int(&n_buffers), NULL) < 0)
return -EINVAL; return -EINVAL;
@ -469,6 +470,7 @@ static int client_node_demarshal_port_use_buffers(void *object, const struct pw_
direction, direction,
port_id, port_id,
mix_id, mix_id,
flags,
n_buffers, buffers); n_buffers, buffers);
return 0; return 0;
} }
@ -673,6 +675,7 @@ client_node_marshal_port_use_buffers(void *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t mix_id, uint32_t mix_id,
uint32_t flags,
uint32_t n_buffers, struct pw_client_node_buffer *buffers) uint32_t n_buffers, struct pw_client_node_buffer *buffers)
{ {
struct pw_resource *resource = object; struct pw_resource *resource = object;
@ -687,6 +690,7 @@ client_node_marshal_port_use_buffers(void *object,
SPA_POD_Int(direction), SPA_POD_Int(direction),
SPA_POD_Int(port_id), SPA_POD_Int(port_id),
SPA_POD_Int(mix_id), SPA_POD_Int(mix_id),
SPA_POD_Int(flags),
SPA_POD_Int(n_buffers), NULL); SPA_POD_Int(n_buffers), NULL);
for (i = 0; i < n_buffers; i++) { for (i = 0; i < n_buffers; i++) {

View file

@ -496,7 +496,7 @@ static int clear_buffers(struct node_data *data, struct mix *mix)
int res; int res;
pw_log_debug("port %p: clear buffers mix:%d", port, mix->mix_id); 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)); pw_log_error("port %p: error clear buffers %s", port, spa_strerror(res));
return res; return res;
} }
@ -553,6 +553,7 @@ error_exit:
static int static int
client_node_port_use_buffers(void *object, client_node_port_use_buffers(void *object,
enum spa_direction direction, uint32_t port_id, uint32_t mix_id, 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) uint32_t n_buffers, struct pw_client_node_buffer *buffers)
{ {
struct pw_proxy *proxy = object; struct pw_proxy *proxy = object;
@ -666,7 +667,7 @@ client_node_port_use_buffers(void *object,
bufs[i] = b; 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; goto error_exit_cleanup;
return res; return res;

View file

@ -561,6 +561,7 @@ static int do_allocation(struct pw_link *this)
char *error = NULL; char *error = NULL;
struct pw_port *input, *output; struct pw_port *input, *output;
struct allocation allocation = { NULL, }; struct allocation allocation = { NULL, };
bool in_use, out_use;
if (this->info.state > PW_LINK_STATE_ALLOCATING) if (this->info.state > PW_LINK_STATE_ALLOCATING)
return 0; return 0;
@ -574,6 +575,7 @@ static int do_allocation(struct pw_link *this)
in_flags = input->spa_flags; in_flags = input->spa_flags;
out_flags = output->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", 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); this, output->node, input->node, in_flags, out_flags);
@ -683,18 +685,19 @@ static int do_allocation(struct pw_link *this)
goto error; goto error;
} }
out_res = res; out_res = res;
SPA_FLAG_UNSET(out_flags, SPA_PORT_FLAG_CAN_USE_BUFFERS); out_use = false;
move_allocation(&allocation, &output->allocation); move_allocation(&allocation, &output->allocation);
pw_log_debug("link %p: allocated %d buffers %p from output port", this, pw_log_debug("link %p: allocated %d buffers %p from output port", this,
allocation.n_buffers, allocation.buffers); 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, pw_log_debug("link %p: using %d buffers %p on output port", this,
allocation.n_buffers, allocation.buffers); allocation.n_buffers, allocation.buffers);
if ((res = pw_port_use_buffers(output, if ((res = pw_port_use_buffers(output,
this->rt.out_mix.port.port_id, this->rt.out_mix.port.port_id,
0,
allocation.buffers, allocation.buffers,
allocation.n_buffers)) < 0) { allocation.n_buffers)) < 0) {
asprintf(&error, "link %p: error use output buffers: %s", this, 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; out_res = res;
move_allocation(&allocation, &output->allocation); 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, pw_log_debug("link %p: using %d buffers %p on input port", this,
allocation.n_buffers, allocation.buffers); allocation.n_buffers, allocation.buffers);
if ((res = pw_port_use_buffers(input, if ((res = pw_port_use_buffers(input,
this->rt.in_mix.port.port_id, this->rt.in_mix.port.port_id,
0,
allocation.buffers, allocation.buffers,
allocation.n_buffers)) < 0) { allocation.n_buffers)) < 0) {
asprintf(&error, "link %p: error use input buffers: %s", this, 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 else
mix = &link->rt.in_mix; 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)); pw_log_warn("link %p: port %p clear error %s", link, port, spa_strerror(res));
} }

View file

@ -1024,7 +1024,7 @@ int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags,
} }
SPA_EXPORT 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) struct spa_buffer **buffers, uint32_t n_buffers)
{ {
int res = 0; 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, 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); buffers, n_buffers);
if (res == -ENOTSUP) if (res == -ENOTSUP)
res = 0; 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, pw_log_debug("port %p: use buffers on node: %p", port,
node->node); node->node);
res = spa_node_port_use_buffers(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) if (res < 0)
pw_log_error("port %p: use buffers on node: %d (%s)", pw_log_error("port %p: use buffers on node: %d (%s)",
port, res, spa_strerror(res)); 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; port->allocated = false;
free_allocation(&port->allocation); 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)) { if (n_buffers > 0 && !SPA_RESULT_IS_ASYNC(res)) {

View file

@ -476,7 +476,7 @@ struct pw_port_implementation {
int (*init_mix) (void *data, struct pw_port_mix *mix); int (*init_mix) (void *data, struct pw_port_mix *mix);
int (*release_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, int (*alloc_buffers) (void *data, struct spa_pod **params, uint32_t n_params,
struct spa_buffer **buffers, uint32_t *n_buffers); 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_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_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_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(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); uint32_t id, uint32_t flags, const struct spa_pod *param);
/** Use buffers on a port \memberof pw_port */ /** 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); struct spa_buffer **buffers, uint32_t n_buffers);
/** Allocate memory for buffers on a port \memberof pw_port */ /** Allocate memory for buffers on a port \memberof pw_port */

View file

@ -385,7 +385,7 @@ static void emit_port_info(struct stream *d)
info = SPA_PORT_INFO_INIT(); info = SPA_PORT_INFO_INIT();
info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS; 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.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
info.params = d->params; info.params = d->params;
info.n_params = 5; info.n_params = 5;
@ -601,12 +601,14 @@ static void clear_buffers(struct pw_stream *stream)
clear_queue(impl, &impl->queued); clear_queue(impl, &impl->queued);
} }
static int impl_port_use_buffers(void *object, enum spa_direction direction, uint32_t port_id, static int impl_port_use_buffers(void *object,
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 stream *impl = object; struct stream *impl = object;
struct pw_stream *stream = &impl->this; 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 prot, res;
int size = 0; int size = 0;
@ -621,7 +623,7 @@ static int impl_port_use_buffers(void *object, enum spa_direction direction, uin
b->flags = 0; b->flags = 0;
b->id = i; 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++) { for (j = 0; j < buffers[i]->n_datas; j++) {
struct spa_data *d = &buffers[i]->datas[j]; struct spa_data *d = &buffers[i]->datas[j];
if (d->type == SPA_DATA_MemFd || if (d->type == SPA_DATA_MemFd ||