mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
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:
parent
3c78036a97
commit
21957e9e8d
37 changed files with 1068 additions and 2288 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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__)
|
||||
|
|
|
|||
|
|
@ -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 },
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -242,6 +242,27 @@ static const struct spa_dict_item node_info_items[] = {
|
|||
{ "node.driver", "true" },
|
||||
};
|
||||
|
||||
static void emit_node_info(struct state *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
|
||||
|
||||
this->callbacks->info(this->callbacks_data, &info);
|
||||
}
|
||||
}
|
||||
|
||||
static void emit_port_info(struct state *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && this->info.change_mask) {
|
||||
this->callbacks->port_info(this->callbacks_data, SPA_DIRECTION_INPUT, 0, &this->info);
|
||||
this->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -256,58 +277,12 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
if (callbacks) {
|
||||
if (callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
|
||||
|
||||
callbacks->info(data, &info);
|
||||
}
|
||||
}
|
||||
emit_node_info(this);
|
||||
emit_port_info(this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 0;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ids > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
|
|
@ -318,24 +293,6 @@ static int impl_node_remove_port(struct spa_node *node, enum spa_direction direc
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id, const struct spa_port_info **info)
|
||||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
|
@ -505,7 +462,9 @@ static int port_set_format(struct spa_node *node,
|
|||
}
|
||||
|
||||
if (this->have_format) {
|
||||
this->info.change_mask |= SPA_PORT_CHANGE_MASK_RATE;
|
||||
this->info.rate = this->rate;
|
||||
emit_port_info(this);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -677,23 +636,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -760,6 +716,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->stream = SND_PCM_STREAM_PLAYBACK;
|
||||
reset_props(&this->props);
|
||||
|
||||
this->info = SPA_PORT_INFO_INIT();
|
||||
this->info.change_mask |= SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_LIVE |
|
||||
SPA_PORT_INFO_FLAG_PHYSICAL |
|
||||
|
|
|
|||
|
|
@ -243,6 +243,27 @@ static const struct spa_dict_item node_info_items[] = {
|
|||
{ "node.driver", "true" },
|
||||
};
|
||||
|
||||
static void emit_node_info(struct state *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
|
||||
|
||||
this->callbacks->info(this->callbacks_data, &info);
|
||||
}
|
||||
}
|
||||
|
||||
static void emit_port_info(struct state *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && this->info.change_mask) {
|
||||
this->callbacks->port_info(this->callbacks_data, SPA_DIRECTION_OUTPUT, 0, &this->info);
|
||||
this->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -257,57 +278,12 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
if (callbacks) {
|
||||
if (callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
|
||||
|
||||
callbacks->info(data, &info);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 0;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
emit_node_info(this);
|
||||
emit_port_info(this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_output_ids > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
|
|
@ -318,24 +294,6 @@ static int impl_node_remove_port(struct spa_node *node, enum spa_direction direc
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id, const struct spa_port_info **info)
|
||||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void recycle_buffer(struct state *this, uint32_t buffer_id)
|
||||
{
|
||||
struct buffer *b = &this->buffers[buffer_id];
|
||||
|
|
@ -508,6 +466,8 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (this->have_format) {
|
||||
this->info.rate = this->rate;
|
||||
this->info.change_mask |= SPA_PORT_CHANGE_MASK_RATE;
|
||||
emit_port_info(this);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -685,23 +645,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -772,6 +729,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->stream = SND_PCM_STREAM_CAPTURE;
|
||||
reset_props(&this->props);
|
||||
|
||||
this->info = SPA_PORT_INFO_INIT();
|
||||
this->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_LIVE |
|
||||
SPA_PORT_INFO_FLAG_PHYSICAL |
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ struct buffer {
|
|||
struct link {
|
||||
struct spa_node *out_node;
|
||||
uint32_t out_port;
|
||||
const struct spa_port_info *out_info;
|
||||
uint32_t out_flags;
|
||||
struct spa_node *in_node;
|
||||
uint32_t in_port;
|
||||
const struct spa_port_info *in_info;
|
||||
uint32_t in_flags;
|
||||
struct spa_io_buffers io;
|
||||
bool negotiated;
|
||||
uint32_t n_buffers;
|
||||
|
|
@ -104,17 +104,13 @@ static int make_link(struct impl *this,
|
|||
l->io.status = SPA_STATUS_NEED_BUFFER;
|
||||
l->io.buffer_id = SPA_ID_INVALID;
|
||||
l->n_buffers = 0;
|
||||
l->out_flags = 0;
|
||||
l->in_flags = 0;
|
||||
|
||||
spa_node_port_get_info(out_node,
|
||||
SPA_DIRECTION_OUTPUT, out_port,
|
||||
&l->out_info);
|
||||
spa_node_port_set_io(out_node,
|
||||
SPA_DIRECTION_OUTPUT, out_port,
|
||||
SPA_IO_Buffers,
|
||||
&l->io, sizeof(l->io));
|
||||
spa_node_port_get_info(in_node,
|
||||
SPA_DIRECTION_INPUT, in_port,
|
||||
&l->in_info);
|
||||
spa_node_port_set_io(in_node,
|
||||
SPA_DIRECTION_INPUT, in_port,
|
||||
SPA_IO_Buffers,
|
||||
|
|
@ -287,17 +283,10 @@ static int negotiate_link_buffers(struct impl *this, struct link *link)
|
|||
|
||||
spa_pod_fixate(param);
|
||||
|
||||
if (link->in_info)
|
||||
in_alloc = SPA_FLAG_CHECK(link->in_info->flags,
|
||||
in_alloc = SPA_FLAG_CHECK(link->in_flags,
|
||||
SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS);
|
||||
else
|
||||
in_alloc = false;
|
||||
|
||||
if (link->out_info)
|
||||
out_alloc = SPA_FLAG_CHECK(link->out_info->flags,
|
||||
out_alloc = SPA_FLAG_CHECK(link->out_flags,
|
||||
SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS);
|
||||
else
|
||||
out_alloc = false;
|
||||
|
||||
flags = 0;
|
||||
if (out_alloc || in_alloc) {
|
||||
|
|
@ -514,9 +503,6 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
res = -EINVAL;
|
||||
break;
|
||||
}
|
||||
if (this->callbacks && this->callbacks->event)
|
||||
this->callbacks->event(this->user_data,
|
||||
&SPA_NODE_EVENT_INIT(SPA_NODE_EVENT_PortsChanged));
|
||||
break;
|
||||
}
|
||||
case SPA_PARAM_Props:
|
||||
|
|
@ -555,6 +541,49 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this,
|
||||
enum spa_direction direction, uint32_t port,
|
||||
const struct spa_port_info *info)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info)
|
||||
this->callbacks->port_info(this->user_data, direction, port, info);
|
||||
}
|
||||
|
||||
|
||||
static void fmt_input_port_info(void *data,
|
||||
enum spa_direction direction, uint32_t port,
|
||||
const struct spa_port_info *info)
|
||||
{
|
||||
struct impl *this = data;
|
||||
|
||||
if (direction != SPA_DIRECTION_INPUT)
|
||||
return;
|
||||
|
||||
emit_port_info(this, direction, port, info);
|
||||
}
|
||||
|
||||
static struct spa_node_callbacks fmt_input_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
.port_info = fmt_input_port_info
|
||||
};
|
||||
|
||||
static void fmt_output_port_info(void *data,
|
||||
enum spa_direction direction, uint32_t port,
|
||||
const struct spa_port_info *info)
|
||||
{
|
||||
struct impl *this = data;
|
||||
|
||||
if (direction != SPA_DIRECTION_OUTPUT)
|
||||
return;
|
||||
|
||||
emit_port_info(this, direction, port, info);
|
||||
}
|
||||
|
||||
static struct spa_node_callbacks fmt_output_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
.port_info = fmt_output_port_info
|
||||
};
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -569,43 +598,8 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_node_get_n_ports(this->fmt[SPA_DIRECTION_INPUT], n_input_ports, max_input_ports, NULL, NULL);
|
||||
spa_node_get_n_ports(this->fmt[SPA_DIRECTION_OUTPUT], NULL, NULL, n_output_ports, max_output_ports);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_node_get_port_ids(this->fmt[SPA_DIRECTION_INPUT], input_ids, n_input_ids, NULL, 0);
|
||||
spa_node_get_port_ids(this->fmt[SPA_DIRECTION_OUTPUT], NULL, 0, output_ids, n_output_ids);
|
||||
spa_node_set_callbacks(this->fmt[SPA_DIRECTION_INPUT], &fmt_input_callbacks, this);
|
||||
spa_node_set_callbacks(this->fmt[SPA_DIRECTION_OUTPUT], &fmt_output_callbacks, this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -633,22 +627,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return spa_node_remove_port(this->fmt[direction], direction, port_id);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
return spa_node_port_get_info(this->fmt[direction], direction, port_id, info);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
|
@ -875,23 +853,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ struct buffer {
|
|||
};
|
||||
|
||||
struct port {
|
||||
uint32_t direction;
|
||||
uint32_t id;
|
||||
|
||||
struct spa_io_buffers *io;
|
||||
|
|
@ -582,6 +583,14 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this, struct port *port)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && port->info.change_mask) {
|
||||
this->callbacks->port_info(this->user_data, port->direction, port->id, &port->info);
|
||||
port->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -596,43 +605,8 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ids && input_ids)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ids > 0 && output_ids)
|
||||
output_ids[0] = 0;
|
||||
emit_port_info(this, GET_IN_PORT(this, 0));
|
||||
emit_port_info(this, GET_OUT_PORT(this, 0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -648,28 +622,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -1156,23 +1108,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -1240,12 +1189,18 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->node = impl_node;
|
||||
|
||||
port = GET_OUT_PORT(this, 0);
|
||||
port->direction = SPA_DIRECTION_OUTPUT;
|
||||
port->id = 0;
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
spa_list_init(&port->queue);
|
||||
|
||||
port = GET_IN_PORT(this, 0);
|
||||
port->direction = SPA_DIRECTION_INPUT;
|
||||
port->id = 0;
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
spa_list_init(&port->queue);
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ struct buffer {
|
|||
};
|
||||
|
||||
struct port {
|
||||
uint32_t direction;
|
||||
uint32_t id;
|
||||
|
||||
struct spa_io_buffers *io;
|
||||
|
|
@ -228,6 +229,14 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this, struct port *port)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && port->info.change_mask) {
|
||||
this->callbacks->port_info(this->user_data, port->direction, port->id, &port->info);
|
||||
port->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -242,43 +251,8 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (input_ids && n_input_ids > 0)
|
||||
input_ids[0] = 0;
|
||||
if (output_ids && n_output_ids > 0)
|
||||
output_ids[0] = 0;
|
||||
emit_port_info(this, GET_IN_PORT(this, 0));
|
||||
emit_port_info(this, GET_OUT_PORT(this, 0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -294,28 +268,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int int32_cmp(const void *v1, const void *v2)
|
||||
{
|
||||
return *(int32_t*)v1 - *(int32_t*)v2;
|
||||
|
|
@ -899,23 +851,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -945,15 +894,19 @@ static int init_port(struct impl *this, enum spa_direction direction, uint32_t p
|
|||
struct port *port;
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
port->direction = direction;
|
||||
port->id = port_id;
|
||||
|
||||
spa_list_init(&port->queue);
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PROPS;
|
||||
port->info.flags = flags;
|
||||
|
||||
port->info_props_items[0] = SPA_DICT_ITEM_INIT("port.dsp", "32 bit float mono audio");
|
||||
port->info_props = SPA_DICT_INIT(port->info_props_items, 1);
|
||||
port->info.props = &port->info_props;
|
||||
port->have_format = false;
|
||||
emit_port_info(this, port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ struct buffer {
|
|||
};
|
||||
|
||||
struct port {
|
||||
uint32_t direction;
|
||||
uint32_t id;
|
||||
|
||||
struct spa_io_buffers *io;
|
||||
|
|
@ -112,16 +113,35 @@ struct impl {
|
|||
|
||||
#define PORT_IS_DSP(d,p) (p != 0 || d != SPA_DIRECTION_OUTPUT)
|
||||
|
||||
static void emit_node_info(struct impl *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->info) {
|
||||
struct spa_node_info info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = 0;
|
||||
this->callbacks->info(this->user_data, &info);
|
||||
}
|
||||
}
|
||||
static void emit_port_info(struct impl *this, struct port *port)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && port->info.change_mask) {
|
||||
this->callbacks->port_info(this->user_data, port->direction, port->id, &port->info);
|
||||
port->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int init_port(struct impl *this, enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t rate, uint32_t position)
|
||||
{
|
||||
struct port *port = GET_PORT(this, direction, port_id);
|
||||
int n_items = 0;
|
||||
|
||||
port->direction = direction;
|
||||
port->id = port_id;
|
||||
|
||||
snprintf(port->position, 16, "%s", rindex(spa_type_audio_channel[position].name, ':')+1);
|
||||
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PROPS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
port->info_props_items[n_items++] = SPA_DICT_ITEM_INIT("port.dsp", "32 bit float mono audio");
|
||||
port->info_props_items[n_items++] = SPA_DICT_ITEM_INIT("port.channel", port->position);
|
||||
|
|
@ -141,6 +161,7 @@ static int init_port(struct impl *this, enum spa_direction direction, uint32_t p
|
|||
spa_list_init(&port->queue);
|
||||
|
||||
spa_log_debug(this->log, NAME " %p: add port %d", this, port_id);
|
||||
emit_port_info(this, port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -232,6 +253,14 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
spa_log_debug(this->log, NAME " %p: profile %d/%d", this,
|
||||
info.info.raw.rate, info.info.raw.channels);
|
||||
|
||||
if (this->callbacks && this->callbacks->port_info) {
|
||||
for (i = 0; i < this->port_count; i++) {
|
||||
this->callbacks->port_info(this->user_data, SPA_DIRECTION_INPUT, i, NULL);
|
||||
if (this->monitor)
|
||||
this->callbacks->port_info(this->user_data, SPA_DIRECTION_OUTPUT, i+1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
port->have_format = true;
|
||||
port->format = info;
|
||||
|
||||
|
|
@ -245,11 +274,6 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
init_port(this, SPA_DIRECTION_OUTPUT, i+1, info.info.raw.rate,
|
||||
info.info.raw.position[i]);
|
||||
}
|
||||
|
||||
if (this->callbacks && this->callbacks->event)
|
||||
this->callbacks->event(this->user_data,
|
||||
&SPA_NODE_EVENT_INIT(SPA_NODE_EVENT_PortsChanged));
|
||||
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
|
|
@ -286,6 +310,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
void *user_data)
|
||||
{
|
||||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
|
|
@ -294,58 +319,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
emit_node_info(this);
|
||||
emit_port_info(this, GET_OUT_PORT(this, 0));
|
||||
for (i = 0; i < this->port_count; i++)
|
||||
emit_port_info(this, GET_IN_PORT(this, i));
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = this->port_count;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = this->port_count;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = this->monitor_count + 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = this->monitor_count + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (input_ids) {
|
||||
n_input_ids = SPA_MIN(n_input_ids, this->port_count);
|
||||
for (i = 0; i < n_input_ids; i++)
|
||||
input_ids[i] = i;
|
||||
}
|
||||
if (output_ids) {
|
||||
n_output_ids = SPA_MIN(n_output_ids, this->monitor_count + 1);
|
||||
for (i = 0; i < n_output_ids; i++)
|
||||
output_ids[i] = i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -362,28 +340,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -998,23 +954,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -1086,7 +1039,10 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->node = impl_node;
|
||||
|
||||
port = GET_OUT_PORT(this, 0);
|
||||
port->direction = SPA_DIRECTION_OUTPUT;
|
||||
port->id = 0;
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
spa_list_init(&port->queue);
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ struct buffer {
|
|||
};
|
||||
|
||||
struct port {
|
||||
uint32_t direction;
|
||||
uint32_t id;
|
||||
|
||||
struct spa_io_buffers *io;
|
||||
|
|
@ -231,6 +232,14 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this, struct port *port)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && port->info.change_mask) {
|
||||
this->callbacks->port_info(this->user_data, port->direction, port->id, &port->info);
|
||||
port->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -245,43 +254,8 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ids && input_ids)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ids > 0 && output_ids)
|
||||
output_ids[0] = 0;
|
||||
emit_port_info(this, GET_IN_PORT(this, 0));
|
||||
emit_port_info(this, GET_OUT_PORT(this, 0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -297,28 +271,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -836,23 +788,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -932,12 +881,18 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->node = impl_node;
|
||||
|
||||
port = GET_OUT_PORT(this, 0);
|
||||
port->direction = SPA_DIRECTION_OUTPUT;
|
||||
port->id = 0;
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
spa_list_init(&port->queue);
|
||||
|
||||
port = GET_IN_PORT(this, 0);
|
||||
port->direction = SPA_DIRECTION_INPUT;
|
||||
port->id = 0;
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
spa_list_init(&port->queue);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ struct buffer {
|
|||
};
|
||||
|
||||
struct port {
|
||||
uint32_t direction;
|
||||
uint32_t id;
|
||||
|
||||
struct spa_io_buffers *io;
|
||||
|
|
@ -110,14 +111,34 @@ struct impl {
|
|||
#define GET_OUT_PORT(this,p) (&this->out_ports[p])
|
||||
#define GET_PORT(this,d,p) (d == SPA_DIRECTION_INPUT ? GET_IN_PORT(this,p) : GET_OUT_PORT(this,p))
|
||||
|
||||
static int init_port(struct impl *this, uint32_t port_id, uint32_t rate, uint32_t position)
|
||||
static void emit_node_info(struct impl *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->info) {
|
||||
struct spa_node_info info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = 0;
|
||||
this->callbacks->info(this->user_data, &info);
|
||||
}
|
||||
}
|
||||
static void emit_port_info(struct impl *this, struct port *port)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && port->info.change_mask) {
|
||||
this->callbacks->port_info(this->user_data, port->direction, port->id, &port->info);
|
||||
port->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int init_port(struct impl *this, enum spa_direction direction,
|
||||
uint32_t port_id, uint32_t rate, uint32_t position)
|
||||
{
|
||||
struct port *port = GET_OUT_PORT(this, port_id);
|
||||
|
||||
port->direction = direction;
|
||||
port->id = port_id;
|
||||
|
||||
snprintf(port->position, 7, "%s", rindex(spa_type_audio_channel[position].name, ':')+1);
|
||||
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PROPS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
port->info_props_items[0] = SPA_DICT_ITEM_INIT("port.dsp", "32 bit float mono audio");
|
||||
port->info_props_items[1] = SPA_DICT_ITEM_INIT("port.channel", port->position);
|
||||
|
|
@ -136,6 +157,7 @@ static int init_port(struct impl *this, uint32_t port_id, uint32_t rate, uint32_
|
|||
port->format.info.raw.position[0] = position;
|
||||
|
||||
spa_log_debug(this->log, NAME " %p: init port %d %s", this, port_id, port->position);
|
||||
emit_port_info(this, port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -226,18 +248,19 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
|
||||
spa_log_debug(this->log, NAME " %p: profile %d", this, info.info.raw.channels);
|
||||
|
||||
this->have_profile = true;
|
||||
this->port_count = info.info.raw.channels;
|
||||
for (i = 0; i < this->port_count; i++) {
|
||||
init_port(this, i, info.info.raw.rate,
|
||||
info.info.raw.position[i]);
|
||||
if (this->callbacks && this->callbacks->port_info)
|
||||
this->callbacks->port_info(this->user_data, SPA_DIRECTION_OUTPUT, i, NULL);
|
||||
}
|
||||
this->have_profile = true;
|
||||
port->have_format = true;
|
||||
port->format = info;
|
||||
|
||||
if (this->callbacks && this->callbacks->event)
|
||||
this->callbacks->event(this->user_data,
|
||||
&SPA_NODE_EVENT_INIT(SPA_NODE_EVENT_PortsChanged));
|
||||
this->port_count = info.info.raw.channels;
|
||||
for (i = 0; i < this->port_count; i++) {
|
||||
init_port(this, SPA_DIRECTION_OUTPUT, i, info.info.raw.rate,
|
||||
info.info.raw.position[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
|
|
@ -274,6 +297,7 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
void *user_data)
|
||||
{
|
||||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
|
|
@ -282,55 +306,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
emit_node_info(this);
|
||||
emit_port_info(this, GET_IN_PORT(this, 0));
|
||||
for (i = 0; i < this->port_count; i++)
|
||||
emit_port_info(this, GET_OUT_PORT(this, i));
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = this->port_count;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = this->port_count;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (n_input_ids > 0 && input_ids)
|
||||
input_ids[0] = 0;
|
||||
if (output_ids) {
|
||||
n_output_ids = SPA_MIN(n_output_ids, this->port_count);
|
||||
for (i = 0; i < n_output_ids; i++)
|
||||
output_ids[i] = i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -347,29 +327,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
*info = &port->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -931,23 +888,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -1014,7 +968,10 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->node = impl_node;
|
||||
|
||||
port = GET_IN_PORT(this, 0);
|
||||
port->direction = SPA_DIRECTION_INPUT;
|
||||
port->id = 0;
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ struct buffer {
|
|||
};
|
||||
|
||||
struct port {
|
||||
bool valid;
|
||||
uint32_t direction;
|
||||
uint32_t id;
|
||||
|
||||
struct port_props props;
|
||||
|
|
@ -78,7 +78,8 @@ struct port {
|
|||
|
||||
struct spa_port_info info;
|
||||
|
||||
bool have_format;
|
||||
int valid:1;
|
||||
int have_format:1;
|
||||
|
||||
struct buffer buffers[MAX_BUFFERS];
|
||||
uint32_t n_buffers;
|
||||
|
|
@ -167,12 +168,21 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this, struct port *port)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && port->info.change_mask) {
|
||||
this->callbacks->port_info(this->user_data, port->direction, port->id, &port->info);
|
||||
port->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
{
|
||||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
|
|
@ -181,56 +191,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = this->port_count;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = MAX_PORTS;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct impl *this;
|
||||
uint32_t i, idx;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (input_ids) {
|
||||
for (i = 0, idx = 0; i < this->last_port && idx < n_input_ids; i++) {
|
||||
if (this->in_ports[i].valid)
|
||||
input_ids[idx++] = i;
|
||||
}
|
||||
emit_port_info(this, GET_OUT_PORT(this, 0));
|
||||
for (i = 0; i < this->last_port; i++) {
|
||||
if (this->in_ports[i].valid)
|
||||
emit_port_info(this, GET_IN_PORT(this, i));
|
||||
}
|
||||
if (n_output_ids > 0 && output_ids)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -246,8 +211,9 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio
|
|||
|
||||
spa_return_val_if_fail(CHECK_FREE_IN_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_IN_PORT (this, port_id);
|
||||
port = GET_IN_PORT(this, port_id);
|
||||
port->valid = true;
|
||||
port->direction = SPA_DIRECTION_INPUT;
|
||||
port->id = port_id;
|
||||
|
||||
port_props_reset(&port->props);
|
||||
|
|
@ -255,6 +221,8 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio
|
|||
port->io_mute = &port->props.mute;
|
||||
|
||||
spa_list_init(&port->queue);
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_REMOVABLE |
|
||||
SPA_PORT_INFO_FLAG_OPTIONAL |
|
||||
|
|
@ -265,6 +233,7 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio
|
|||
this->last_port = port_id + 1;
|
||||
|
||||
spa_log_info(this->log, NAME " %p: add port %d", this, port_id);
|
||||
emit_port_info(this, port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -281,7 +250,7 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
|
||||
spa_return_val_if_fail(CHECK_IN_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_IN_PORT (this, port_id);
|
||||
port = GET_IN_PORT(this, port_id);
|
||||
|
||||
this->port_count--;
|
||||
if (port->have_format && this->have_format) {
|
||||
|
|
@ -300,28 +269,8 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
this->last_port = i + 1;
|
||||
}
|
||||
spa_log_info(this->log, NAME " %p: remove port %d", this, port_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
if (this->callbacks && this->callbacks->port_info)
|
||||
this->callbacks->port_info(this->user_data, direction, port_id, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -902,23 +851,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -978,6 +924,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
port = GET_OUT_PORT(this, 0);
|
||||
port->valid = true;
|
||||
port->direction = SPA_DIRECTION_OUTPUT;
|
||||
port->id = 0;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
|
|
|
|||
|
|
@ -448,6 +448,27 @@ static const struct spa_dict_item node_info_items[] = {
|
|||
{ "media.class", "Audio/Source" },
|
||||
};
|
||||
|
||||
static void emit_node_info(struct impl *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
|
||||
|
||||
this->callbacks->info(this->callbacks_data, &info);
|
||||
}
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && this->info.change_mask) {
|
||||
this->callbacks->port_info(this->callbacks_data, SPA_DIRECTION_OUTPUT, 0, &this->info);
|
||||
this->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -462,53 +483,8 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
if (callbacks) {
|
||||
if (callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
|
||||
|
||||
callbacks->info(data, &info);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 0;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_output_ids > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
emit_node_info(this);
|
||||
emit_port_info(this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -524,26 +500,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
port_enum_formats(struct impl *this,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
|
@ -965,23 +921,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -1066,6 +1019,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
||||
this->info = SPA_PORT_INFO_INIT();
|
||||
this->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_NO_REF;
|
||||
if (this->props.live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
|
|
|||
|
|
@ -846,6 +846,27 @@ static const struct spa_dict_item node_info_items[] = {
|
|||
{ "node.driver", "true" },
|
||||
};
|
||||
|
||||
static void emit_node_info(struct impl *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
|
||||
|
||||
this->callbacks->info(this->callbacks_data, &info);
|
||||
}
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && this->info.change_mask) {
|
||||
this->callbacks->port_info(this->callbacks_data, SPA_DIRECTION_INPUT, 0, &this->info);
|
||||
this->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -860,58 +881,12 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
if (callbacks) {
|
||||
if (callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
|
||||
|
||||
callbacks->info(data, &info);
|
||||
}
|
||||
}
|
||||
emit_node_info(this);
|
||||
emit_port_info(this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 0;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ids > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
|
|
@ -922,24 +897,6 @@ static int impl_node_remove_port(struct spa_node *node, enum spa_direction direc
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id, const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
|
@ -1289,23 +1246,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ struct impl {
|
|||
bool started;
|
||||
};
|
||||
|
||||
static int spa_ffmpeg_dec_node_enum_params(struct spa_node *node,
|
||||
static int impl_node_enum_params(struct spa_node *node,
|
||||
uint32_t id, uint32_t *index,
|
||||
const struct spa_pod *filter,
|
||||
struct spa_pod **result,
|
||||
|
|
@ -81,19 +81,19 @@ static int spa_ffmpeg_dec_node_enum_params(struct spa_node *node,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_set_param(struct spa_node *node,
|
||||
static int impl_node_set_param(struct spa_node *node,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_set_io(struct spa_node *node, uint32_t id, void *data, size_t size)
|
||||
static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size_t size)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -115,8 +115,18 @@ static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, const struct
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this, enum spa_direction direction, uint32_t id)
|
||||
{
|
||||
struct port *port = GET_PORT(this, direction, id);
|
||||
|
||||
if (this->callbacks && this->callbacks->port_info && port->info.change_mask) {
|
||||
this->callbacks->port_info(this->user_data, direction, id, &port->info);
|
||||
port->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_set_callbacks(struct spa_node *node,
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
{
|
||||
|
|
@ -130,88 +140,26 @@ spa_ffmpeg_dec_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_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)
|
||||
{
|
||||
if (node == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
emit_port_info(this, SPA_DIRECTION_INPUT, 0);
|
||||
emit_port_info(this, SPA_DIRECTION_OUTPUT, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_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)
|
||||
{
|
||||
if (node == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ids > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ids > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_remove_port(struct spa_node *node,
|
||||
impl_node_remove_port(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
if (node == NULL || info == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return -EINVAL;
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
*info = &port->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -263,7 +211,7 @@ static int port_get_format(struct spa_node *node,
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node,
|
||||
impl_node_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t id, uint32_t *index,
|
||||
const struct spa_pod *filter,
|
||||
|
|
@ -358,7 +306,7 @@ static int port_set_format(struct spa_node *node,
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_set_param(struct spa_node *node,
|
||||
impl_node_port_set_param(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
|
|
@ -371,7 +319,7 @@ spa_ffmpeg_dec_node_port_set_param(struct spa_node *node,
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_use_buffers(struct spa_node *node,
|
||||
impl_node_port_use_buffers(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_buffer **buffers,
|
||||
|
|
@ -387,7 +335,7 @@ spa_ffmpeg_dec_node_port_use_buffers(struct spa_node *node,
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_alloc_buffers(struct spa_node *node,
|
||||
impl_node_port_alloc_buffers(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_pod **params,
|
||||
|
|
@ -399,7 +347,7 @@ spa_ffmpeg_dec_node_port_alloc_buffers(struct spa_node *node,
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_set_io(struct spa_node *node,
|
||||
impl_node_port_set_io(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t id,
|
||||
|
|
@ -426,7 +374,7 @@ spa_ffmpeg_dec_node_port_set_io(struct spa_node *node,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_process(struct spa_node *node)
|
||||
static int impl_node_process(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
|
@ -452,7 +400,7 @@ static int spa_ffmpeg_dec_node_process(struct spa_node *node)
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
if (node == NULL)
|
||||
return -EINVAL;
|
||||
|
|
@ -463,29 +411,26 @@ spa_ffmpeg_dec_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, u
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static const struct spa_node ffmpeg_dec_node = {
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
spa_ffmpeg_dec_node_enum_params,
|
||||
spa_ffmpeg_dec_node_set_param,
|
||||
spa_ffmpeg_dec_node_set_io,
|
||||
spa_ffmpeg_dec_node_send_command,
|
||||
spa_ffmpeg_dec_node_set_callbacks,
|
||||
spa_ffmpeg_dec_node_get_n_ports,
|
||||
spa_ffmpeg_dec_node_get_port_ids,
|
||||
spa_ffmpeg_dec_node_add_port,
|
||||
spa_ffmpeg_dec_node_remove_port,
|
||||
spa_ffmpeg_dec_node_port_get_info,
|
||||
spa_ffmpeg_dec_node_port_enum_params,
|
||||
spa_ffmpeg_dec_node_port_set_param,
|
||||
spa_ffmpeg_dec_node_port_use_buffers,
|
||||
spa_ffmpeg_dec_node_port_alloc_buffers,
|
||||
spa_ffmpeg_dec_node_port_set_io,
|
||||
spa_ffmpeg_dec_node_port_reuse_buffer,
|
||||
spa_ffmpeg_dec_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -509,9 +454,10 @@ spa_ffmpeg_dec_init(struct spa_handle *handle,
|
|||
uint32_t n_support)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
uint32_t i;
|
||||
|
||||
handle->get_interface = spa_ffmpeg_dec_get_interface;
|
||||
handle->get_interface = impl_get_interface;
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -520,10 +466,17 @@ spa_ffmpeg_dec_init(struct spa_handle *handle,
|
|||
this->log = support[i].data;
|
||||
}
|
||||
|
||||
this->node = ffmpeg_dec_node;
|
||||
this->node = impl_node;
|
||||
|
||||
this->in_ports[0].info.flags = 0;
|
||||
this->out_ports[0].info.flags = 0;
|
||||
port = GET_IN_PORT(this, 0);
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = 0;
|
||||
|
||||
port = GET_OUT_PORT(this, 0);
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ struct impl {
|
|||
bool started;
|
||||
};
|
||||
|
||||
static int spa_ffmpeg_enc_node_enum_params(struct spa_node *node,
|
||||
static int impl_node_enum_params(struct spa_node *node,
|
||||
uint32_t id, uint32_t *index,
|
||||
const struct spa_pod *filter,
|
||||
struct spa_pod **param,
|
||||
|
|
@ -84,18 +84,18 @@ static int spa_ffmpeg_enc_node_enum_params(struct spa_node *node,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_set_io(struct spa_node *node, uint32_t id, void *data, size_t size)
|
||||
static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size_t size)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -117,8 +117,18 @@ static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, const struct
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this, enum spa_direction direction, uint32_t id)
|
||||
{
|
||||
struct port *port = GET_PORT(this, direction, id);
|
||||
|
||||
if (this->callbacks && this->callbacks->port_info && port->info.change_mask) {
|
||||
this->callbacks->port_info(this->user_data, direction, id, &port->info);
|
||||
port->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_set_callbacks(struct spa_node *node,
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
{
|
||||
|
|
@ -132,85 +142,25 @@ spa_ffmpeg_enc_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_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)
|
||||
{
|
||||
if (node == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
emit_port_info(this, SPA_DIRECTION_INPUT, 0);
|
||||
emit_port_info(this, SPA_DIRECTION_OUTPUT, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_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)
|
||||
{
|
||||
if (node == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ids > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ids > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_remove_port(struct spa_node *node,
|
||||
impl_node_remove_port(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id, const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
if (node == NULL || info == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return -EINVAL;
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -252,7 +202,7 @@ static int port_get_format(struct spa_node *node,
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_port_enum_params(struct spa_node *node,
|
||||
impl_node_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t id, uint32_t *index,
|
||||
const struct spa_pod *filter,
|
||||
|
|
@ -338,7 +288,7 @@ static int port_set_format(struct spa_node *node,
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_port_set_param(struct spa_node *node,
|
||||
impl_node_port_set_param(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
|
|
@ -351,7 +301,7 @@ spa_ffmpeg_enc_node_port_set_param(struct spa_node *node,
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_port_use_buffers(struct spa_node *node,
|
||||
impl_node_port_use_buffers(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_buffer **buffers, uint32_t n_buffers)
|
||||
|
|
@ -366,7 +316,7 @@ spa_ffmpeg_enc_node_port_use_buffers(struct spa_node *node,
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_port_alloc_buffers(struct spa_node *node,
|
||||
impl_node_port_alloc_buffers(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_pod **params,
|
||||
|
|
@ -378,7 +328,7 @@ spa_ffmpeg_enc_node_port_alloc_buffers(struct spa_node *node,
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_port_set_io(struct spa_node *node,
|
||||
impl_node_port_set_io(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t id,
|
||||
|
|
@ -406,7 +356,7 @@ spa_ffmpeg_enc_node_port_set_io(struct spa_node *node,
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
if (node == NULL)
|
||||
return -EINVAL;
|
||||
|
|
@ -417,7 +367,7 @@ spa_ffmpeg_enc_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, u
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_process(struct spa_node *node)
|
||||
static int impl_node_process(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
|
@ -442,29 +392,26 @@ static int spa_ffmpeg_enc_node_process(struct spa_node *node)
|
|||
return SPA_STATUS_OK;
|
||||
}
|
||||
|
||||
static const struct spa_node ffmpeg_enc_node = {
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
spa_ffmpeg_enc_node_enum_params,
|
||||
spa_ffmpeg_enc_node_set_param,
|
||||
spa_ffmpeg_enc_node_set_io,
|
||||
spa_ffmpeg_enc_node_send_command,
|
||||
spa_ffmpeg_enc_node_set_callbacks,
|
||||
spa_ffmpeg_enc_node_get_n_ports,
|
||||
spa_ffmpeg_enc_node_get_port_ids,
|
||||
spa_ffmpeg_enc_node_add_port,
|
||||
spa_ffmpeg_enc_node_remove_port,
|
||||
spa_ffmpeg_enc_node_port_get_info,
|
||||
spa_ffmpeg_enc_node_port_enum_params,
|
||||
spa_ffmpeg_enc_node_port_set_param,
|
||||
spa_ffmpeg_enc_node_port_use_buffers,
|
||||
spa_ffmpeg_enc_node_port_alloc_buffers,
|
||||
spa_ffmpeg_enc_node_port_set_io,
|
||||
spa_ffmpeg_enc_node_port_reuse_buffer,
|
||||
spa_ffmpeg_enc_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -487,9 +434,10 @@ spa_ffmpeg_enc_init(struct spa_handle *handle,
|
|||
const struct spa_support *support, uint32_t n_support)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
uint32_t i;
|
||||
|
||||
handle->get_interface = spa_ffmpeg_enc_get_interface;
|
||||
handle->get_interface = impl_get_interface;
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -498,10 +446,17 @@ spa_ffmpeg_enc_init(struct spa_handle *handle,
|
|||
this->log = support[i].data;
|
||||
}
|
||||
|
||||
this->node = ffmpeg_enc_node;
|
||||
this->node = impl_node;
|
||||
|
||||
this->in_ports[0].info.flags = 0;
|
||||
this->out_ports[0].info.flags = 0;
|
||||
port = GET_IN_PORT(this, 0);
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = 0;
|
||||
|
||||
port = GET_OUT_PORT(this, 0);
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,6 +323,14 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && this->info.change_mask) {
|
||||
this->callbacks->port_info(this->callbacks_data, SPA_DIRECTION_INPUT, 0, &this->info);
|
||||
this->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -334,48 +342,14 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks != NULL && callbacks->process != NULL) {
|
||||
if (this->data_loop == NULL && callbacks != NULL && callbacks->ready != NULL) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return -EINVAL;
|
||||
}
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 0;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ids > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
emit_port_info(this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -391,26 +365,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -702,23 +656,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -803,6 +754,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
||||
this->info = SPA_PORT_INFO_INIT();
|
||||
this->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_NO_REF;
|
||||
if (this->props.live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
|
|
|||
|
|
@ -339,6 +339,14 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && this->info.change_mask) {
|
||||
this->callbacks->port_info(this->callbacks_data, SPA_DIRECTION_OUTPUT, 0, &this->info);
|
||||
this->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -350,48 +358,14 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && (callbacks != NULL && callbacks->process != NULL)) {
|
||||
if (this->data_loop == NULL && (callbacks != NULL && callbacks->ready != NULL)) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return -EINVAL;
|
||||
}
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 0;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_output_ids > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
emit_port_info(this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -407,26 +381,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -737,23 +691,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -838,6 +789,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
||||
this->info = SPA_PORT_INFO_INIT();
|
||||
this->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_NO_REF;
|
||||
if (this->props.live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
|
|
|||
|
|
@ -332,6 +332,25 @@ static const struct spa_dict_item info_items[] = {
|
|||
{ "node.driver", "true" },
|
||||
};
|
||||
|
||||
static void emit_node_info(struct impl *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(info_items);
|
||||
|
||||
this->callbacks->info(this->callbacks_data, &info);
|
||||
}
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this, struct port *port)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info)
|
||||
this->callbacks->port_info(this->callbacks_data, SPA_DIRECTION_OUTPUT, 0, &port->info);
|
||||
}
|
||||
|
||||
static int impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *data)
|
||||
|
|
@ -345,56 +364,12 @@ static int impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
if (callbacks) {
|
||||
if (callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(info_items);
|
||||
|
||||
callbacks->info(data, &info);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 0;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
emit_node_info(this);
|
||||
emit_port_info(this, GET_OUT_PORT(this, 0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_output_ids > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
|
|
@ -409,25 +384,6 @@ static int impl_node_remove_port(struct spa_node *node,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &GET_PORT(this, direction, port_id)->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -923,23 +879,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -1013,9 +966,12 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
port = GET_OUT_PORT(this, 0);
|
||||
spa_list_init(&port->queue);
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_LIVE |
|
||||
SPA_PORT_INFO_FLAG_PHYSICAL |
|
||||
SPA_PORT_INFO_FLAG_TERMINAL;
|
||||
|
||||
port->export_buf = true;
|
||||
port->have_query_ext_ctrl = true;
|
||||
port->dev.log = this->log;
|
||||
|
|
|
|||
|
|
@ -913,12 +913,15 @@ static int spa_v4l2_set_format(struct impl *this, struct spa_video_info *format,
|
|||
port->rate.num = framerate->denom = streamparm.parm.capture.timeperframe.numerator;
|
||||
|
||||
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_INFO_FLAG_CAN_ALLOC_BUFFERS : 0) |
|
||||
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_LIVE |
|
||||
SPA_PORT_INFO_FLAG_PHYSICAL |
|
||||
SPA_PORT_INFO_FLAG_TERMINAL;
|
||||
port->info.rate = streamparm.parm.capture.timeperframe.denominator;
|
||||
if (this->callbacks && this->callbacks->port_info)
|
||||
this->callbacks->port_info(this->callbacks_data, SPA_DIRECTION_OUTPUT, 0, &port->info);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -392,6 +392,27 @@ static const struct spa_dict_item node_info_items[] = {
|
|||
{ "media.class", "Video/Source" },
|
||||
};
|
||||
|
||||
static void emit_node_info(struct impl *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
|
||||
|
||||
this->callbacks->info(this->callbacks_data, &info);
|
||||
}
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && this->info.change_mask) {
|
||||
this->callbacks->port_info(this->callbacks_data, SPA_DIRECTION_OUTPUT, 0, &this->info);
|
||||
this->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -406,52 +427,8 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
if (callbacks) {
|
||||
if (callbacks->info) {
|
||||
struct spa_node_info info;
|
||||
|
||||
info = SPA_NODE_INFO_INIT();
|
||||
info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
|
||||
info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
|
||||
|
||||
callbacks->info(data, &info);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 0;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_output_ids > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
emit_node_info(this);
|
||||
emit_port_info(this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -467,26 +444,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -840,23 +797,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -941,6 +895,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
||||
this->info = SPA_PORT_INFO_INIT();
|
||||
this->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_NO_REF;
|
||||
if (this->props.live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
|
|
|||
|
|
@ -240,6 +240,15 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this, enum spa_direction direction, uint32_t id)
|
||||
{
|
||||
struct port *port = GET_PORT(this, direction, id);
|
||||
if (this->callbacks && this->callbacks->port_info && port->info.change_mask) {
|
||||
this->callbacks->port_info(this->callbacks_data, direction, id, &port->info);
|
||||
port->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
|
|
@ -254,48 +263,12 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
emit_port_info(this, SPA_DIRECTION_INPUT, 0);
|
||||
emit_port_info(this, SPA_DIRECTION_OUTPUT, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ids > 0 && input_ids)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ids > 0 && output_ids)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
|
|
@ -307,28 +280,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -785,23 +736,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -841,6 +789,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
uint32_t n_support)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
|
|
@ -859,13 +808,19 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->node = impl_node;
|
||||
reset_props(&this->props);
|
||||
|
||||
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
port = GET_IN_PORT(this, 0);
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_IN_PLACE;
|
||||
spa_list_init(&this->in_ports[0].empty);
|
||||
spa_list_init(&port->empty);
|
||||
|
||||
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
port = GET_OUT_PORT(this, 0);
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
spa_list_init(&this->out_ports[0].empty);
|
||||
spa_list_init(&port->empty);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ struct data {
|
|||
uint32_t n_support;
|
||||
struct spa_log *log;
|
||||
struct spa_loop loop;
|
||||
struct spa_node *node;
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
@ -74,7 +75,7 @@ inspect_node_params(struct data *data, struct spa_node *node)
|
|||
SPA_TYPE_OBJECT_ParamList, NULL,
|
||||
SPA_PARAM_LIST_id, SPA_POD_Id(&id));
|
||||
|
||||
printf("enumerating: %s:\n", spa_debug_type_find_name(NULL, id));
|
||||
printf("enumerating: %s:\n", spa_debug_type_find_name(spa_type_param, id));
|
||||
for (idx2 = 0;;) {
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
if ((res = spa_node_enum_params(node,
|
||||
|
|
@ -115,7 +116,7 @@ inspect_port_params(struct data *data, struct spa_node *node,
|
|||
SPA_TYPE_OBJECT_ParamList, NULL,
|
||||
SPA_PARAM_LIST_id, SPA_POD_Id(&id));
|
||||
|
||||
printf("enumerating: %s:\n", spa_debug_type_find_name(NULL, id));
|
||||
printf("enumerating: %s:\n", spa_debug_type_find_name(spa_type_param, id));
|
||||
for (idx2 = 0;;) {
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
if ((res = spa_node_port_enum_params(node,
|
||||
|
|
@ -135,55 +136,44 @@ inspect_port_params(struct data *data, struct spa_node *node,
|
|||
}
|
||||
}
|
||||
|
||||
static void node_info(void *data, const struct spa_node_info *info)
|
||||
static void node_info(void *_data, const struct spa_node_info *info)
|
||||
{
|
||||
struct data *data = _data;
|
||||
if (info->change_mask & SPA_NODE_CHANGE_MASK_PROPS) {
|
||||
printf("node properties:\n");
|
||||
spa_debug_dict(2, info->props);
|
||||
}
|
||||
inspect_node_params(data, data->node);
|
||||
}
|
||||
|
||||
static void node_port_info(void *_data, enum spa_direction direction, uint32_t id,
|
||||
const struct spa_port_info *info)
|
||||
{
|
||||
struct data *data = _data;
|
||||
|
||||
if (info == NULL) {
|
||||
printf("port %d removed", id);
|
||||
}
|
||||
else {
|
||||
printf(" %s port: %08x\n",
|
||||
direction == SPA_DIRECTION_INPUT ? "input" : "output",
|
||||
id);
|
||||
inspect_port_params(data, data->node, direction, id);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct spa_node_callbacks node_callbacks =
|
||||
{
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
.info = node_info,
|
||||
.port_info = node_port_info,
|
||||
};
|
||||
|
||||
static void inspect_node(struct data *data, struct spa_node *node)
|
||||
{
|
||||
int res;
|
||||
uint32_t i, n_input, max_input, n_output, max_output;
|
||||
uint32_t *in_ports, *out_ports;
|
||||
|
||||
printf("node info:\n");
|
||||
data->node = node;
|
||||
spa_node_set_callbacks(node, &node_callbacks, data);
|
||||
|
||||
inspect_node_params(data, node);
|
||||
|
||||
if ((res = spa_node_get_n_ports(node, &n_input, &max_input, &n_output, &max_output)) < 0) {
|
||||
printf("can't get n_ports: %d\n", res);
|
||||
return;
|
||||
}
|
||||
printf("supported ports:\n");
|
||||
printf("input ports: %d/%d\n", n_input, max_input);
|
||||
printf("output ports: %d/%d\n", n_output, max_output);
|
||||
|
||||
in_ports = alloca(n_input * sizeof(uint32_t));
|
||||
out_ports = alloca(n_output * sizeof(uint32_t));
|
||||
|
||||
if ((res = spa_node_get_port_ids(node, in_ports, n_input, out_ports, n_output)) < 0)
|
||||
printf("can't get port ids: %d\n", res);
|
||||
|
||||
for (i = 0; i < n_input; i++) {
|
||||
printf(" input port: %08x\n", in_ports[i]);
|
||||
inspect_port_params(data, node, SPA_DIRECTION_INPUT, in_ports[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < n_output; i++) {
|
||||
printf(" output port: %08x\n", out_ports[i]);
|
||||
inspect_port_params(data, node, SPA_DIRECTION_OUTPUT, out_ports[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void inspect_factory(struct data *data, const struct spa_handle_factory *factory)
|
||||
|
|
|
|||
|
|
@ -137,8 +137,19 @@ static int impl_set_callbacks(struct spa_node *node,
|
|||
const struct spa_node_callbacks *callbacks, void *data)
|
||||
{
|
||||
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
|
||||
|
||||
d->callbacks = callbacks;
|
||||
d->callbacks_data = data;
|
||||
|
||||
if (d->callbacks && d->callbacks->port_info) {
|
||||
struct spa_port_info info;
|
||||
|
||||
info = SPA_PORT_INFO_INIT();
|
||||
info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
|
||||
d->callbacks->port_info(d->callbacks_data, SPA_DIRECTION_INPUT, 0, &info);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -148,28 +159,6 @@ static int impl_set_io(struct spa_node *node,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int impl_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)
|
||||
{
|
||||
*n_input_ports = *max_input_ports = 1;
|
||||
*n_output_ports = *max_output_ports = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_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)
|
||||
{
|
||||
if (n_input_ids > 0)
|
||||
input_ids[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_port_set_io(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t id, void *data, size_t size)
|
||||
|
|
@ -190,20 +179,6 @@ static int impl_port_set_io(struct spa_node *node,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int impl_port_get_info(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
|
||||
|
||||
d->port_info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
d->port_info.rate = 0;
|
||||
d->port_info.props = NULL;
|
||||
|
||||
*info = &d->port_info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -471,10 +446,7 @@ static const struct spa_node impl_node = {
|
|||
.set_callbacks = impl_set_callbacks,
|
||||
.set_io = impl_set_io,
|
||||
.send_command = impl_send_command,
|
||||
.get_n_ports = impl_get_n_ports,
|
||||
.get_port_ids = impl_get_port_ids,
|
||||
.port_set_io = impl_port_set_io,
|
||||
.port_get_info = impl_port_get_info,
|
||||
.port_enum_params = impl_port_enum_params,
|
||||
.port_set_param = impl_port_set_param,
|
||||
.port_use_buffers = impl_port_use_buffers,
|
||||
|
|
|
|||
|
|
@ -56,10 +56,6 @@ struct data {
|
|||
struct pw_remote *remote;
|
||||
struct spa_hook remote_listener;
|
||||
|
||||
struct spa_port_info port_info;
|
||||
struct spa_dict port_props;
|
||||
struct spa_dict_item port_items[1];
|
||||
|
||||
struct spa_node impl_node;
|
||||
const struct spa_node_callbacks *callbacks;
|
||||
void *callbacks_data;
|
||||
|
|
@ -110,6 +106,19 @@ static int impl_set_callbacks(struct spa_node *node,
|
|||
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
|
||||
d->callbacks = callbacks;
|
||||
d->callbacks_data = data;
|
||||
|
||||
if (d->callbacks && d->callbacks->port_info) {
|
||||
struct spa_port_info info;
|
||||
struct spa_dict_item port_items[1];
|
||||
|
||||
info = SPA_PORT_INFO_INIT();
|
||||
info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PROPS;
|
||||
info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
port_items[0] = SPA_DICT_ITEM_INIT("port.dsp", "32 bit float mono audio");
|
||||
info.props = &SPA_DICT_INIT_ARRAY(port_items);
|
||||
|
||||
d->callbacks->port_info(d->callbacks_data, SPA_DIRECTION_OUTPUT, 0, &info);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -119,29 +128,6 @@ static int impl_set_io(struct spa_node *node,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int impl_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)
|
||||
{
|
||||
*n_input_ports = *max_input_ports = 0;
|
||||
*n_output_ports = *max_output_ports = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_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)
|
||||
{
|
||||
if (n_output_ids > 0)
|
||||
output_ids[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_port_set_io(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t id, void *data, size_t size)
|
||||
{
|
||||
|
|
@ -161,23 +147,6 @@ static int impl_port_set_io(struct spa_node *node, enum spa_direction direction,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int impl_port_get_info(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
|
||||
|
||||
d->port_info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
d->port_info.rate = 0;
|
||||
d->port_info.props = &d->port_props;
|
||||
|
||||
d->port_items[0] = SPA_DICT_ITEM_INIT("port.dsp", "32 bit float mono audio");
|
||||
d->port_props = SPA_DICT_INIT(d->port_items, 1);
|
||||
|
||||
*info = &d->port_info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -480,10 +449,7 @@ static const struct spa_node impl_node = {
|
|||
.set_callbacks = impl_set_callbacks,
|
||||
.set_io = impl_set_io,
|
||||
.send_command = impl_send_command,
|
||||
.get_n_ports = impl_get_n_ports,
|
||||
.get_port_ids = impl_get_port_ids,
|
||||
.port_set_io = impl_port_set_io,
|
||||
.port_get_info = impl_port_get_info,
|
||||
.port_enum_params = impl_port_enum_params,
|
||||
.port_set_param = impl_port_set_param,
|
||||
.port_use_buffers = impl_port_use_buffers,
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ static void handle_events(struct data *data)
|
|||
}
|
||||
}
|
||||
|
||||
static int impl_set_io(struct spa_node *node, uint32_t id, void *data, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
{
|
||||
return 0;
|
||||
|
|
@ -90,28 +95,16 @@ static int impl_set_callbacks(struct spa_node *node,
|
|||
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
|
||||
d->callbacks = callbacks;
|
||||
d->callbacks_data = data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_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)
|
||||
{
|
||||
*n_input_ports = *max_input_ports = 1;
|
||||
*n_output_ports = *max_output_ports = 0;
|
||||
return 0;
|
||||
}
|
||||
if (d->callbacks && d->callbacks->port_info) {
|
||||
struct spa_port_info info;
|
||||
|
||||
static int impl_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)
|
||||
{
|
||||
if (n_input_ids > 0)
|
||||
input_ids[0] = 0;
|
||||
info = SPA_PORT_INFO_INIT();
|
||||
info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
|
||||
d->callbacks->port_info(d->callbacks_data, SPA_DIRECTION_INPUT, 0, &info);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -128,20 +121,6 @@ static int impl_port_set_io(struct spa_node *node, enum spa_direction direction,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int impl_port_get_info(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
|
||||
|
||||
d->port_info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
d->port_info.rate = 0;
|
||||
d->port_info.props = NULL;
|
||||
|
||||
*info = &d->port_info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t *index,
|
||||
|
|
@ -329,12 +308,10 @@ static int impl_node_process(struct spa_node *node)
|
|||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
NULL,
|
||||
.set_io = impl_set_io,
|
||||
.send_command = impl_send_command,
|
||||
.set_callbacks = impl_set_callbacks,
|
||||
.get_n_ports = impl_get_n_ports,
|
||||
.get_port_ids = impl_get_port_ids,
|
||||
.port_set_io = impl_port_set_io,
|
||||
.port_get_info = impl_port_get_info,
|
||||
.port_enum_params = impl_port_enum_params,
|
||||
.port_set_param = impl_port_set_param,
|
||||
.port_use_buffers = impl_port_use_buffers,
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ struct buffer {
|
|||
};
|
||||
|
||||
struct port {
|
||||
bool valid;
|
||||
uint32_t direction;
|
||||
uint32_t id;
|
||||
|
||||
struct port_props props;
|
||||
|
|
@ -80,7 +80,8 @@ struct port {
|
|||
|
||||
struct spa_port_info info;
|
||||
|
||||
bool have_format;
|
||||
int valid:1;
|
||||
int have_format:1;
|
||||
|
||||
struct buffer buffers[MAX_BUFFERS];
|
||||
uint32_t n_buffers;
|
||||
|
|
@ -162,12 +163,21 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *this, struct port *port)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info && port->info.change_mask) {
|
||||
this->callbacks->port_info(this->user_data, port->direction, port->id, &port->info);
|
||||
port->info.change_mask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *user_data)
|
||||
{
|
||||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
|
|
@ -176,57 +186,11 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = this->port_count;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = MAX_PORTS;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct impl *this;
|
||||
uint32_t i, idx;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (input_ids) {
|
||||
for (i = 0, idx = 0; i < this->last_port && idx < n_input_ids; i++) {
|
||||
if (this->in_ports[i].valid)
|
||||
input_ids[idx++] = i;
|
||||
}
|
||||
emit_port_info(this, GET_OUT_PORT(this, 0));
|
||||
for (i = 0; i < this->last_port; i++) {
|
||||
if (this->in_ports[i].valid)
|
||||
emit_port_info(this, GET_IN_PORT(this, i));
|
||||
}
|
||||
if (n_output_ids > 0 && output_ids)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -242,6 +206,7 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio
|
|||
spa_return_val_if_fail(CHECK_FREE_IN_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_IN_PORT (this, port_id);
|
||||
port->direction = direction;
|
||||
port->id = port_id;
|
||||
|
||||
port_props_reset(&port->props);
|
||||
|
|
@ -249,6 +214,8 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio
|
|||
port->io_mute = &port->props.mute;
|
||||
|
||||
spa_list_init(&port->queue);
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_REMOVABLE |
|
||||
SPA_PORT_INFO_FLAG_OPTIONAL |
|
||||
|
|
@ -260,6 +227,7 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio
|
|||
port->valid = true;
|
||||
|
||||
spa_log_info(this->log, NAME " %p: add port %d %d", this, port_id, this->last_port);
|
||||
emit_port_info(this, port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -297,27 +265,8 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
}
|
||||
spa_log_info(this->log, NAME " %p: remove port %d %d", this, port_id, this->last_port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
if (this->callbacks && this->callbacks->port_info)
|
||||
this->callbacks->port_info(this->user_data, direction, port_id, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -866,23 +815,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
|
||||
|
|
@ -943,6 +889,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
port = GET_OUT_PORT(this, 0);
|
||||
port->valid = true;
|
||||
port->id = 0;
|
||||
port->info = SPA_PORT_INFO_INIT();
|
||||
port->info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
spa_list_init(&port->queue);
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ struct port {
|
|||
struct spa_port_info info;
|
||||
struct pw_properties *properties;
|
||||
|
||||
bool have_format;
|
||||
int have_format:1;
|
||||
uint32_t n_params;
|
||||
struct spa_pod **params;
|
||||
|
||||
|
|
@ -464,12 +464,21 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
static void emit_port_info(struct node *this, struct port *port)
|
||||
{
|
||||
if (this->callbacks && this->callbacks->port_info) {
|
||||
this->callbacks->port_info(this->callbacks_data, port->direction, port->id, &port->info);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *data)
|
||||
{
|
||||
struct node *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
|
|
@ -477,59 +486,13 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct node *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct node, node);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = this->n_inputs;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = this->max_inputs == 0 ? this->n_inputs : this->max_inputs;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = this->n_outputs;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = this->max_outputs == 0 ? this->n_outputs : this->max_outputs;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct node *this;
|
||||
uint32_t c, i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct node, node);
|
||||
|
||||
if (input_ids) {
|
||||
for (c = 0, i = 0; i < MAX_INPUTS && c < n_input_ids; i++) {
|
||||
if (this->in_ports[i])
|
||||
input_ids[c++] = i;
|
||||
}
|
||||
for (i = 0; i < MAX_INPUTS; i++) {
|
||||
if (this->in_ports[i])
|
||||
emit_port_info(this, this->in_ports[i]);
|
||||
}
|
||||
if (output_ids) {
|
||||
for (c = 0, i = 0; i < MAX_OUTPUTS && c < n_output_ids; i++) {
|
||||
if (this->out_ports[i])
|
||||
output_ids[c++] = i;
|
||||
}
|
||||
for (i = 0; i < MAX_OUTPUTS; i++) {
|
||||
if (this->out_ports[i])
|
||||
emit_port_info(this, this->out_ports[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -608,6 +571,8 @@ clear_port(struct node *this, struct port *port)
|
|||
this->n_outputs--;
|
||||
}
|
||||
}
|
||||
if (this->callbacks && this->callbacks->port_info)
|
||||
this->callbacks->port_info(this->callbacks_data, port->direction, port->id, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -644,27 +609,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return SPA_RESULT_RETURN_ASYNC(this->seq++);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct node *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct node, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
|
@ -1007,8 +951,8 @@ client_node_done(void *data, int seq, int res)
|
|||
{
|
||||
struct impl *impl = data;
|
||||
struct node *this = &impl->node;
|
||||
|
||||
this->callbacks->done(this->callbacks_data, seq, res);
|
||||
if (this->callbacks && this->callbacks->done)
|
||||
this->callbacks->done(this->callbacks_data, seq, res);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1070,35 +1014,23 @@ client_node_port_update(void *data,
|
|||
|
||||
if (remove) {
|
||||
clear_port(this, port);
|
||||
pw_node_update_ports(impl->this.node);
|
||||
} else {
|
||||
struct port *target;
|
||||
|
||||
if (port == NULL) {
|
||||
target = &this->dummy;
|
||||
spa_zero(this->dummy);
|
||||
target->id = port_id;
|
||||
}
|
||||
else
|
||||
} else
|
||||
target = port;
|
||||
|
||||
do_update_port(this,
|
||||
target,
|
||||
change_mask,
|
||||
n_params, params, info);
|
||||
|
||||
if (port == NULL) {
|
||||
if (direction == SPA_DIRECTION_INPUT) {
|
||||
this->n_inputs++;
|
||||
this->in_ports[port_id] = target;
|
||||
}
|
||||
else {
|
||||
this->n_outputs++;
|
||||
this->out_ports[port_id] = target;
|
||||
}
|
||||
pw_node_update_ports(impl->this.node);
|
||||
}
|
||||
n_params, params,
|
||||
info);
|
||||
|
||||
if (this->callbacks && this->callbacks->port_info)
|
||||
this->callbacks->port_info(this->callbacks_data, direction, port_id, info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1112,7 +1044,8 @@ static void client_node_event(void *data, struct spa_event *event)
|
|||
{
|
||||
struct impl *impl = data;
|
||||
struct node *this = &impl->node;
|
||||
this->callbacks->event(this->callbacks_data, event);
|
||||
if (this->callbacks && this->callbacks->event)
|
||||
this->callbacks->event(this->callbacks_data, event);
|
||||
}
|
||||
|
||||
static struct pw_client_node_proxy_methods client_node_methods = {
|
||||
|
|
@ -1153,11 +1086,8 @@ static const struct spa_node impl_node = {
|
|||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.get_n_ports = impl_node_get_n_ports,
|
||||
.get_port_ids = impl_node_get_port_ids,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_get_info = impl_node_port_get_info,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
|
|
@ -1501,17 +1431,12 @@ static const struct spa_node impl_port_mix = {
|
|||
static void node_port_init(void *data, struct pw_port *port)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
struct port *p = pw_port_get_user_data(port), *dummy;
|
||||
struct port *p = pw_port_get_user_data(port);
|
||||
struct node *this = &impl->node;
|
||||
|
||||
pw_log_debug("client-node %p: port %p init", &impl->this, port);
|
||||
|
||||
if (port->direction == PW_DIRECTION_INPUT)
|
||||
dummy = this->in_ports[port->port_id];
|
||||
else
|
||||
dummy = this->out_ports[port->port_id];
|
||||
|
||||
*p = *dummy;
|
||||
*p = this->dummy;
|
||||
p->port = port;
|
||||
p->node = this;
|
||||
p->direction = port->direction;
|
||||
|
|
@ -1520,11 +1445,13 @@ static void node_port_init(void *data, struct pw_port *port)
|
|||
p->mix_node = impl_port_mix;
|
||||
mix_init(&p->mix[MAX_MIX], p, SPA_ID_INVALID);
|
||||
|
||||
if (p->direction == SPA_DIRECTION_INPUT)
|
||||
if (p->direction == SPA_DIRECTION_INPUT) {
|
||||
this->in_ports[p->id] = p;
|
||||
else
|
||||
this->n_inputs++;
|
||||
} else {
|
||||
this->out_ports[p->id] = p;
|
||||
|
||||
this->n_outputs++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ struct impl {
|
|||
struct spa_node *cnode;
|
||||
struct spa_node *adapter;
|
||||
struct spa_node *adapter_mix;
|
||||
uint32_t adapter_mix_flags;
|
||||
uint32_t adapter_mix_port;
|
||||
|
||||
bool use_converter;
|
||||
|
|
@ -223,10 +224,6 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
if ((res = spa_node_set_param(impl->adapter, id, flags, param)) < 0)
|
||||
return res;
|
||||
|
||||
if (this->callbacks && this->callbacks->event)
|
||||
this->callbacks->event(this->callbacks_data,
|
||||
&SPA_NODE_EVENT_INIT(SPA_NODE_EVENT_PortsChanged));
|
||||
|
||||
try_link_controls(impl);
|
||||
}
|
||||
break;
|
||||
|
|
@ -288,30 +285,31 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void adapter_port_info(void *data,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
const struct spa_port_info *info)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
struct node *this = &impl->node;
|
||||
|
||||
if (this->callbacks && this->callbacks->port_info) {
|
||||
if (direction == impl->direction) {
|
||||
this->callbacks->port_info(this->callbacks_data, direction, port_id, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const struct spa_node_callbacks adapter_node_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
.port_info = adapter_port_info,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *data)
|
||||
{
|
||||
struct node *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct node, node);
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct node *this;
|
||||
struct impl *impl;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
|
@ -319,46 +317,15 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct node, node);
|
||||
impl = this->impl;
|
||||
|
||||
spa_node_get_n_ports(impl->adapter,
|
||||
n_input_ports,
|
||||
max_input_ports,
|
||||
n_output_ports,
|
||||
max_output_ports);
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
if (this->callbacks && impl->adapter && impl->adapter != impl->cnode)
|
||||
spa_node_set_callbacks(impl->adapter, &adapter_node_callbacks, impl);
|
||||
|
||||
if (impl->direction == SPA_DIRECTION_OUTPUT) {
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 0;
|
||||
} else {
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 0;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_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)
|
||||
{
|
||||
struct node *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct node, node);
|
||||
|
||||
return spa_node_get_port_ids(this->impl->adapter,
|
||||
input_ids,
|
||||
n_input_ids,
|
||||
output_ids,
|
||||
n_output_ids);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
|
|
@ -404,26 +371,6 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
return spa_node_remove_port(impl->adapter_mix, direction, port_id);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct node *this;
|
||||
struct impl *impl;
|
||||
|
||||
if (node == NULL || info == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct node, node);
|
||||
impl = this->impl;
|
||||
|
||||
if (direction != impl->direction)
|
||||
return -EINVAL;
|
||||
|
||||
return spa_node_port_get_info(impl->adapter, direction, port_id, info);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
|
@ -552,7 +499,7 @@ static int negotiate_buffers(struct impl *impl)
|
|||
int32_t size, buffers, blocks, align, flags;
|
||||
uint32_t *aligns;
|
||||
struct spa_data *datas;
|
||||
const struct spa_port_info *in_info, *out_info;
|
||||
uint32_t in_flags, out_flags;
|
||||
struct spa_buffer_alloc_info info = { 0, };
|
||||
void *skel;
|
||||
|
||||
|
|
@ -588,18 +535,11 @@ static int negotiate_buffers(struct impl *impl)
|
|||
|
||||
spa_pod_fixate(param);
|
||||
|
||||
if ((res = spa_node_port_get_info(impl->cnode,
|
||||
impl->direction, 0,
|
||||
&out_info)) < 0)
|
||||
return res;
|
||||
if ((res = spa_node_port_get_info(impl->adapter_mix,
|
||||
SPA_DIRECTION_REVERSE(impl->direction),
|
||||
impl->adapter_mix_port,
|
||||
&in_info)) < 0)
|
||||
return res;
|
||||
in_flags = impl->client_port->spa_flags;
|
||||
out_flags = impl->adapter_mix_flags;
|
||||
|
||||
in_alloc = SPA_FLAG_CHECK(in_info->flags, SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS);
|
||||
out_alloc = SPA_FLAG_CHECK(out_info->flags, SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS);
|
||||
in_alloc = SPA_FLAG_CHECK(in_flags, SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS);
|
||||
out_alloc = SPA_FLAG_CHECK(out_flags, SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS);
|
||||
|
||||
flags = 0;
|
||||
if (out_alloc || in_alloc) {
|
||||
|
|
@ -876,23 +816,20 @@ static int impl_node_process(struct spa_node *node)
|
|||
|
||||
static const struct spa_node impl_node = {
|
||||
SPA_VERSION_NODE,
|
||||
impl_node_enum_params,
|
||||
impl_node_set_param,
|
||||
impl_node_set_io,
|
||||
impl_node_send_command,
|
||||
impl_node_set_callbacks,
|
||||
impl_node_get_n_ports,
|
||||
impl_node_get_port_ids,
|
||||
impl_node_add_port,
|
||||
impl_node_remove_port,
|
||||
impl_node_port_get_info,
|
||||
impl_node_port_enum_params,
|
||||
impl_node_port_set_param,
|
||||
impl_node_port_use_buffers,
|
||||
impl_node_port_alloc_buffers,
|
||||
impl_node_port_set_io,
|
||||
impl_node_port_reuse_buffer,
|
||||
impl_node_process,
|
||||
.enum_params = impl_node_enum_params,
|
||||
.set_param = impl_node_set_param,
|
||||
.set_io = impl_node_set_io,
|
||||
.send_command = impl_node_send_command,
|
||||
.set_callbacks = impl_node_set_callbacks,
|
||||
.add_port = impl_node_add_port,
|
||||
.remove_port = impl_node_remove_port,
|
||||
.port_enum_params = impl_node_port_enum_params,
|
||||
.port_set_param = impl_node_port_set_param,
|
||||
.port_use_buffers = impl_node_port_use_buffers,
|
||||
.port_alloc_buffers = impl_node_port_alloc_buffers,
|
||||
.port_set_io = impl_node_port_set_io,
|
||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
||||
.process = impl_node_process,
|
||||
};
|
||||
|
||||
static int
|
||||
|
|
@ -914,10 +851,38 @@ node_init(struct node *this,
|
|||
return SPA_RESULT_RETURN_ASYNC(this->seq++);
|
||||
}
|
||||
|
||||
static int do_port_info(void *data, struct pw_port *port)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
struct node *node = &impl->node;
|
||||
struct spa_port_info info;
|
||||
|
||||
info = SPA_PORT_INFO_INIT();
|
||||
info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PROPS;
|
||||
info.flags = port->spa_flags;
|
||||
info.props = &port->properties->dict;
|
||||
|
||||
node->callbacks->port_info(node->callbacks_data,
|
||||
impl->direction, port->port_id, &info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct impl *impl)
|
||||
{
|
||||
struct node *node = &impl->node;
|
||||
|
||||
if (node->callbacks && node->callbacks->port_info) {
|
||||
pw_node_for_each_port(impl->client_node->node,
|
||||
impl->direction,
|
||||
do_port_info,
|
||||
impl);
|
||||
}
|
||||
}
|
||||
|
||||
static void client_node_initialized(void *data)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
uint32_t n_input_ports, n_output_ports, max_input_ports, max_output_ports, state;
|
||||
uint32_t state;
|
||||
uint32_t media_type, media_subtype;
|
||||
struct spa_pod *format;
|
||||
uint8_t buffer[4096];
|
||||
|
|
@ -928,18 +893,15 @@ static void client_node_initialized(void *data)
|
|||
char media_class[64];
|
||||
bool exclusive, monitor;
|
||||
struct spa_dict_item items[1];
|
||||
const struct pw_node_info *info;
|
||||
|
||||
pw_log_debug("client-stream %p: initialized", &impl->this);
|
||||
|
||||
if ((res = spa_node_get_n_ports(impl->cnode,
|
||||
&n_input_ports,
|
||||
&max_input_ports,
|
||||
&n_output_ports,
|
||||
&max_output_ports)) < 0)
|
||||
info = pw_node_get_info(impl->client_node->node);
|
||||
if (info == NULL)
|
||||
return;
|
||||
|
||||
|
||||
if (n_output_ports == 0) {
|
||||
if (info->n_output_ports == 0) {
|
||||
impl->direction = SPA_DIRECTION_INPUT;
|
||||
dir = "Input";
|
||||
}
|
||||
|
|
@ -949,8 +911,8 @@ static void client_node_initialized(void *data)
|
|||
}
|
||||
|
||||
pw_log_debug("client-stream %p: in %d/%d out %d/%d -> %s", &impl->this,
|
||||
n_input_ports, max_input_ports,
|
||||
n_output_ports, max_output_ports,
|
||||
info->n_input_ports, info->max_input_ports,
|
||||
info->n_output_ports, info->max_output_ports,
|
||||
dir);
|
||||
|
||||
props = pw_node_get_properties(impl->client_node->node);
|
||||
|
|
@ -987,7 +949,9 @@ static void client_node_initialized(void *data)
|
|||
impl->adapter = impl->cnode;
|
||||
impl->adapter_mix = impl->client_port->mix;
|
||||
impl->adapter_mix_port = 0;
|
||||
impl->adapter_mix_flags = impl->client_port->spa_flags;
|
||||
impl->use_converter = false;
|
||||
emit_port_info(impl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1025,12 +989,16 @@ static void client_node_initialized(void *data)
|
|||
impl->adapter_mix = impl->adapter;
|
||||
impl->adapter_mix_port = 0;
|
||||
impl->use_converter = true;
|
||||
if (impl->node.callbacks != NULL)
|
||||
spa_node_set_callbacks(impl->adapter, &adapter_node_callbacks, impl);
|
||||
}
|
||||
else {
|
||||
impl->adapter = impl->cnode;
|
||||
impl->adapter_mix = impl->client_port->mix;
|
||||
impl->adapter_mix_port = 0;
|
||||
impl->adapter_mix_flags = impl->client_port->spa_flags;
|
||||
impl->use_converter = false;
|
||||
emit_port_info(impl);
|
||||
}
|
||||
|
||||
if (impl->use_converter) {
|
||||
|
|
|
|||
|
|
@ -793,7 +793,7 @@ static int client_node_demarshal_port_update(void *object, void *data, size_t si
|
|||
struct spa_pod_frame f;
|
||||
uint32_t i, direction, port_id, change_mask, n_params;
|
||||
const struct spa_pod **params = NULL;
|
||||
struct spa_port_info info = { 0 }, *infop = NULL;
|
||||
struct spa_port_info info = SPA_PORT_INFO_INIT(), *infop = NULL;
|
||||
struct spa_pod *ipod;
|
||||
struct spa_dict props;
|
||||
|
||||
|
|
|
|||
|
|
@ -397,8 +397,7 @@ static void client_node_transport(void *object, uint32_t node_id,
|
|||
static void add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32_t change_mask)
|
||||
{
|
||||
struct node_data *data = proxy->user_data;
|
||||
const struct spa_port_info *port_info = NULL;
|
||||
struct spa_port_info pi;
|
||||
struct spa_port_info pi = SPA_PORT_INFO_INIT();
|
||||
uint32_t n_params = 0;
|
||||
struct spa_pod **params = NULL;
|
||||
|
||||
|
|
@ -438,8 +437,12 @@ static void add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32
|
|||
}
|
||||
}
|
||||
if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_INFO) {
|
||||
spa_node_port_get_info(port->node->node, port->direction, port->port_id, &port_info);
|
||||
pi = * port_info;
|
||||
pi.change_mask = SPA_PORT_CHANGE_MASK_FLAGS |
|
||||
SPA_PORT_CHANGE_MASK_RATE |
|
||||
SPA_PORT_CHANGE_MASK_PROPS;
|
||||
pi.flags = port->spa_flags;
|
||||
pi.rate = 0;
|
||||
pi.props = &port->properties->dict;
|
||||
pi.flags &= ~SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ static struct pw_port *get_port(struct pw_node *node, enum spa_direction directi
|
|||
if (port_id == SPA_ID_INVALID)
|
||||
return NULL;
|
||||
|
||||
p = pw_port_new(direction, port_id, NULL, 0);
|
||||
p = pw_port_new(direction, port_id, 0, NULL, 0);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -540,7 +540,6 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s
|
|||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||
int res;
|
||||
const struct spa_port_info *iinfo, *oinfo;
|
||||
uint32_t in_flags, out_flags;
|
||||
char *error = NULL;
|
||||
struct pw_port *input, *output;
|
||||
|
|
@ -561,17 +560,9 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s
|
|||
output = this->output;
|
||||
|
||||
pw_log_debug("link %p: doing alloc buffers %p %p", this, output->node, input->node);
|
||||
if ((res = spa_node_port_get_info(input->node->node,
|
||||
input->direction, input->port_id,
|
||||
&iinfo)) < 0)
|
||||
return res;
|
||||
if ((res = spa_node_port_get_info(output->node->node,
|
||||
output->direction, output->port_id,
|
||||
&oinfo)) < 0)
|
||||
return res;
|
||||
|
||||
in_flags = iinfo->flags;
|
||||
out_flags = oinfo->flags;
|
||||
in_flags = input->spa_flags;
|
||||
out_flags = output->spa_flags;
|
||||
|
||||
if (out_flags & SPA_PORT_INFO_FLAG_LIVE) {
|
||||
pw_log_debug("setting link as live");
|
||||
|
|
@ -579,10 +570,6 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s
|
|||
input->node->live = true;
|
||||
}
|
||||
|
||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) {
|
||||
spa_debug_port_info(2, oinfo);
|
||||
spa_debug_port_info(2, iinfo);
|
||||
}
|
||||
if (output->allocation.n_buffers) {
|
||||
out_flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
in_flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
|
|
|
|||
|
|
@ -230,101 +230,6 @@ static void node_unbind_func(void *data)
|
|||
spa_list_remove(&resource->link);
|
||||
}
|
||||
|
||||
static void update_port_map(struct pw_node *node, enum pw_direction direction,
|
||||
struct pw_map *portmap, uint32_t *ids, uint32_t n_ids)
|
||||
{
|
||||
uint32_t o, n;
|
||||
size_t os, ns;
|
||||
struct pw_port *port;
|
||||
int res;
|
||||
|
||||
o = n = 0;
|
||||
os = pw_map_get_size(portmap);
|
||||
ns = n_ids;
|
||||
|
||||
while (o < os || n < ns) {
|
||||
port = pw_map_lookup(portmap, o);
|
||||
|
||||
if (n >= ns || o < ids[n]) {
|
||||
pw_log_debug("node %p: %s port %d removed", node,
|
||||
pw_direction_as_string(direction), o);
|
||||
|
||||
if (port != NULL)
|
||||
pw_port_destroy(port);
|
||||
|
||||
o++;
|
||||
}
|
||||
else if (o >= os || o > ids[n]) {
|
||||
pw_log_debug("node %p: %s port %d added", node,
|
||||
pw_direction_as_string(direction), ids[n]);
|
||||
|
||||
if (port == NULL) {
|
||||
if ((port = pw_port_new(direction, ids[n], NULL, node->port_user_data_size))) {
|
||||
if ((res = pw_port_add(port, node)) < 0) {
|
||||
pw_log_error("node %p: can't add port %p: %d, %s",
|
||||
node, port, res, spa_strerror(res));
|
||||
pw_port_destroy(port);
|
||||
}
|
||||
}
|
||||
o = ids[n] + 1;
|
||||
os++;
|
||||
}
|
||||
|
||||
n++;
|
||||
}
|
||||
else {
|
||||
pw_log_debug("node %p: %s port %d unchanged", node,
|
||||
pw_direction_as_string(direction), o);
|
||||
n++;
|
||||
o++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
int pw_node_update_ports(struct pw_node *node)
|
||||
{
|
||||
uint32_t *input_port_ids, *output_port_ids;
|
||||
uint32_t n_input_ports, n_output_ports, max_input_ports, max_output_ports;
|
||||
int res;
|
||||
|
||||
res = spa_node_get_n_ports(node->node,
|
||||
&n_input_ports,
|
||||
&max_input_ports,
|
||||
&n_output_ports,
|
||||
&max_output_ports);
|
||||
if (res < 0)
|
||||
return res;
|
||||
|
||||
if (node->info.max_input_ports != max_input_ports) {
|
||||
node->info.max_input_ports = max_input_ports;
|
||||
node->info.change_mask |= PW_NODE_CHANGE_MASK_INPUT_PORTS;
|
||||
}
|
||||
if (node->info.max_output_ports != max_output_ports) {
|
||||
node->info.max_output_ports = max_output_ports;
|
||||
node->info.change_mask |= PW_NODE_CHANGE_MASK_OUTPUT_PORTS;
|
||||
}
|
||||
|
||||
input_port_ids = alloca(sizeof(uint32_t) * n_input_ports);
|
||||
output_port_ids = alloca(sizeof(uint32_t) * n_output_ports);
|
||||
|
||||
res = spa_node_get_port_ids(node->node,
|
||||
input_port_ids,
|
||||
max_input_ports,
|
||||
output_port_ids,
|
||||
max_output_ports);
|
||||
if (res < 0)
|
||||
return res;
|
||||
|
||||
pw_log_debug("node %p: update_port ids input %u/%u, outputs %u/%u", node,
|
||||
n_input_ports, max_input_ports, n_output_ports, max_output_ports);
|
||||
|
||||
update_port_map(node, PW_DIRECTION_INPUT, &node->input_port_map, input_port_ids, n_input_ports);
|
||||
update_port_map(node, PW_DIRECTION_OUTPUT, &node->output_port_map, output_port_ids, n_output_ports);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
clear_info(struct pw_node *this)
|
||||
{
|
||||
|
|
@ -481,8 +386,6 @@ int pw_node_register(struct pw_node *this,
|
|||
if (properties == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
pw_node_update_ports(this);
|
||||
|
||||
if ((str = pw_properties_get(this->properties, "media.class")) != NULL)
|
||||
pw_properties_set(properties, "media.class", str);
|
||||
pw_properties_set(properties, "node.name", this->info.name);
|
||||
|
|
@ -881,6 +784,48 @@ static void node_info(void *data, const struct spa_node_info *info)
|
|||
pw_node_update_properties(node, info->props);
|
||||
}
|
||||
|
||||
static void node_port_info(void *data, enum spa_direction direction, uint32_t port_id,
|
||||
const struct spa_port_info *info)
|
||||
{
|
||||
struct pw_node *node = data;
|
||||
struct pw_port *port = pw_node_find_port(node, direction, port_id);
|
||||
|
||||
if (info == NULL) {
|
||||
if (port) {
|
||||
pw_log_debug("node %p: %s port %d removed", node,
|
||||
pw_direction_as_string(direction), port_id);
|
||||
pw_port_destroy(port);
|
||||
} else {
|
||||
pw_log_warn("node %p: %s port %d unknown", node,
|
||||
pw_direction_as_string(direction), port_id);
|
||||
}
|
||||
} else if (port) {
|
||||
if (info->change_mask & SPA_PORT_CHANGE_MASK_FLAGS)
|
||||
port->spa_flags = info->flags;
|
||||
if (info->change_mask & SPA_PORT_CHANGE_MASK_PROPS)
|
||||
pw_port_update_properties(port, info->props);
|
||||
} else {
|
||||
int res;
|
||||
struct pw_properties *props;
|
||||
|
||||
pw_log_debug("node %p: %s port %d added", node,
|
||||
pw_direction_as_string(direction), port_id);
|
||||
|
||||
props = info->props ?
|
||||
pw_properties_new_dict(info->props) :
|
||||
pw_properties_new(NULL, NULL);
|
||||
|
||||
if ((port = pw_port_new(direction, port_id, info->flags, props,
|
||||
node->port_user_data_size))) {
|
||||
if ((res = pw_port_add(port, node)) < 0) {
|
||||
pw_log_error("node %p: can't add port %p: %d, %s",
|
||||
node, port, res, spa_strerror(res));
|
||||
pw_port_destroy(port);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void node_done(void *data, int seq, int res)
|
||||
{
|
||||
struct pw_node *node = data;
|
||||
|
|
@ -897,15 +842,6 @@ static void node_event(void *data, struct spa_event *event)
|
|||
|
||||
pw_log_trace("node %p: event %d", node, SPA_EVENT_TYPE(event));
|
||||
pw_node_events_event(node, event);
|
||||
|
||||
switch (SPA_NODE_EVENT_ID(event)) {
|
||||
case SPA_NODE_EVENT_PortsChanged:
|
||||
pw_node_update_ports(node);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void node_ready(void *data, int status)
|
||||
|
|
@ -944,6 +880,7 @@ static void node_reuse_buffer(void *data, uint32_t port_id, uint32_t buffer_id)
|
|||
static const struct spa_node_callbacks node_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
.info = node_info,
|
||||
.port_info = node_port_info,
|
||||
.done = node_done,
|
||||
.event = node_event,
|
||||
.ready = node_ready,
|
||||
|
|
@ -1027,6 +964,8 @@ void pw_node_destroy(struct pw_node *node)
|
|||
if (node->registered)
|
||||
spa_list_remove(&node->link);
|
||||
|
||||
spa_node_set_callbacks(node->node, NULL, NULL);
|
||||
|
||||
pw_log_debug("node %p: unlink ports", node);
|
||||
spa_list_for_each(port, &node->input_ports, link)
|
||||
pw_port_unlink(port);
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@ int pw_port_release_mix(struct pw_port *port, struct pw_port_mix *mix)
|
|||
SPA_EXPORT
|
||||
struct pw_port *pw_port_new(enum pw_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t spa_flags,
|
||||
struct pw_properties *properties,
|
||||
size_t user_data_size)
|
||||
{
|
||||
|
|
@ -263,8 +264,14 @@ struct pw_port *pw_port_new(enum pw_direction direction,
|
|||
if (properties == NULL)
|
||||
goto no_mem;
|
||||
|
||||
if (SPA_FLAG_CHECK(spa_flags, SPA_PORT_INFO_FLAG_PHYSICAL))
|
||||
pw_properties_set(properties, "port.physical", "1");
|
||||
if (SPA_FLAG_CHECK(spa_flags, SPA_PORT_INFO_FLAG_TERMINAL))
|
||||
pw_properties_set(properties, "port.terminal", "1");
|
||||
|
||||
this->direction = direction;
|
||||
this->port_id = port_id;
|
||||
this->spa_flags = spa_flags;
|
||||
this->properties = properties;
|
||||
this->state = PW_PORT_STATE_INIT;
|
||||
this->rt.io = SPA_IO_BUFFERS_INIT;
|
||||
|
|
@ -554,10 +561,8 @@ int pw_port_add(struct pw_port *port, struct pw_node *node)
|
|||
struct spa_list *ports;
|
||||
struct pw_map *portmap;
|
||||
struct pw_port *find;
|
||||
const char *str, *dir;
|
||||
int res;
|
||||
bool control;
|
||||
const struct spa_port_info *spa_info;
|
||||
const char *str, *dir;
|
||||
|
||||
if (port->node != NULL)
|
||||
return -EEXIST;
|
||||
|
|
@ -574,24 +579,6 @@ int pw_port_add(struct pw_port *port, struct pw_node *node)
|
|||
if (find != NULL)
|
||||
return -EEXIST;
|
||||
|
||||
if ((res = spa_node_port_get_info(node->node,
|
||||
port->direction, port_id,
|
||||
&spa_info)) < 0) {
|
||||
/* can't get port info, try to add it.. */
|
||||
if ((res = spa_node_add_port(node->node, port->direction, port_id)) < 0)
|
||||
goto add_failed;
|
||||
|
||||
SPA_FLAG_SET(port->flags, PW_PORT_FLAG_TO_REMOVE);
|
||||
|
||||
/* try again */
|
||||
if ((res = spa_node_port_get_info(node->node,
|
||||
port->direction, port_id,
|
||||
&spa_info)) < 0)
|
||||
goto info_failed;
|
||||
}
|
||||
if (spa_info->props)
|
||||
pw_port_update_properties(port, spa_info->props);
|
||||
|
||||
port->node = node;
|
||||
|
||||
pw_node_events_port_init(node, port);
|
||||
|
|
@ -601,28 +588,40 @@ int pw_port_add(struct pw_port *port, struct pw_node *node)
|
|||
dir = port->direction == PW_DIRECTION_INPUT ? "in" : "out";
|
||||
pw_properties_set(port->properties, "port.direction", dir);
|
||||
|
||||
control = PW_PORT_IS_CONTROL(port);
|
||||
if (control) {
|
||||
dir = port->direction == PW_DIRECTION_INPUT ? "control" : "notify";
|
||||
pw_properties_set(port->properties, "port.control", "1");
|
||||
}
|
||||
|
||||
if ((str = pw_properties_get(port->properties, "port.name")) == NULL) {
|
||||
if ((str = pw_properties_get(port->properties, "port.channel")) != NULL &&
|
||||
strcmp(str, "UNK") != 0) {
|
||||
pw_properties_setf(port->properties, "port.name", "%s_%s", dir, str);
|
||||
}
|
||||
else {
|
||||
pw_properties_setf(port->properties, "port.name", "%s_%d", dir, port_id);
|
||||
pw_properties_setf(port->properties, "port.name", "%s_%d", dir, port->port_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (SPA_FLAG_CHECK(spa_info->flags, SPA_PORT_INFO_FLAG_PHYSICAL))
|
||||
pw_properties_set(port->properties, "port.physical", "1");
|
||||
if (SPA_FLAG_CHECK(spa_info->flags, SPA_PORT_INFO_FLAG_TERMINAL))
|
||||
pw_properties_set(port->properties, "port.terminal", "1");
|
||||
control = PW_PORT_IS_CONTROL(port);
|
||||
if (control) {
|
||||
dir = port->direction == PW_DIRECTION_INPUT ? "control" : "notify";
|
||||
pw_properties_set(port->properties, "port.control", "1");
|
||||
}
|
||||
|
||||
pw_log_debug("port %p: %d add to node %p %08x", port, port_id, node, spa_info->flags);
|
||||
if (control) {
|
||||
pw_log_debug("port %p: setting node control", port);
|
||||
} else {
|
||||
pw_log_debug("port %p: setting node io", port);
|
||||
spa_node_port_set_io(node->node,
|
||||
port->direction, port->port_id,
|
||||
SPA_IO_Buffers,
|
||||
&port->rt.io, sizeof(port->rt.io));
|
||||
|
||||
if (port->mix->port_set_io) {
|
||||
spa_node_port_set_io(port->mix,
|
||||
pw_direction_reverse(port->direction), 0,
|
||||
SPA_IO_Buffers,
|
||||
&port->rt.io, sizeof(port->rt.io));
|
||||
}
|
||||
}
|
||||
|
||||
pw_log_debug("port %p: %d add to node %p", port, port_id, node);
|
||||
|
||||
spa_list_append(ports, &port->link);
|
||||
pw_map_insert_at(portmap, port_id, port);
|
||||
|
|
@ -635,23 +634,6 @@ int pw_port_add(struct pw_port *port, struct pw_node *node)
|
|||
node->info.change_mask |= PW_NODE_CHANGE_MASK_OUTPUT_PORTS;
|
||||
}
|
||||
|
||||
if (control) {
|
||||
pw_log_debug("port %p: setting node control", port);
|
||||
} else {
|
||||
pw_log_debug("port %p: setting node io", port);
|
||||
spa_node_port_set_io(node->node,
|
||||
port->direction, port_id,
|
||||
SPA_IO_Buffers,
|
||||
&port->rt.io, sizeof(port->rt.io));
|
||||
|
||||
if (port->mix->port_set_io) {
|
||||
spa_node_port_set_io(port->mix,
|
||||
pw_direction_reverse(port->direction), 0,
|
||||
SPA_IO_Buffers,
|
||||
&port->rt.io, sizeof(port->rt.io));
|
||||
}
|
||||
}
|
||||
|
||||
if (node->global)
|
||||
pw_port_register(port, node->global->owner, node->global,
|
||||
pw_properties_copy(port->properties));
|
||||
|
|
@ -664,15 +646,6 @@ int pw_port_add(struct pw_port *port, struct pw_node *node)
|
|||
pw_node_events_port_added(node, port);
|
||||
|
||||
return 0;
|
||||
|
||||
add_failed:
|
||||
pw_log_error("node %p: could not add port %d %s", node, port_id,
|
||||
spa_strerror(res));
|
||||
return res;
|
||||
info_failed:
|
||||
pw_log_error("node %p: could not get port info %d %s", node, port_id,
|
||||
spa_strerror(res));
|
||||
return res;
|
||||
}
|
||||
|
||||
static int do_destroy_link(void *data, struct pw_link *link)
|
||||
|
|
|
|||
|
|
@ -427,6 +427,7 @@ struct pw_port {
|
|||
#define PW_PORT_FLAG_BUFFERS (1<<1) /**< port has data */
|
||||
#define PW_PORT_FLAG_CONTROL (1<<2) /**< port has control */
|
||||
uint32_t flags;
|
||||
uint32_t spa_flags;
|
||||
|
||||
enum pw_direction direction; /**< port direction */
|
||||
uint32_t port_id; /**< port id */
|
||||
|
|
@ -452,7 +453,7 @@ struct pw_port {
|
|||
#define PW_PORT_MIX_FLAG_MIX_ONLY (1<<1) /**< only negotiate mix ports */
|
||||
uint32_t mix_flags; /**< flags for the mixing */
|
||||
|
||||
int allocated:1; /**< if buffers are allocated */
|
||||
int allocated:1; /**< if buffers are allocated */
|
||||
|
||||
struct pw_map mix_port_map; /**< map from port_id from mixer */
|
||||
uint32_t n_mix;
|
||||
|
|
@ -691,6 +692,7 @@ const struct pw_export_type *pw_core_find_export_type(struct pw_core *core, uint
|
|||
struct pw_port *
|
||||
pw_port_new(enum pw_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t spa_flags,
|
||||
struct pw_properties *properties,
|
||||
size_t user_data_size);
|
||||
|
||||
|
|
|
|||
|
|
@ -313,51 +313,27 @@ static int impl_send_command(struct spa_node *node, const struct spa_command *co
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void emit_port_info(struct stream *d)
|
||||
{
|
||||
if (d->callbacks && d->callbacks->port_info) {
|
||||
struct spa_port_info info;
|
||||
info = SPA_PORT_INFO_INIT();
|
||||
info.change_mask = SPA_PORT_CHANGE_MASK_FLAGS;
|
||||
info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
d->callbacks->port_info(d->callbacks_data, d->direction, 0, &info);
|
||||
}
|
||||
}
|
||||
|
||||
static int impl_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks, void *data)
|
||||
{
|
||||
struct stream *d = SPA_CONTAINER_OF(node, struct stream, impl_node);
|
||||
|
||||
d->callbacks = callbacks;
|
||||
d->callbacks_data = data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_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)
|
||||
{
|
||||
struct stream *d = SPA_CONTAINER_OF(node, struct stream, impl_node);
|
||||
if (d->direction == SPA_DIRECTION_INPUT) {
|
||||
*n_input_ports = 1;
|
||||
*max_input_ports = MAX_PORTS;
|
||||
*n_output_ports = *max_output_ports = 0;
|
||||
}
|
||||
else {
|
||||
*n_input_ports = *max_input_ports = 0;
|
||||
*n_output_ports = 1;
|
||||
*max_output_ports = MAX_PORTS;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
emit_port_info(d);
|
||||
|
||||
static int impl_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)
|
||||
{
|
||||
struct stream *impl = SPA_CONTAINER_OF(node, struct stream, impl_node);
|
||||
|
||||
if (impl->direction == SPA_DIRECTION_INPUT) {
|
||||
if (n_input_ids > 0)
|
||||
input_ids[0] = 0;
|
||||
}
|
||||
else {
|
||||
if (n_output_ids > 0)
|
||||
output_ids[0] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -400,20 +376,6 @@ static int impl_port_set_io(struct spa_node *node, enum spa_direction direction,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int impl_port_get_info(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct stream *d = SPA_CONTAINER_OF(node, struct stream, impl_node);
|
||||
|
||||
d->port_info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
d->port_info.rate = 0;
|
||||
d->port_info.props = NULL;
|
||||
|
||||
*info = &d->port_info;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t id, uint32_t *index,
|
||||
|
|
@ -794,10 +756,7 @@ static const struct spa_node impl_node = {
|
|||
.set_io = impl_set_io,
|
||||
.send_command = impl_send_command,
|
||||
.set_callbacks = impl_set_callbacks,
|
||||
.get_n_ports = impl_get_n_ports,
|
||||
.get_port_ids = impl_get_port_ids,
|
||||
.port_set_io = impl_port_set_io,
|
||||
.port_get_info = impl_port_get_info,
|
||||
.port_enum_params = impl_port_enum_params,
|
||||
.port_set_param = impl_port_set_param,
|
||||
.port_use_buffers = impl_port_use_buffers,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue