node: Add port_info event

Add a port_info event. With this, we get updates to ports pushed to
us, which is more convenient and also allows for better dynamic
add/remove of ports.
We don't need to the PortChanged event anymore
We can remove the get_port_ids/get_n_ports/port_get_info methods.
Update plugins
This commit is contained in:
Wim Taymans 2019-02-14 17:08:46 +01:00
parent 3c78036a97
commit 21957e9e8d
37 changed files with 1068 additions and 2288 deletions

View file

@ -38,7 +38,6 @@ enum spa_node_event {
SPA_NODE_EVENT_Error,
SPA_NODE_EVENT_Buffering,
SPA_NODE_EVENT_RequestRefresh,
SPA_NODE_EVENT_PortsChanged,
};
#define SPA_NODE_EVENT_ID(ev) SPA_EVENT_ID(ev, SPA_TYPE_EVENT_Node)

View file

@ -47,14 +47,12 @@ struct spa_node;
* Contains the basic node information.
*/
struct spa_node_info {
#define SPA_VERSION_NODE_INFO 0
uint32_t version;
#define SPA_NODE_CHANGE_MASK_PROPS (1<<0)
uint64_t change_mask;
struct spa_dict *props;
};
#define SPA_NODE_INFO_INIT() (struct spa_node_info) { SPA_VERSION_NODE_INFO, }
#define SPA_NODE_INFO_INIT() (struct spa_node_info) { 0, }
/**
* Port information structure
@ -62,6 +60,11 @@ struct spa_node_info {
* Contains the basic port information.
*/
struct spa_port_info {
#define SPA_PORT_CHANGE_MASK_FLAGS (1<<0)
#define SPA_PORT_CHANGE_MASK_RATE (1<<1)
#define SPA_PORT_CHANGE_MASK_PROPS (1<<2)
uint64_t change_mask;
#define SPA_PORT_INFO_FLAG_REMOVABLE (1<<0) /**< port can be removed */
#define SPA_PORT_INFO_FLAG_OPTIONAL (1<<1) /**< processing on port is optional */
#define SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS (1<<2) /**< the port can allocate buffer data */
@ -81,6 +84,7 @@ struct spa_port_info {
const struct spa_dict *props; /**< extra port properties */
};
#define SPA_PORT_INFO_INIT() (struct spa_port_info) { 0, }
struct spa_node_callbacks {
#define SPA_VERSION_NODE_CALLBACKS 0
@ -89,6 +93,11 @@ struct spa_node_callbacks {
/** Emited when info changes */
void (*info) (void *data, const struct spa_node_info *info);
/** Emited when port info changes, NULL when port is removed */
void (*port_info) (void *data,
enum spa_direction direction, uint32_t port,
const struct spa_port_info *info);
/** Emited when an async operation completed.
*
* Will be called from the main thread. */
@ -249,44 +258,6 @@ struct spa_node {
int (*set_callbacks) (struct spa_node *node,
const struct spa_node_callbacks *callbacks,
void *data);
/**
* Get the current number of input and output ports and also the maximum
* number of ports.
*
* This function must be called from the main thread.
*
* \param node a spa_node
* \param n_input_ports location to hold the number of input ports or NULL
* \param max_input_ports location to hold the maximum number of input ports or NULL
* \param n_output_ports location to hold the number of output ports or NULL
* \param max_output_ports location to hold the maximum number of output ports or NULL
* \return 0 on success
* -EINVAL when node is NULL
*/
int (*get_n_ports) (struct spa_node *node,
uint32_t *n_input_ports,
uint32_t *max_input_ports,
uint32_t *n_output_ports,
uint32_t *max_output_ports);
/**
* Get the ids of the currently available ports.
*
* This function must be called from the main thread.
*
* \param node a #struct spa_node
* \param input_ids array to store the input stream ids
* \param n_input_ids size of the \a input_ids array
* \param output_ids array to store the output stream ids
* \param n_output_ids size of the \a output_ids array
* \return 0 on success
* -EINVAL when node is NULL
*/
int (*get_port_ids) (struct spa_node *node,
uint32_t *input_ids,
uint32_t n_input_ids,
uint32_t *output_ids,
uint32_t n_output_ids);
/**
* Make a new port with \a port_id. The caller should use get_port_ids() to
* find an unused id for the given \a direction.
@ -305,11 +276,6 @@ struct spa_node {
int (*remove_port) (struct spa_node *node, enum spa_direction direction, uint32_t port_id);
int (*port_get_info) (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
const struct spa_port_info **info);
/**
* Enumerate all possible parameters of \a id on \a port_id of \a node
* that are compatible with \a filter.
@ -509,11 +475,8 @@ struct spa_node {
#define spa_node_set_io(n,...) (n)->set_io((n),__VA_ARGS__)
#define spa_node_send_command(n,...) (n)->send_command((n),__VA_ARGS__)
#define spa_node_set_callbacks(n,...) (n)->set_callbacks((n),__VA_ARGS__)
#define spa_node_get_n_ports(n,...) (n)->get_n_ports((n),__VA_ARGS__)
#define spa_node_get_port_ids(n,...) (n)->get_port_ids((n),__VA_ARGS__)
#define spa_node_add_port(n,...) (n)->add_port((n),__VA_ARGS__)
#define spa_node_remove_port(n,...) (n)->remove_port((n),__VA_ARGS__)
#define spa_node_port_get_info(n,...) (n)->port_get_info((n),__VA_ARGS__)
#define spa_node_port_enum_params(n,...) (n)->port_enum_params((n),__VA_ARGS__)
#define spa_node_port_set_param(n,...) (n)->port_set_param((n),__VA_ARGS__)
#define spa_node_port_use_buffers(n,...) (n)->port_use_buffers((n),__VA_ARGS__)

View file

@ -57,7 +57,6 @@ static const struct spa_type_info spa_type_node_event_id[] = {
{ SPA_NODE_EVENT_Error, SPA_TYPE_Int, SPA_TYPE_INFO_NODE_EVENT_BASE "Error", NULL },
{ SPA_NODE_EVENT_Buffering, SPA_TYPE_Int, SPA_TYPE_INFO_NODE_EVENT_BASE "Buffering", NULL },
{ SPA_NODE_EVENT_RequestRefresh, SPA_TYPE_Int, SPA_TYPE_INFO_NODE_EVENT_BASE "RequestRefresh", NULL },
{ SPA_NODE_EVENT_PortsChanged, SPA_TYPE_Int, SPA_TYPE_INFO_NODE_EVENT_BASE "PortsChanged", NULL },
{ 0, 0, NULL, NULL },
};