mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Use errno for result errors
Make new enumeration for data transport status and use errno style error numbers for errors.
This commit is contained in:
parent
dda28b1589
commit
6fb0f580ea
86 changed files with 2019 additions and 1988 deletions
|
|
@ -70,9 +70,9 @@ struct spa_clock {
|
|||
* can be modified. The modifications will take effect after a call
|
||||
* to spa_clock::set_props.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when clock or props are %NULL
|
||||
* #SPA_RESULT_NOT_IMPLEMENTED when there are no properties
|
||||
* Returns: 0 on success
|
||||
* -EINVAL when clock or props are %NULL
|
||||
* -ENOTSUP when there are no properties
|
||||
* implemented on @clock
|
||||
*/
|
||||
int (*enum_params) (struct spa_clock *clock,
|
||||
|
|
@ -93,12 +93,11 @@ struct spa_clock {
|
|||
*
|
||||
* If @props is NULL, all the properties are reset to their defaults.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when clock is %NULL
|
||||
* #SPA_RESULT_NOT_IMPLEMENTED when no properties can be
|
||||
* Returns: 0 on success
|
||||
* -EINVAL when clock is %NULL
|
||||
* -ENOTSUP when no properties can be
|
||||
* modified on @clock.
|
||||
* #SPA_RESULT_WRONG_PROPERTY_TYPE when a property has the wrong
|
||||
* type.
|
||||
* -ENOENT when the param with id is not supported
|
||||
*/
|
||||
int (*set_param) (struct spa_clock *clock,
|
||||
uint32_t id, uint32_t flags,
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ static inline void spa_graph_data_port_check(struct spa_graph_data *data, struct
|
|||
struct spa_graph_node *node = port->node;
|
||||
uint32_t required = node->required[SPA_DIRECTION_INPUT];
|
||||
|
||||
if (port->io->status == SPA_RESULT_HAVE_BUFFER)
|
||||
if (port->io->status == SPA_STATUS_HAVE_BUFFER)
|
||||
node->ready[SPA_DIRECTION_INPUT]++;
|
||||
|
||||
spa_debug("port %p node %p check %d %d %d", port, node,
|
||||
|
|
@ -85,9 +85,9 @@ static inline bool spa_graph_data_iterate(struct spa_graph_data *data)
|
|||
switch (n->state) {
|
||||
case SPA_GRAPH_STATE_IN:
|
||||
state = spa_node_process_input(n->implementation);
|
||||
if (state == SPA_RESULT_NEED_BUFFER)
|
||||
if (state == SPA_STATUS_NEED_BUFFER)
|
||||
n->state = SPA_GRAPH_STATE_CHECK_IN;
|
||||
else if (state == SPA_RESULT_HAVE_BUFFER)
|
||||
else if (state == SPA_STATUS_HAVE_BUFFER)
|
||||
n->state = SPA_GRAPH_STATE_CHECK_OUT;
|
||||
spa_debug("node %p processed input state %d", n, n->state);
|
||||
if (n == data->node)
|
||||
|
|
@ -97,9 +97,9 @@ static inline bool spa_graph_data_iterate(struct spa_graph_data *data)
|
|||
|
||||
case SPA_GRAPH_STATE_OUT:
|
||||
state = spa_node_process_output(n->implementation);
|
||||
if (state == SPA_RESULT_NEED_BUFFER)
|
||||
if (state == SPA_STATUS_NEED_BUFFER)
|
||||
n->state = SPA_GRAPH_STATE_CHECK_IN;
|
||||
else if (state == SPA_RESULT_HAVE_BUFFER)
|
||||
else if (state == SPA_STATUS_HAVE_BUFFER)
|
||||
n->state = SPA_GRAPH_STATE_CHECK_OUT;
|
||||
spa_debug("node %p processed output state %d", n, n->state);
|
||||
spa_list_append(&data->ready, &n->ready_link);
|
||||
|
|
@ -109,14 +109,14 @@ static inline bool spa_graph_data_iterate(struct spa_graph_data *data)
|
|||
n->ready[SPA_DIRECTION_INPUT] = 0;
|
||||
spa_list_for_each(p, &n->ports[SPA_DIRECTION_INPUT], link) {
|
||||
struct spa_graph_node *pn = p->peer->node;
|
||||
if (p->io->status == SPA_RESULT_NEED_BUFFER) {
|
||||
if (p->io->status == SPA_STATUS_NEED_BUFFER) {
|
||||
if (pn != data->node
|
||||
|| pn->flags & SPA_GRAPH_NODE_FLAG_ASYNC) {
|
||||
pn->state = SPA_GRAPH_STATE_OUT;
|
||||
spa_list_append(&data->ready,
|
||||
&pn->ready_link);
|
||||
}
|
||||
} else if (p->io->status == SPA_RESULT_OK)
|
||||
} else if (p->io->status == SPA_STATUS_OK)
|
||||
n->ready[SPA_DIRECTION_INPUT]++;
|
||||
}
|
||||
case SPA_GRAPH_STATE_CHECK_OUT:
|
||||
|
|
@ -143,7 +143,7 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
|
||||
while(spa_graph_data_iterate(data));
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *node)
|
||||
|
|
@ -157,7 +157,7 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
|
||||
while(spa_graph_data_iterate(data));
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_graph_callbacks spa_graph_impl_default = {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ static inline int spa_graph_scheduler_default(struct spa_graph_node *node)
|
|||
else if (node->action == SPA_GRAPH_ACTION_OUT)
|
||||
res = spa_node_process_output(n);
|
||||
else
|
||||
res = SPA_RESULT_ERROR;
|
||||
res = -EBADF;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ static inline void spa_graph_port_check(struct spa_graph *graph, struct spa_grap
|
|||
{
|
||||
struct spa_graph_node *node = port->node;
|
||||
|
||||
if (port->io->status == SPA_RESULT_HAVE_BUFFER)
|
||||
if (port->io->status == SPA_STATUS_HAVE_BUFFER)
|
||||
node->ready++;
|
||||
|
||||
spa_debug("port %p node %p check %d %d %d", port, node, port->io->status, node->ready, node->required);
|
||||
|
|
@ -65,7 +65,7 @@ static inline void spa_graph_node_update(struct spa_graph *graph, struct spa_gra
|
|||
|
||||
node->ready = 0;
|
||||
spa_list_for_each(p, &node->ports[SPA_DIRECTION_INPUT], link) {
|
||||
if (p->io->status == SPA_RESULT_OK && !(node->flags & SPA_GRAPH_NODE_FLAG_ASYNC))
|
||||
if (p->io->status == SPA_STATUS_OK && !(node->flags & SPA_GRAPH_NODE_FLAG_ASYNC))
|
||||
node->ready++;
|
||||
}
|
||||
spa_debug("node %p update %d ready", node, node->ready);
|
||||
|
|
@ -111,11 +111,11 @@ next:
|
|||
|
||||
if (n->state != SPA_GRAPH_STATE_END) {
|
||||
spa_debug("node %p add ready for CHECK", n);
|
||||
if (state == SPA_RESULT_NEED_BUFFER)
|
||||
if (state == SPA_STATUS_NEED_BUFFER)
|
||||
n->state = SPA_GRAPH_STATE_CHECK_IN;
|
||||
else if (state == SPA_RESULT_HAVE_BUFFER)
|
||||
else if (state == SPA_STATUS_HAVE_BUFFER)
|
||||
n->state = SPA_GRAPH_STATE_CHECK_OUT;
|
||||
else if (state == SPA_RESULT_OK)
|
||||
else if (state == SPA_STATUS_OK)
|
||||
n->state = SPA_GRAPH_STATE_CHECK_OK;
|
||||
spa_list_append(&graph->ready, &n->ready_link);
|
||||
}
|
||||
|
|
@ -128,14 +128,14 @@ next:
|
|||
n->ready = 0;
|
||||
spa_list_for_each(p, &n->ports[SPA_DIRECTION_INPUT], link) {
|
||||
struct spa_graph_node *pn = p->peer->node;
|
||||
if (p->io->status == SPA_RESULT_NEED_BUFFER) {
|
||||
if (p->io->status == SPA_STATUS_NEED_BUFFER) {
|
||||
if (pn != graph->node
|
||||
|| pn->flags & SPA_GRAPH_NODE_FLAG_ASYNC) {
|
||||
pn->state = SPA_GRAPH_STATE_OUT;
|
||||
spa_debug("node %p add ready OUT", n);
|
||||
spa_list_append(&graph->ready, &pn->ready_link);
|
||||
}
|
||||
} else if (p->io->status == SPA_RESULT_OK)
|
||||
} else if (p->io->status == SPA_STATUS_OK)
|
||||
n->ready++;
|
||||
}
|
||||
break;
|
||||
|
|
@ -162,7 +162,7 @@ next:
|
|||
static inline void spa_graph_scheduler_pull(struct spa_graph *graph, struct spa_graph_node *node)
|
||||
{
|
||||
node->action = SPA_GRAPH_ACTION_CHECK;
|
||||
node->state = SPA_RESULT_NEED_BUFFER;
|
||||
node->state = SPA_STATUS_NEED_BUFFER;
|
||||
graph->node = node;
|
||||
spa_debug("node %p start pull", node);
|
||||
if (node->ready_link.next == NULL)
|
||||
|
|
|
|||
|
|
@ -44,11 +44,11 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
continue;
|
||||
pnode = pport->node;
|
||||
spa_debug("node %p peer %p io %d %d", node, pnode, pport->io->status, pport->io->buffer_id);
|
||||
if (pport->io->status == SPA_RESULT_NEED_BUFFER) {
|
||||
if (pport->io->status == SPA_STATUS_NEED_BUFFER) {
|
||||
if (pnode->ready_link.next == NULL)
|
||||
spa_list_append(&ready, &pnode->ready_link);
|
||||
}
|
||||
else if (pport->io->status == SPA_RESULT_OK &&
|
||||
else if (pport->io->status == SPA_STATUS_OK &&
|
||||
!(pnode->flags & SPA_GRAPH_NODE_FLAG_ASYNC))
|
||||
node->ready[SPA_DIRECTION_INPUT]++;
|
||||
}
|
||||
|
|
@ -56,11 +56,11 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
spa_list_for_each_safe(n, t, &ready, ready_link) {
|
||||
n->state = spa_node_process_output(n->implementation);
|
||||
spa_debug("peer %p processed out %d", n, n->state);
|
||||
if (n->state == SPA_RESULT_NEED_BUFFER)
|
||||
if (n->state == SPA_STATUS_NEED_BUFFER)
|
||||
spa_graph_need_input(n->graph, n);
|
||||
else {
|
||||
spa_list_for_each(p, &n->ports[SPA_DIRECTION_OUTPUT], link) {
|
||||
if (p->io->status == SPA_RESULT_HAVE_BUFFER)
|
||||
if (p->io->status == SPA_STATUS_HAVE_BUFFER)
|
||||
node->ready[SPA_DIRECTION_INPUT]++;
|
||||
}
|
||||
}
|
||||
|
|
@ -74,15 +74,15 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
node->ready[SPA_DIRECTION_INPUT] == node->required[SPA_DIRECTION_INPUT]) {
|
||||
node->state = spa_node_process_input(node->implementation);
|
||||
spa_debug("node %p processed in %d", node, node->state);
|
||||
if (node->state == SPA_RESULT_HAVE_BUFFER) {
|
||||
if (node->state == SPA_STATUS_HAVE_BUFFER) {
|
||||
spa_list_for_each(p, &node->ports[SPA_DIRECTION_OUTPUT], link) {
|
||||
if (p->io->status == SPA_RESULT_HAVE_BUFFER)
|
||||
if (p->io->status == SPA_STATUS_HAVE_BUFFER)
|
||||
if (p->peer)
|
||||
p->peer->node->ready[SPA_DIRECTION_INPUT]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *node)
|
||||
|
|
@ -106,7 +106,7 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
}
|
||||
|
||||
pnode = pport->node;
|
||||
if (pport->io->status == SPA_RESULT_HAVE_BUFFER)
|
||||
if (pport->io->status == SPA_STATUS_HAVE_BUFFER)
|
||||
pnode->ready[SPA_DIRECTION_INPUT]++;
|
||||
|
||||
pready = pnode->ready[SPA_DIRECTION_INPUT];
|
||||
|
|
@ -123,12 +123,12 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
spa_list_for_each_safe(n, t, &ready, ready_link) {
|
||||
n->state = spa_node_process_input(n->implementation);
|
||||
spa_debug("node %p chain processed in %d", n, n->state);
|
||||
if (n->state == SPA_RESULT_HAVE_BUFFER)
|
||||
if (n->state == SPA_STATUS_HAVE_BUFFER)
|
||||
spa_graph_have_output(n->graph, n);
|
||||
else {
|
||||
n->ready[SPA_DIRECTION_INPUT] = 0;
|
||||
spa_list_for_each(p, &n->ports[SPA_DIRECTION_INPUT], link) {
|
||||
if (p->io->status == SPA_RESULT_OK &&
|
||||
if (p->io->status == SPA_STATUS_OK &&
|
||||
!(n->flags & SPA_GRAPH_NODE_FLAG_ASYNC))
|
||||
n->ready[SPA_DIRECTION_INPUT]++;
|
||||
}
|
||||
|
|
@ -139,14 +139,14 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
|
||||
node->state = spa_node_process_output(node->implementation);
|
||||
spa_debug("node %p processed out %d", node, node->state);
|
||||
if (node->state == SPA_RESULT_NEED_BUFFER) {
|
||||
if (node->state == SPA_STATUS_NEED_BUFFER) {
|
||||
node->ready[SPA_DIRECTION_INPUT] = 0;
|
||||
spa_list_for_each(p, &node->ports[SPA_DIRECTION_INPUT], link) {
|
||||
if (p->io->status == SPA_RESULT_OK && !(node->flags & SPA_GRAPH_NODE_FLAG_ASYNC))
|
||||
if (p->io->status == SPA_STATUS_OK && !(node->flags & SPA_GRAPH_NODE_FLAG_ASYNC))
|
||||
node->ready[SPA_DIRECTION_INPUT]++;
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_graph_callbacks spa_graph_impl_default = {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ static inline void check_input(struct spa_graph_node *node)
|
|||
debug("node %p input peer %p io %d %d\n", node, pnode, pport->io->status, pport->io->buffer_id);
|
||||
|
||||
pnode->ready[SPA_DIRECTION_OUTPUT]++;
|
||||
if (pport->io->status == SPA_RESULT_OK)
|
||||
if (pport->io->status == SPA_STATUS_OK)
|
||||
node->ready[SPA_DIRECTION_INPUT]++;
|
||||
|
||||
debug("node %p input peer %p out %d %d\n", node, pnode,
|
||||
|
|
@ -81,7 +81,7 @@ static inline void check_output(struct spa_graph_node *node)
|
|||
pnode = pport->node;
|
||||
debug("node %p output peer %p io %d %d\n", node, pnode, pport->io->status, pport->io->buffer_id);
|
||||
|
||||
if (pport->io->status == SPA_RESULT_HAVE_BUFFER) {
|
||||
if (pport->io->status == SPA_STATUS_HAVE_BUFFER) {
|
||||
pnode->ready[SPA_DIRECTION_INPUT]++;
|
||||
node->required[SPA_DIRECTION_OUTPUT]++;
|
||||
}
|
||||
|
|
@ -97,21 +97,21 @@ static inline void spa_graph_impl_activate(void *data, struct spa_graph_node *no
|
|||
int res;
|
||||
|
||||
debug("node %p activate %d\n", node, node->state);
|
||||
if (node->state == SPA_RESULT_NEED_BUFFER) {
|
||||
if (node->state == SPA_STATUS_NEED_BUFFER) {
|
||||
res = spa_node_process_input(node->implementation);
|
||||
debug("node %p process in %d\n", node, res);
|
||||
}
|
||||
else if (node->state == SPA_RESULT_HAVE_BUFFER) {
|
||||
else if (node->state == SPA_STATUS_HAVE_BUFFER) {
|
||||
res = spa_node_process_output(node->implementation);
|
||||
debug("node %p process out %d\n", node, res);
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
if (res == SPA_RESULT_NEED_BUFFER || (res == SPA_RESULT_OK && node->state == SPA_RESULT_NEED_BUFFER)) {
|
||||
if (res == SPA_STATUS_NEED_BUFFER || (res == SPA_STATUS_OK && node->state == SPA_STATUS_NEED_BUFFER)) {
|
||||
check_input(node);
|
||||
}
|
||||
else if (res == SPA_RESULT_HAVE_BUFFER) {
|
||||
else if (res == SPA_STATUS_HAVE_BUFFER) {
|
||||
check_output(node);
|
||||
}
|
||||
node->state = res;
|
||||
|
|
@ -125,7 +125,7 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
|
||||
debug("node %p start pull\n", node);
|
||||
|
||||
node->state = SPA_RESULT_NEED_BUFFER;
|
||||
node->state = SPA_STATUS_NEED_BUFFER;
|
||||
node->ready[SPA_DIRECTION_INPUT] = 0;
|
||||
|
||||
spa_list_for_each(p, &node->ports[SPA_DIRECTION_INPUT], link) {
|
||||
|
|
@ -140,19 +140,19 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
debug("node %p pull peer %p io %d %d\n", node, pnode, pport->io->status, pport->io->buffer_id);
|
||||
|
||||
pnode->ready[SPA_DIRECTION_OUTPUT]++;
|
||||
if (pport->io->status == SPA_RESULT_OK)
|
||||
if (pport->io->status == SPA_STATUS_OK)
|
||||
node->ready[SPA_DIRECTION_INPUT]++;
|
||||
|
||||
debug("node %p pull peer %p out %d %d\n", node, pnode, prequired, pnode->ready[SPA_DIRECTION_OUTPUT]);
|
||||
if (prequired > 0 && pnode->ready[SPA_DIRECTION_OUTPUT] >= prequired) {
|
||||
pnode->state = SPA_RESULT_HAVE_BUFFER;
|
||||
pnode->state = SPA_STATUS_HAVE_BUFFER;
|
||||
spa_graph_impl_activate(data, pnode);
|
||||
}
|
||||
}
|
||||
|
||||
debug("node %p end pull\n", node);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *node)
|
||||
|
|
@ -162,7 +162,7 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
|
||||
debug("node %p start push\n", node);
|
||||
|
||||
node->state = SPA_RESULT_HAVE_BUFFER;
|
||||
node->state = SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
node->ready[SPA_DIRECTION_OUTPUT] = 0;
|
||||
node->required[SPA_DIRECTION_OUTPUT] = 0;
|
||||
|
|
@ -179,13 +179,13 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
prequired = pnode->required[SPA_DIRECTION_INPUT];
|
||||
debug("node %p push peer %p io %d %d\n", node, pnode, pport->io->status, pport->io->buffer_id);
|
||||
|
||||
if (pport->io->status == SPA_RESULT_HAVE_BUFFER) {
|
||||
if (pport->io->status == SPA_STATUS_HAVE_BUFFER) {
|
||||
pnode->ready[SPA_DIRECTION_INPUT]++;
|
||||
node->required[SPA_DIRECTION_OUTPUT]++;
|
||||
}
|
||||
debug("node %p push peer %p in %d %d\n", node, pnode, prequired, pnode->ready[SPA_DIRECTION_INPUT]);
|
||||
if (prequired > 0 && pnode->ready[SPA_DIRECTION_INPUT] >= prequired) {
|
||||
pnode->state = SPA_RESULT_NEED_BUFFER;
|
||||
pnode->state = SPA_STATUS_NEED_BUFFER;
|
||||
spa_graph_impl_activate(data, pnode);
|
||||
}
|
||||
}
|
||||
|
|
@ -195,7 +195,7 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
}
|
||||
debug("node %p end push\n", node);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_graph_callbacks spa_graph_impl_default = {
|
||||
|
|
|
|||
|
|
@ -44,18 +44,18 @@ static inline void spa_graph_impl_activate(void *data, struct spa_graph_node *no
|
|||
int res = node->state;
|
||||
|
||||
debug("node %p activate %d\n", node, node->state);
|
||||
if (node->state == SPA_RESULT_NEED_BUFFER) {
|
||||
if (node->state == SPA_STATUS_NEED_BUFFER) {
|
||||
res = spa_node_process_input(node->implementation);
|
||||
debug("node %p process in %d\n", node, res);
|
||||
}
|
||||
else if (node->state == SPA_RESULT_HAVE_BUFFER) {
|
||||
else if (node->state == SPA_STATUS_HAVE_BUFFER) {
|
||||
res = spa_node_process_output(node->implementation);
|
||||
debug("node %p process out %d\n", node, res);
|
||||
}
|
||||
|
||||
if (recurse && (res == SPA_RESULT_NEED_BUFFER || res == SPA_RESULT_OK))
|
||||
if (recurse && (res == SPA_STATUS_NEED_BUFFER || res == SPA_STATUS_OK))
|
||||
spa_graph_impl_need_input(data, node);
|
||||
else if (recurse && (res == SPA_RESULT_HAVE_BUFFER))
|
||||
else if (recurse && (res == SPA_STATUS_HAVE_BUFFER))
|
||||
spa_graph_impl_have_output(data, node);
|
||||
else
|
||||
node->state = res;
|
||||
|
|
@ -70,7 +70,7 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
|
||||
debug("node %p start pull\n", node);
|
||||
|
||||
node->state = SPA_RESULT_NEED_BUFFER;
|
||||
node->state = SPA_STATUS_NEED_BUFFER;
|
||||
node->ready[SPA_DIRECTION_INPUT] = 0;
|
||||
required = node->required[SPA_DIRECTION_INPUT];
|
||||
|
||||
|
|
@ -85,15 +85,15 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
prequired = pnode->required[SPA_DIRECTION_OUTPUT];
|
||||
debug("node %p pull peer %p io %d %d\n", node, pnode, pport->io->status, pport->io->buffer_id);
|
||||
|
||||
if (pport->io->status == SPA_RESULT_NEED_BUFFER)
|
||||
if (pport->io->status == SPA_STATUS_NEED_BUFFER)
|
||||
pnode->ready[SPA_DIRECTION_OUTPUT]++;
|
||||
else if (pport->io->status == SPA_RESULT_OK)
|
||||
else if (pport->io->status == SPA_STATUS_OK)
|
||||
node->ready[SPA_DIRECTION_INPUT]++;
|
||||
|
||||
debug("node %p pull peer %p out %d %d\n", node, pnode, prequired, pnode->ready[SPA_DIRECTION_OUTPUT]);
|
||||
if (prequired > 0 && pnode->ready[SPA_DIRECTION_OUTPUT] >= prequired) {
|
||||
if (pnode->state == SPA_RESULT_NEED_BUFFER)
|
||||
pnode->state = SPA_RESULT_HAVE_BUFFER;
|
||||
if (pnode->state == SPA_STATUS_NEED_BUFFER)
|
||||
pnode->state = SPA_STATUS_HAVE_BUFFER;
|
||||
spa_graph_impl_activate(data, pnode, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
|
||||
debug("node %p end pull\n", node);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *node)
|
||||
|
|
@ -111,7 +111,7 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
|
||||
debug("node %p start push\n", node);
|
||||
|
||||
node->state = SPA_RESULT_HAVE_BUFFER;
|
||||
node->state = SPA_STATUS_HAVE_BUFFER;
|
||||
node->ready[SPA_DIRECTION_OUTPUT] = 0;
|
||||
node->required[SPA_DIRECTION_OUTPUT] = 0;
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
prequired = pnode->required[SPA_DIRECTION_INPUT];
|
||||
debug("node %p push peer %p io %d %d\n", node, pnode, pport->io->status, pport->io->buffer_id);
|
||||
|
||||
if (pport->io->status == SPA_RESULT_HAVE_BUFFER) {
|
||||
if (pport->io->status == SPA_STATUS_HAVE_BUFFER) {
|
||||
pnode->ready[SPA_DIRECTION_INPUT]++;
|
||||
node->required[SPA_DIRECTION_OUTPUT]++;
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
|
||||
debug("node %p end push\n", node);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_graph_callbacks spa_graph_impl_default = {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
}
|
||||
pnode = pport->node;
|
||||
|
||||
if (pport->io->status == SPA_RESULT_NEED_BUFFER) {
|
||||
if (pport->io->status == SPA_STATUS_NEED_BUFFER) {
|
||||
pnode->ready[SPA_DIRECTION_OUTPUT]++;
|
||||
node->required[SPA_DIRECTION_INPUT]++;
|
||||
}
|
||||
|
|
@ -70,13 +70,13 @@ static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *n
|
|||
pnode->state = spa_node_process_output(pnode->implementation);
|
||||
|
||||
spa_debug("peer %p processed out %d", pnode, pnode->state);
|
||||
if (pnode->state == SPA_RESULT_NEED_BUFFER)
|
||||
if (pnode->state == SPA_STATUS_NEED_BUFFER)
|
||||
spa_graph_need_input(pnode->graph, pnode);
|
||||
else if (pnode->state == SPA_RESULT_HAVE_BUFFER)
|
||||
else if (pnode->state == SPA_STATUS_HAVE_BUFFER)
|
||||
spa_graph_have_output(pnode->graph, pnode);
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *node)
|
||||
|
|
@ -98,7 +98,7 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
}
|
||||
pnode = pport->node;
|
||||
|
||||
if (p->io->status == SPA_RESULT_HAVE_BUFFER) {
|
||||
if (p->io->status == SPA_STATUS_HAVE_BUFFER) {
|
||||
pnode->ready[SPA_DIRECTION_INPUT]++;
|
||||
node->required[SPA_DIRECTION_OUTPUT]++;
|
||||
}
|
||||
|
|
@ -113,13 +113,13 @@ static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *
|
|||
pnode->state = spa_node_process_input(pnode->implementation);
|
||||
|
||||
spa_debug("node %p chain processed in %d", pnode, pnode->state);
|
||||
if (pnode->state == SPA_RESULT_HAVE_BUFFER)
|
||||
if (pnode->state == SPA_STATUS_HAVE_BUFFER)
|
||||
spa_graph_have_output(pnode->graph, pnode);
|
||||
else if (pnode->state == SPA_RESULT_NEED_BUFFER)
|
||||
else if (pnode->state == SPA_STATUS_NEED_BUFFER)
|
||||
spa_graph_need_input(pnode->graph, pnode);
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_graph_callbacks spa_graph_impl_default = {
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ spa_graph_node_add(struct spa_graph *graph,
|
|||
struct spa_graph_node *node)
|
||||
{
|
||||
node->graph = graph;
|
||||
node->state = SPA_RESULT_OK;
|
||||
node->state = SPA_STATUS_OK;
|
||||
node->ready_link.next = NULL;
|
||||
spa_list_append(&graph->nodes, &node->link);
|
||||
spa_debug("node %p add", node);
|
||||
|
|
|
|||
|
|
@ -141,14 +141,29 @@ struct spa_monitor {
|
|||
* Set callbacks to receive asynchronous notifications from
|
||||
* the monitor.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* Returns: 0 on success
|
||||
* -errno on error
|
||||
*/
|
||||
int (*set_callbacks) (struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
void *data);
|
||||
|
||||
/**
|
||||
* spa_monitor::enum_items:
|
||||
* @monitor: a #spa_monitor
|
||||
* @item: result item
|
||||
* @index: index of the item
|
||||
*
|
||||
* Get the next item of the monitor. \a index should contain 0 to get the
|
||||
* first item and is updated with an opaque value that should be passed
|
||||
* unmodified to get the next items.
|
||||
*
|
||||
* Returns: 1 when an item is available
|
||||
* 0 when no more items are available
|
||||
* -errno on error
|
||||
*/
|
||||
int (*enum_items) (struct spa_monitor *monitor,
|
||||
struct spa_monitor_item **item, uint32_t index);
|
||||
struct spa_monitor_item **item, uint32_t *index);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -51,12 +51,18 @@ struct spa_range {
|
|||
* by the host and configured on all ports for which IO is requested.
|
||||
*/
|
||||
struct spa_port_io {
|
||||
uint32_t status; /**< the status code */
|
||||
#define SPA_STATUS_OK 0
|
||||
#define SPA_STATUS_NEED_BUFFER 1
|
||||
#define SPA_STATUS_HAVE_BUFFER 2
|
||||
#define SPA_STATUS_FORMAT_CHANGED 3
|
||||
#define SPA_STATUS_PORTS_CHANGED 4
|
||||
#define SPA_STATUS_PARAM_CHANGED 5
|
||||
int32_t status; /**< the status code */
|
||||
uint32_t buffer_id; /**< a buffer id */
|
||||
struct spa_range range; /**< the requested range */
|
||||
};
|
||||
|
||||
#define SPA_PORT_IO_INIT (struct spa_port_io) { SPA_RESULT_OK, SPA_ID_INVALID, }
|
||||
#define SPA_PORT_IO_INIT (struct spa_port_io) { SPA_STATUS_OK, SPA_ID_INVALID, }
|
||||
|
||||
/**
|
||||
* struct spa_port_info
|
||||
|
|
|
|||
|
|
@ -484,7 +484,7 @@ do { \
|
|||
|
||||
static inline void *
|
||||
spa_pod_builder_addv(struct spa_pod_builder *builder,
|
||||
const char *format, va_list args)
|
||||
const char *format, va_list args)
|
||||
{
|
||||
while (format) {
|
||||
switch (*format) {
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ static inline int spa_pod_object_fixate(struct spa_pod_object *obj)
|
|||
if (res->type == SPA_POD_TYPE_PROP)
|
||||
((struct spa_pod_prop *) res)->body.flags &= ~SPA_POD_PROP_FLAG_UNSET;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <spa/pod/iter.h>
|
||||
|
|
@ -206,27 +207,27 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
|
|||
switch (*format) {
|
||||
case '<':
|
||||
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_POD_TYPE_OBJECT)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
if (++parser->depth >= SPA_POD_MAX_DEPTH)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
it = &parser->iter[parser->depth];
|
||||
spa_pod_iter_init(it, pod, SPA_POD_SIZE(pod), sizeof(struct spa_pod_object));
|
||||
goto read_pod;
|
||||
case '[':
|
||||
if (pod == NULL || SPA_POD_TYPE(pod) != SPA_POD_TYPE_STRUCT)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
if (++parser->depth >= SPA_POD_MAX_DEPTH)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
it = &parser->iter[parser->depth];
|
||||
spa_pod_iter_init(it, pod, SPA_POD_SIZE(pod), sizeof(struct spa_pod_struct));
|
||||
goto read_pod;
|
||||
case ']': case '>':
|
||||
if (current != NULL)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
if (--parser->depth < 0)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
it = &parser->iter[parser->depth];
|
||||
current = spa_pod_iter_current(it);
|
||||
|
|
@ -268,12 +269,12 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
|
|||
case 'V':
|
||||
pod = (struct spa_pod *) prop;
|
||||
if (pod == NULL && required)
|
||||
return SPA_RESULT_NOT_FOUND;
|
||||
return -ENOENT;
|
||||
goto collect;
|
||||
default:
|
||||
if (pod == NULL || !spa_pod_parser_can_collect(pod, *format)) {
|
||||
if (required)
|
||||
return SPA_RESULT_NOT_FOUND;
|
||||
return -ENOENT;
|
||||
skip = true;
|
||||
}
|
||||
collect:
|
||||
|
|
|
|||
|
|
@ -158,14 +158,13 @@ struct spa_handle_factory {
|
|||
*
|
||||
* Enumerate the interface information for @factory.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_NOT_IMPLEMENTED when there are no interfaces
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when handle or info is %NULL
|
||||
* #SPA_RESULT_ENUM_END when there are no more infos
|
||||
* Returns: 1 when an item is available
|
||||
* 0 when no more items are available
|
||||
* -errno on error
|
||||
*/
|
||||
int (*enum_interface_info) (const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index);
|
||||
uint32_t *index);
|
||||
};
|
||||
|
||||
#define spa_handle_factory_init(h,...) (h)->init((h),__VA_ARGS__)
|
||||
|
|
@ -183,7 +182,7 @@ struct spa_handle_factory {
|
|||
* #SPA_RESULT_ENUM_END when there are no more factories
|
||||
*/
|
||||
typedef int (*spa_handle_factory_enum_func_t) (const struct spa_handle_factory **factory,
|
||||
uint32_t index);
|
||||
uint32_t *index);
|
||||
|
||||
#define SPA_HANDLE_FACTORY_ENUM_FUNC_NAME "spa_handle_factory_enum"
|
||||
|
||||
|
|
@ -194,11 +193,11 @@ typedef int (*spa_handle_factory_enum_func_t) (const struct spa_handle_factory *
|
|||
*
|
||||
* The entry point in a plugin.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when factory is %NULL
|
||||
* #SPA_RESULT_ENUM_END when there are no more factories
|
||||
* Returns: 1 on success
|
||||
* 0 when no more items are available
|
||||
* -errno on error
|
||||
*/
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index);
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index);
|
||||
|
||||
void spa_handle_factory_register(const struct spa_handle_factory *factory);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,47 +30,6 @@ extern "C" {
|
|||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
enum spa_result {
|
||||
SPA_RESULT_WAIT_SYNC = 2,
|
||||
SPA_RESULT_MODIFIED = 1,
|
||||
SPA_RESULT_OK = 0,
|
||||
SPA_RESULT_ERROR = -1,
|
||||
SPA_RESULT_ERRNO = -2,
|
||||
SPA_RESULT_NOT_FOUND = -3,
|
||||
SPA_RESULT_BUSY = -4,
|
||||
SPA_RESULT_NO_MEMORY = -5,
|
||||
SPA_RESULT_NO_PERMISSION = -6,
|
||||
SPA_RESULT_INVALID_ARGUMENTS = -7,
|
||||
SPA_RESULT_NOT_IMPLEMENTED = -8,
|
||||
SPA_RESULT_UNKNOWN_INTERFACE = -9,
|
||||
SPA_RESULT_UNEXPECTED = -10,
|
||||
SPA_RESULT_INCOMPATIBLE = -11,
|
||||
SPA_RESULT_INCOMPATIBLE_VERSION = -12,
|
||||
SPA_RESULT_INCOMPLETE = -13,
|
||||
SPA_RESULT_ENUM_END = -14,
|
||||
|
||||
SPA_RESULT_INACTIVE = -15,
|
||||
SPA_RESULT_INVALID_COMMAND = -16,
|
||||
|
||||
SPA_RESULT_INVALID_PORT = -17,
|
||||
SPA_RESULT_INVALID_DIRECTION = -18,
|
||||
SPA_RESULT_PORTS_CHANGED = -19,
|
||||
SPA_RESULT_TOO_MANY_PORTS = -20,
|
||||
|
||||
SPA_RESULT_PARAM_CHANGED = -21,
|
||||
SPA_RESULT_PARAM_UNSET = -22,
|
||||
SPA_RESULT_UNKNOWN_PARAM = -23,
|
||||
|
||||
SPA_RESULT_NO_FORMAT = -24,
|
||||
SPA_RESULT_FORMAT_CHANGED = -25,
|
||||
SPA_RESULT_INVALID_MEDIA_TYPE = -26,
|
||||
|
||||
SPA_RESULT_INVALID_BUFFER_ID = -27,
|
||||
SPA_RESULT_NO_BUFFERS = -28,
|
||||
SPA_RESULT_OUT_OF_BUFFERS = -29,
|
||||
SPA_RESULT_HAVE_BUFFER = -30,
|
||||
SPA_RESULT_NEED_BUFFER = -31,
|
||||
};
|
||||
|
||||
#define SPA_ASYNC_BIT (1 << 30)
|
||||
#define SPA_ASYNC_MASK (3 << 30)
|
||||
|
|
@ -184,6 +143,8 @@ struct spa_fraction {
|
|||
#define spa_memzero(x,l) (memset((x), 0, (l)))
|
||||
#define spa_zero(x) (spa_memzero(&(x), sizeof(x)))
|
||||
|
||||
#define spa_strerror(err) strerror(-(err))
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ void spa_debug_set_type_map(const struct spa_type_map *m)
|
|||
int spa_debug_port_info(const struct spa_port_info *info)
|
||||
{
|
||||
if (info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
fprintf(stderr, "struct spa_port_info %p:\n", info);
|
||||
fprintf(stderr, " flags: \t%08x\n", info->flags);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spa_debug_buffer(const struct spa_buffer *buffer)
|
||||
|
|
@ -52,7 +52,7 @@ int spa_debug_buffer(const struct spa_buffer *buffer)
|
|||
int i;
|
||||
|
||||
if (buffer == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
fprintf(stderr, "spa_buffer %p:\n", buffer);
|
||||
fprintf(stderr, " id: %08X\n", buffer->id);
|
||||
|
|
@ -119,7 +119,7 @@ int spa_debug_buffer(const struct spa_buffer *buffer)
|
|||
fprintf(stderr, " size: %u\n", d->chunk->size);
|
||||
fprintf(stderr, " stride: %d\n", d->chunk->stride);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spa_debug_dump_mem(const void *mem, size_t size)
|
||||
|
|
@ -128,7 +128,7 @@ int spa_debug_dump_mem(const void *mem, size_t size)
|
|||
int i;
|
||||
|
||||
if (mem == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
if (i % 16 == 0)
|
||||
|
|
@ -137,7 +137,7 @@ int spa_debug_dump_mem(const void *mem, size_t size)
|
|||
if (i % 16 == 15 || i == size - 1)
|
||||
printf("\n");
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *pod_type_names[] = {
|
||||
|
|
@ -384,11 +384,11 @@ static int spa_debug_format(const struct spa_pod_object *format)
|
|||
uint32_t mtype, mstype;
|
||||
|
||||
if (format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_pod_object_parse(format, "I", &mtype,
|
||||
"I", &mstype) < 0)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
media_type = spa_type_map_get_type(map, mtype);
|
||||
media_subtype = spa_type_map_get_type(map, mstype);
|
||||
|
|
@ -451,12 +451,12 @@ static int spa_debug_format(const struct spa_pod_object *format)
|
|||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spa_debug_pod(const struct spa_pod *pod, uint32_t flags)
|
||||
{
|
||||
int res = SPA_RESULT_OK;
|
||||
int res = 0;
|
||||
|
||||
if (flags & SPA_DEBUG_FLAG_FORMAT)
|
||||
res = spa_debug_format((struct spa_pod_object*)pod);
|
||||
|
|
@ -472,11 +472,11 @@ int spa_debug_dict(const struct spa_dict *dict)
|
|||
unsigned int i;
|
||||
|
||||
if (dict == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < dict->n_items; i++)
|
||||
fprintf(stderr, " %s = \"%s\"\n", dict->items[i].key,
|
||||
dict->items[i].value);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -144,7 +145,7 @@ filter_prop(struct spa_pod_builder *b,
|
|||
|
||||
/* incompatible property types */
|
||||
if (p1->body.value.type != p2->body.value.type)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
|
||||
rt1 = p1->body.flags & SPA_POD_PROP_RANGE_MASK;
|
||||
rt2 = p2->body.flags & SPA_POD_PROP_RANGE_MASK;
|
||||
|
|
@ -192,7 +193,7 @@ filter_prop(struct spa_pod_builder *b,
|
|||
}
|
||||
}
|
||||
if (n_copied == 0)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
||||
}
|
||||
|
||||
|
|
@ -209,13 +210,13 @@ filter_prop(struct spa_pod_builder *b,
|
|||
n_copied++;
|
||||
}
|
||||
if (n_copied == 0)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
||||
}
|
||||
|
||||
if ((rt1 == SPA_POD_PROP_RANGE_NONE && rt2 == SPA_POD_PROP_RANGE_STEP) ||
|
||||
(rt1 == SPA_POD_PROP_RANGE_ENUM && rt2 == SPA_POD_PROP_RANGE_STEP)) {
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if ((rt1 == SPA_POD_PROP_RANGE_MIN_MAX && rt2 == SPA_POD_PROP_RANGE_NONE) ||
|
||||
|
|
@ -231,7 +232,7 @@ filter_prop(struct spa_pod_builder *b,
|
|||
n_copied++;
|
||||
}
|
||||
if (n_copied == 0)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
np->body.flags |= SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET;
|
||||
}
|
||||
|
||||
|
|
@ -253,44 +254,44 @@ filter_prop(struct spa_pod_builder *b,
|
|||
}
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_NONE && rt2 == SPA_POD_PROP_RANGE_FLAGS)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_MIN_MAX && rt2 == SPA_POD_PROP_RANGE_STEP)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_MIN_MAX && rt2 == SPA_POD_PROP_RANGE_FLAGS)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_ENUM && rt2 == SPA_POD_PROP_RANGE_FLAGS)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_STEP && rt2 == SPA_POD_PROP_RANGE_NONE)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_STEP && rt2 == SPA_POD_PROP_RANGE_MIN_MAX)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_STEP && rt2 == SPA_POD_PROP_RANGE_STEP)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_STEP && rt2 == SPA_POD_PROP_RANGE_ENUM)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_STEP && rt2 == SPA_POD_PROP_RANGE_FLAGS)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
if (rt1 == SPA_POD_PROP_RANGE_FLAGS && rt2 == SPA_POD_PROP_RANGE_NONE)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_FLAGS && rt2 == SPA_POD_PROP_RANGE_MIN_MAX)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_FLAGS && rt2 == SPA_POD_PROP_RANGE_STEP)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_FLAGS && rt2 == SPA_POD_PROP_RANGE_ENUM)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
if (rt1 == SPA_POD_PROP_RANGE_FLAGS && rt2 == SPA_POD_PROP_RANGE_FLAGS)
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
spa_pod_builder_pop(b);
|
||||
fix_default(np);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pod_filter(struct spa_pod_builder *b,
|
||||
|
|
@ -300,7 +301,7 @@ int pod_filter(struct spa_pod_builder *b,
|
|||
uint32_t filter_size)
|
||||
{
|
||||
const struct spa_pod *pp, *pf, *tmp;
|
||||
int res = SPA_RESULT_OK;
|
||||
int res = 0;
|
||||
|
||||
pf = filter;
|
||||
|
||||
|
|
@ -313,7 +314,7 @@ int pod_filter(struct spa_pod_builder *b,
|
|||
case SPA_POD_TYPE_STRUCT:
|
||||
if (pf != NULL) {
|
||||
if (SPA_POD_TYPE(pf) != SPA_POD_TYPE_STRUCT)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
|
||||
pc = SPA_POD_CONTENTS(struct spa_pod_struct, pp);
|
||||
pcs = SPA_POD_CONTENTS_SIZE(struct spa_pod_struct, pp);
|
||||
|
|
@ -334,7 +335,7 @@ int pod_filter(struct spa_pod_builder *b,
|
|||
p1 = (struct spa_pod_object *) pp;
|
||||
|
||||
if (SPA_POD_TYPE(pf) != SPA_POD_TYPE_OBJECT)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
|
||||
pc = SPA_POD_CONTENTS(struct spa_pod_object, pp);
|
||||
pcs = SPA_POD_CONTENTS_SIZE(struct spa_pod_object, pp);
|
||||
|
|
@ -365,9 +366,9 @@ int pod_filter(struct spa_pod_builder *b,
|
|||
default:
|
||||
if (pf != NULL) {
|
||||
if (SPA_POD_SIZE(pp) != SPA_POD_SIZE(pf))
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
if (memcmp(pp, pf, SPA_POD_SIZE(pp)) != 0)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
do_advance = true;
|
||||
}
|
||||
do_copy = true;
|
||||
|
|
@ -396,12 +397,12 @@ spa_pod_filter(struct spa_pod_builder *b,
|
|||
const struct spa_pod *pod,
|
||||
const struct spa_pod *filter)
|
||||
{
|
||||
spa_return_val_if_fail(pod != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(b != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(pod != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(b != NULL, -EINVAL);
|
||||
|
||||
if (filter == NULL) {
|
||||
spa_pod_builder_raw_padded(b, pod, SPA_POD_SIZE(pod));
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
return pod_filter(b, pod, SPA_POD_SIZE(pod), filter, SPA_POD_SIZE(filter));
|
||||
|
||||
|
|
@ -424,12 +425,12 @@ int pod_compare(const struct spa_pod *pod1,
|
|||
uint32_t p1cs, p2cs;
|
||||
|
||||
if (p2 == NULL)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
|
||||
switch (SPA_POD_TYPE(p1)) {
|
||||
case SPA_POD_TYPE_STRUCT:
|
||||
if (SPA_POD_TYPE(p2) != SPA_POD_TYPE_STRUCT)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
|
||||
p1c = SPA_POD_CONTENTS(struct spa_pod_struct, p1);
|
||||
p1cs = SPA_POD_CONTENTS_SIZE(struct spa_pod_struct, p1);
|
||||
|
|
@ -440,7 +441,7 @@ int pod_compare(const struct spa_pod *pod1,
|
|||
break;
|
||||
case SPA_POD_TYPE_OBJECT:
|
||||
if (SPA_POD_TYPE(p2) != SPA_POD_TYPE_OBJECT)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
|
||||
p1c = SPA_POD_CONTENTS(struct spa_pod_object, p1);
|
||||
p1cs = SPA_POD_CONTENTS_SIZE(struct spa_pod_object, p1);
|
||||
|
|
@ -457,15 +458,15 @@ int pod_compare(const struct spa_pod *pod1,
|
|||
pr2 = find_prop(pod2, pod2_size, pr1->body.key);
|
||||
|
||||
if (pr2 == NULL)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
|
||||
/* incompatible property types */
|
||||
if (pr1->body.value.type != pr2->body.value.type)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
|
||||
if (pr1->body.flags & SPA_POD_PROP_FLAG_UNSET ||
|
||||
pr2->body.flags & SPA_POD_PROP_FLAG_UNSET)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
|
||||
a1 = SPA_MEMBER(pr1, sizeof(struct spa_pod_prop), void);
|
||||
a2 = SPA_MEMBER(pr2, sizeof(struct spa_pod_prop), void);
|
||||
|
|
@ -475,7 +476,7 @@ int pod_compare(const struct spa_pod *pod1,
|
|||
}
|
||||
default:
|
||||
if (SPA_POD_TYPE(p1) != SPA_POD_TYPE(p2))
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
|
||||
res = compare_value(SPA_POD_TYPE(p1), SPA_POD_BODY(p1), SPA_POD_BODY(p2));
|
||||
do_advance = true;
|
||||
|
|
@ -493,16 +494,16 @@ int pod_compare(const struct spa_pod *pod1,
|
|||
return res;
|
||||
}
|
||||
if (p2 != NULL)
|
||||
return SPA_RESULT_INCOMPATIBLE;
|
||||
return -EINVAL;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spa_pod_compare(const struct spa_pod *pod1,
|
||||
const struct spa_pod *pod2)
|
||||
{
|
||||
spa_return_val_if_fail(pod1 != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(pod2 != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(pod1 != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(pod2 != NULL, -EINVAL);
|
||||
|
||||
return pod_compare(pod1, SPA_POD_SIZE(pod1), pod2, SPA_POD_SIZE(pod2));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,11 +84,11 @@ struct impl {
|
|||
static int impl_udev_open(struct impl *this)
|
||||
{
|
||||
if (this->udev != NULL)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
this->udev = udev_new();
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *path_get_card_id(const char *path)
|
||||
|
|
@ -350,7 +350,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
int res;
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(monitor != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
udev_monitor_unref(this->umonitor);
|
||||
this->umonitor = udev_monitor_new_from_netlink(this->udev, "udev");
|
||||
if (this->umonitor == NULL)
|
||||
return SPA_RESULT_ERROR;
|
||||
return -ENODEV;
|
||||
|
||||
udev_monitor_filter_add_match_subsystem_devtype(this->umonitor, "sound", NULL);
|
||||
udev_monitor_enable_receiving(this->umonitor);
|
||||
|
|
@ -380,25 +380,25 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
spa_loop_remove_source(this->main_loop, &this->source);
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_monitor_enum_items(struct spa_monitor *monitor,
|
||||
struct spa_monitor_item **item,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(item != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(monitor != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(item != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
return res;
|
||||
|
||||
if (index == 0 || this->index > index) {
|
||||
if (*index == 0 || this->index > *index) {
|
||||
if (this->enumerate)
|
||||
udev_enumerate_unref(this->enumerate);
|
||||
this->enumerate = udev_enumerate_new(this->udev);
|
||||
|
|
@ -409,13 +409,13 @@ static int impl_monitor_enum_items(struct spa_monitor *monitor,
|
|||
this->devices = udev_enumerate_get_list_entry(this->enumerate);
|
||||
this->index = 0;
|
||||
}
|
||||
while (index > this->index && this->devices) {
|
||||
while (*index > this->index && this->devices) {
|
||||
this->devices = udev_list_entry_get_next(this->devices);
|
||||
this->index++;
|
||||
}
|
||||
again:
|
||||
if (this->devices == NULL)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
if (this->dev == NULL) {
|
||||
this->dev = udev_device_new_from_syspath(this->udev, udev_list_entry_get_name(this->devices));
|
||||
|
|
@ -435,10 +435,11 @@ static int impl_monitor_enum_items(struct spa_monitor *monitor,
|
|||
}
|
||||
|
||||
this->index++;
|
||||
(*index)++;
|
||||
|
||||
*item = this->item;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_monitor impl_monitor = {
|
||||
|
|
@ -452,17 +453,17 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.monitor.Monitor)
|
||||
*interface = &this->monitor;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
|
|
@ -478,7 +479,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
if (this->udev)
|
||||
udev_unref(this->udev);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -491,8 +492,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -509,18 +510,18 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "an id-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (this->main_loop == NULL) {
|
||||
spa_log_error(this->log, "a main-loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
this->monitor = impl_monitor;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -530,16 +531,17 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
if (index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
if (*index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return 0;
|
||||
|
||||
*info = &impl_interfaces[index];
|
||||
return SPA_RESULT_OK;
|
||||
*info = &impl_interfaces[(*index)++];
|
||||
return 1;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_alsa_monitor_factory = {
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct spa_pod *param;
|
||||
uint32_t offset;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
|
@ -65,7 +65,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
next:
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
|
|
@ -75,7 +75,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
|
|
@ -88,7 +88,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
2, 1, INT32_MAX);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
|
|
@ -105,7 +105,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
struct state *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
|
@ -115,16 +115,16 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
|
||||
if (param == NULL) {
|
||||
reset_props(p);
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_device, "?S", p->device, sizeof(p->device),
|
||||
":", t->prop_min_latency, "?i", &p->min_latency, NULL);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_send_done(struct spa_loop *loop, bool async, uint32_t seq, size_t size, const void *data, void *user_data)
|
||||
|
|
@ -133,7 +133,7 @@ static int do_send_done(struct spa_loop *loop, bool async, uint32_t seq, size_t
|
|||
|
||||
this->callbacks->done(this->callbacks_data, seq, *(int*)data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_command(struct spa_loop *loop, bool async, uint32_t seq, size_t size, const void *data, void *user_data)
|
||||
|
|
@ -146,7 +146,7 @@ static int do_command(struct spa_loop *loop, bool async, uint32_t seq, size_t si
|
|||
SPA_COMMAND_TYPE(cmd) == this->type.command_node.Pause) {
|
||||
res = spa_node_port_send_command(&this->node, SPA_DIRECTION_INPUT, 0, cmd);
|
||||
} else
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
res = -ENOTSUP;
|
||||
|
||||
if (async) {
|
||||
spa_loop_invoke(this->main_loop,
|
||||
|
|
@ -164,18 +164,17 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE(command) == this->type.command_node.Start ||
|
||||
SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
return spa_loop_invoke(this->data_loop,
|
||||
do_command,
|
||||
|
|
@ -186,7 +185,7 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
this);
|
||||
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -196,14 +195,14 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -213,7 +212,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
|
|
@ -224,7 +223,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -234,23 +233,23 @@ impl_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -259,16 +258,16 @@ impl_node_port_get_info(struct spa_node *node,
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
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), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -284,17 +283,18 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
struct spa_pod *param;
|
||||
uint32_t offset;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
offset = builder->offset;
|
||||
|
||||
|
||||
next:
|
||||
if (id == t->param.idList) {
|
||||
uint32_t list[] = { t->param.idEnumFormat,
|
||||
|
|
@ -306,16 +306,17 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
printf("%d\n", *index);
|
||||
return spa_alsa_enum_format(this, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
t->param.idFormat, t->format,
|
||||
|
|
@ -327,9 +328,9 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param_buffers.Buffers,
|
||||
|
|
@ -343,7 +344,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
}
|
||||
else if (id == t->param.idMeta) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
|
|
@ -366,11 +367,11 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_meta.ringbufferAlign, "i", 16);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -378,7 +379,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int clear_buffers(struct state *this)
|
||||
|
|
@ -387,7 +388,7 @@ static int clear_buffers(struct state *this)
|
|||
spa_list_init(&this->ready);
|
||||
this->n_buffers = 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
@ -414,10 +415,10 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (info.media_type != this->type.media_type.audio ||
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if ((err = spa_alsa_set_format(this, &info, flags)) < 0)
|
||||
return err;
|
||||
|
|
@ -431,7 +432,7 @@ static int port_set_format(struct spa_node *node,
|
|||
this->info.rate = this->rate;
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -443,18 +444,18 @@ impl_node_port_set_param(struct spa_node *node,
|
|||
struct state *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (id == t->param.idFormat) {
|
||||
return port_set_format(node, direction, port_id, flags, param);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -465,21 +466,21 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
struct state *this;
|
||||
int i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
spa_log_info(this->log, "use buffers %d", n_buffers);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
if (n_buffers == 0) {
|
||||
spa_alsa_pause(this, false);
|
||||
clear_buffers(this);
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < n_buffers; i++) {
|
||||
|
|
@ -497,12 +498,12 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
type == this->type.data.DmaBuf ||
|
||||
type == this->type.data.MemPtr) && buffers[i]->datas[0].data == NULL) {
|
||||
spa_log_error(this->log, NAME " %p: need mapped memory", this);
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
this->n_buffers = n_buffers;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -516,17 +517,17 @@ impl_node_port_alloc_buffers(struct spa_node *node,
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(buffers != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(buffers != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -534,20 +535,20 @@ impl_node_port_set_io(struct spa_node *node, enum spa_direction direction, uint3
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
this->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -557,18 +558,18 @@ impl_node_port_send_command(struct spa_node *node,
|
|||
struct state *this;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
res = spa_alsa_pause(this, false);
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Start) {
|
||||
res = spa_alsa_start(this, false);
|
||||
} else
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
res = -ENOTSUP;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -578,19 +579,19 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
struct state *this;
|
||||
struct spa_port_io *input;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
input = this->io;
|
||||
spa_return_val_if_fail(input != NULL, SPA_RESULT_UNEXPECTED);
|
||||
spa_return_val_if_fail(input != NULL, -EIO);
|
||||
|
||||
if (input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id < this->n_buffers) {
|
||||
if (input->status == SPA_STATUS_HAVE_BUFFER && input->buffer_id < this->n_buffers) {
|
||||
struct buffer *b = &this->buffers[input->buffer_id];
|
||||
|
||||
if (!b->outstanding) {
|
||||
spa_log_warn(this->log, NAME " %p: buffer %u in use", this, input->buffer_id);
|
||||
input->status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
return SPA_RESULT_ERROR;
|
||||
input->status = -EINVAL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
spa_log_trace(this->log, NAME " %p: queue buffer %u", this, input->buffer_id);
|
||||
|
|
@ -598,14 +599,14 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
spa_list_append(&this->ready, &b->link);
|
||||
b->outstanding = false;
|
||||
input->buffer_id = SPA_ID_INVALID;
|
||||
input->status = SPA_RESULT_OK;
|
||||
input->status = SPA_STATUS_OK;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_STATUS_OK;
|
||||
}
|
||||
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static const struct spa_dict_item node_info_items[] = {
|
||||
|
|
@ -644,22 +645,22 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct state *) handle;
|
||||
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -669,8 +670,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct state *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -689,15 +690,15 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (this->data_loop == NULL) {
|
||||
spa_log_error(this->log, "a data loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (this->main_loop == NULL) {
|
||||
spa_log_error(this->log, "a main loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -713,7 +714,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -722,19 +723,21 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
|
||||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info, uint32_t index)
|
||||
const struct spa_interface_info **info, uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[*index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_dict_item info_items[] = {
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct spa_pod *param;
|
||||
uint32_t offset;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
|
@ -64,7 +64,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
next:
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
|
|
@ -74,7 +74,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
|
|
@ -85,7 +85,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
2, 1, INT32_MAX);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
|
|
@ -102,7 +102,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
struct state *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
|
@ -112,16 +112,16 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
|
||||
if (param == NULL) {
|
||||
reset_props(p);
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_device, "?S", p->device, sizeof(p->device),
|
||||
":", t->prop_min_latency, "?i", &p->min_latency, NULL);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_send_done(struct spa_loop *loop, bool async, uint32_t seq, size_t size, const void *data, void *user_data)
|
||||
|
|
@ -130,7 +130,7 @@ static int do_send_done(struct spa_loop *loop, bool async, uint32_t seq, size_t
|
|||
|
||||
this->callbacks->done(this->callbacks_data, seq, *(int*)data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_start(struct spa_loop *loop, bool async, uint32_t seq, size_t size, const void *data, void *user_data)
|
||||
|
|
@ -175,31 +175,29 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE(command) == this->type.command_node.Start) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
return spa_loop_invoke(this->data_loop, do_start, ++this->seq, 0, NULL, false, this);
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
return spa_loop_invoke(this->data_loop, do_pause, ++this->seq, 0, NULL, false, this);
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -209,14 +207,14 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -226,7 +224,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
|
|
@ -237,7 +235,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -247,23 +245,23 @@ impl_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -272,16 +270,16 @@ impl_node_port_get_info(struct spa_node *node,
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
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), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void recycle_buffer(struct state *this, uint32_t buffer_id)
|
||||
|
|
@ -307,9 +305,9 @@ static int port_get_format(struct spa_node *node,
|
|||
struct type *t = &this->type;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = spa_pod_builder_object(builder,
|
||||
t->param.idFormat, t->format,
|
||||
|
|
@ -319,7 +317,7 @@ static int port_get_format(struct spa_node *node,
|
|||
":", t->format_audio.rate, "i", this->current_format.info.raw.rate,
|
||||
":", t->format_audio.channels, "i", this->current_format.info.raw.channels);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -335,14 +333,14 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
uint32_t offset;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
offset = builder->offset;
|
||||
|
||||
|
|
@ -357,20 +355,20 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return spa_alsa_enum_format(this, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if ((res = port_get_format(node, direction, port_id, index, ¶m, builder)) < 0)
|
||||
if ((res = port_get_format(node, direction, port_id, index, ¶m, builder)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param_buffers.Buffers,
|
||||
|
|
@ -382,7 +380,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
}
|
||||
else if (id == t->param.idMeta) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
|
|
@ -392,11 +390,11 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_meta.size, "i", sizeof(struct spa_meta_header));
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -404,7 +402,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int clear_buffers(struct state *this)
|
||||
|
|
@ -414,7 +412,7 @@ static int clear_buffers(struct state *this)
|
|||
spa_list_init(&this->ready);
|
||||
this->n_buffers = 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
@ -438,10 +436,10 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (info.media_type != this->type.media_type.audio ||
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if ((err = spa_alsa_set_format(this, &info, flags)) < 0)
|
||||
return err;
|
||||
|
|
@ -455,7 +453,7 @@ static int port_set_format(struct spa_node *node,
|
|||
this->info.rate = this->rate;
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -467,18 +465,18 @@ impl_node_port_set_param(struct spa_node *node,
|
|||
struct state *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (id == t->param.idFormat) {
|
||||
return port_set_format(node, direction, port_id, flags, param);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -490,14 +488,14 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
int res;
|
||||
int i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
if (this->n_buffers > 0) {
|
||||
spa_alsa_pause(this, false);
|
||||
|
|
@ -517,13 +515,13 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
d[0].type == this->type.data.DmaBuf ||
|
||||
d[0].type == this->type.data.MemPtr) && d[0].data != NULL)) {
|
||||
spa_log_error(this->log, NAME " %p: need mapped memory", this);
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
spa_list_append(&this->free, &b->link);
|
||||
}
|
||||
this->n_buffers = n_buffers;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -538,17 +536,17 @@ impl_node_port_alloc_buffers(struct spa_node *node,
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(buffers != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(buffers != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -556,36 +554,36 @@ impl_node_port_set_io(struct spa_node *node, enum spa_direction direction, uint3
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
this->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(port_id == 0, SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(port_id == 0, -EINVAL);
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if (buffer_id >= this->n_buffers)
|
||||
return SPA_RESULT_INVALID_BUFFER_ID;
|
||||
return -EINVAL;
|
||||
|
||||
recycle_buffer(this, buffer_id);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -595,25 +593,25 @@ impl_node_port_send_command(struct spa_node *node,
|
|||
struct state *this;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
res = spa_alsa_pause(this, false);
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Start) {
|
||||
res = spa_alsa_start(this, false);
|
||||
} else
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
res = -ENOTSUP;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
|
|
@ -621,20 +619,20 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
struct state *this;
|
||||
struct spa_port_io *io;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
io = this->io;
|
||||
spa_return_val_if_fail(io != NULL, SPA_RESULT_UNEXPECTED);
|
||||
spa_return_val_if_fail(io != NULL, -EIO);
|
||||
|
||||
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
if (io->status == SPA_STATUS_HAVE_BUFFER)
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
if (io->buffer_id < this->n_buffers) {
|
||||
recycle_buffer(this, io->buffer_id);
|
||||
io->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_dict_item node_info_items[] = {
|
||||
|
|
@ -672,14 +670,14 @@ static const struct spa_node impl_node = {
|
|||
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_clock_set_param(struct spa_clock *clock,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_clock_get_time(struct spa_clock *clock,
|
||||
|
|
@ -689,7 +687,7 @@ static int impl_clock_get_time(struct spa_clock *clock,
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(clock != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(clock, struct state, clock);
|
||||
|
||||
|
|
@ -700,7 +698,7 @@ static int impl_clock_get_time(struct spa_clock *clock,
|
|||
if (monotonic_time)
|
||||
*monotonic_time = this->last_monotonic;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
|
|
@ -716,8 +714,8 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct state *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct state *) handle;
|
||||
|
||||
|
|
@ -726,14 +724,14 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
else if (interface_id == this->type.clock)
|
||||
*interface = &this->clock;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -746,8 +744,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct state *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -766,15 +764,15 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "an id-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (this->data_loop == NULL) {
|
||||
spa_log_error(this->log, "a data loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (this->main_loop == NULL) {
|
||||
spa_log_error(this->log, "a main loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -791,7 +789,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
snprintf(this->props.device, 63, "%s", info->items[i].value);
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -802,17 +800,18 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
if (index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
if (*index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return 0;
|
||||
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[(*index)++];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_dict_item info_items[] = {
|
||||
|
|
|
|||
|
|
@ -14,16 +14,7 @@
|
|||
|
||||
#include "alsa-utils.h"
|
||||
|
||||
static int convert_errnum(struct state *state, int errnum)
|
||||
{
|
||||
switch (errnum) {
|
||||
case -EBUSY:
|
||||
return SPA_RESULT_BUSY;
|
||||
}
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
#define CHECK(s,msg) if ((err = (s)) < 0) { spa_log_error(state->log, msg ": %s", snd_strerror(err)); return convert_errnum(state, err); }
|
||||
#define CHECK(s,msg) if ((err = (s)) < 0) { spa_log_error(state->log, msg ": %s", snd_strerror(err)); return err; }
|
||||
|
||||
static int spa_alsa_open(struct state *state)
|
||||
{
|
||||
|
|
@ -139,7 +130,7 @@ spa_alsa_enum_format(struct state *state, uint32_t *index,
|
|||
|
||||
next:
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
hndl = state->hndl;
|
||||
snd_pcm_hw_params_alloca(¶ms);
|
||||
|
|
@ -208,7 +199,7 @@ spa_alsa_enum_format(struct state *state, uint32_t *index,
|
|||
if (!opened)
|
||||
spa_alsa_close(state);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_t flags)
|
||||
|
|
@ -235,7 +226,6 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
|
|||
/* set the interleaved read/write format */
|
||||
CHECK(snd_pcm_hw_params_set_access(hndl, params, SND_PCM_ACCESS_MMAP_INTERLEAVED), "set_access");
|
||||
|
||||
|
||||
/* disable ALSA wakeups, we use a timer */
|
||||
if (snd_pcm_hw_params_can_disable_period_wakeup(params))
|
||||
CHECK(snd_pcm_hw_params_set_period_wakeup(hndl, params, 0), "set_period_wakeup");
|
||||
|
|
@ -329,7 +319,7 @@ static inline void try_pull(struct state *state, snd_pcm_uframes_t frames, bool
|
|||
|
||||
if (spa_list_is_empty(&state->ready) && do_pull) {
|
||||
spa_log_trace(state->log, "alsa-util %p: %d", state, io->status);
|
||||
io->status = SPA_RESULT_NEED_BUFFER;
|
||||
io->status = SPA_STATUS_NEED_BUFFER;
|
||||
io->range.offset = state->sample_count * state->frame_size;
|
||||
io->range.min_size = state->threshold * state->frame_size;
|
||||
io->range.max_size = frames * state->frame_size;
|
||||
|
|
@ -461,7 +451,7 @@ push_frames(struct state *state,
|
|||
|
||||
b->outstanding = true;
|
||||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_HAVE_BUFFER;
|
||||
io->status = SPA_STATUS_HAVE_BUFFER;
|
||||
state->callbacks->have_output(state->callbacks_data);
|
||||
}
|
||||
return total_frames;
|
||||
|
|
@ -661,7 +651,7 @@ int spa_alsa_start(struct state *state, bool xrun_recover)
|
|||
int err;
|
||||
|
||||
if (state->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
spa_log_trace(state->log, "alsa %p: start", state);
|
||||
|
||||
|
|
@ -671,7 +661,7 @@ int spa_alsa_start(struct state *state, bool xrun_recover)
|
|||
|
||||
if ((err = snd_pcm_prepare(state->hndl)) < 0) {
|
||||
spa_log_error(state->log, "snd_pcm_prepare error: %s", snd_strerror(err));
|
||||
return SPA_RESULT_ERROR;
|
||||
return err;
|
||||
}
|
||||
|
||||
if (state->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||
|
|
@ -692,7 +682,7 @@ int spa_alsa_start(struct state *state, bool xrun_recover)
|
|||
} else {
|
||||
if ((err = snd_pcm_start(state->hndl)) < 0) {
|
||||
spa_log_error(state->log, "snd_pcm_start: %s", snd_strerror(err));
|
||||
return SPA_RESULT_ERROR;
|
||||
return err;
|
||||
}
|
||||
state->alsa_started = true;
|
||||
}
|
||||
|
|
@ -700,7 +690,7 @@ int spa_alsa_start(struct state *state, bool xrun_recover)
|
|||
|
||||
state->started = true;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_remove_source(struct spa_loop *loop,
|
||||
|
|
@ -712,7 +702,7 @@ static int do_remove_source(struct spa_loop *loop,
|
|||
{
|
||||
struct state *state = user_data;
|
||||
spa_loop_remove_source(state->data_loop, &state->source);
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spa_alsa_pause(struct state *state, bool xrun_recover)
|
||||
|
|
@ -720,7 +710,7 @@ int spa_alsa_pause(struct state *state, bool xrun_recover)
|
|||
int err;
|
||||
|
||||
if (!state->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
spa_log_trace(state->log, "alsa %p: pause", state);
|
||||
|
||||
|
|
@ -731,5 +721,5 @@ int spa_alsa_pause(struct state *state, bool xrun_recover)
|
|||
|
||||
state->started = false;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,17 +17,20 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
|
||||
extern const struct spa_handle_factory spa_alsa_source_factory;
|
||||
extern const struct spa_handle_factory spa_alsa_sink_factory;
|
||||
extern const struct spa_handle_factory spa_alsa_monitor_factory;
|
||||
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*factory = &spa_alsa_source_factory;
|
||||
break;
|
||||
|
|
@ -38,7 +41,8 @@ int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t
|
|||
*factory = &spa_alsa_monitor_factory;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -139,21 +140,21 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
const struct spa_pod_object *filter,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -162,9 +163,9 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
this->started = false;
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -174,14 +175,14 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -193,7 +194,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -206,7 +207,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -219,7 +220,7 @@ impl_node_get_port_ids(struct spa_node *node,
|
|||
struct impl *this;
|
||||
int i, idx;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -232,7 +233,7 @@ impl_node_get_port_ids(struct spa_node *node,
|
|||
if (n_output_ports > 0 && output_ids)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
|
|
@ -240,12 +241,11 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio
|
|||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_FREE_IN_PORT(this, direction, port_id),
|
||||
SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_FREE_IN_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_IN_PORT (this, port_id);
|
||||
port->valid = true;
|
||||
|
|
@ -261,7 +261,7 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio
|
|||
|
||||
spa_log_info(this->log, NAME " %p: add port %d", this, port_id);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -270,11 +270,11 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_IN_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_IN_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_IN_PORT (this, port_id);
|
||||
|
||||
|
|
@ -296,7 +296,7 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
|
|||
}
|
||||
spa_log_info(this->log, NAME " %p: remove port %d", this, port_id);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -308,17 +308,17 @@ impl_node_port_get_info(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
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), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
|
|
@ -345,9 +345,9 @@ static int port_enum_formats(struct spa_node *node,
|
|||
2, 1, INT32_MAX);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
|
|
@ -361,9 +361,9 @@ static int port_get_format(struct spa_node *node,
|
|||
struct port *port = GET_PORT(this, direction, port_id);
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = spa_pod_builder_object(builder,
|
||||
t->param.idFormat, t->format,
|
||||
|
|
@ -373,7 +373,7 @@ static int port_get_format(struct spa_node *node,
|
|||
":", t->format_audio.rate, "i", this->format.info.raw.rate,
|
||||
":", t->format_audio.channels, "i", this->format.info.raw.channels);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -390,14 +390,14 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
uint32_t offset;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
|
|
@ -414,21 +414,21 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, ¶m, builder)) < 0)
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, ¶m, builder)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if ((res = port_get_format(node, direction, port_id, index, ¶m, builder)) < 0)
|
||||
if ((res = port_get_format(node, direction, port_id, index, ¶m, builder)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param_buffers.Buffers,
|
||||
|
|
@ -442,7 +442,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
}
|
||||
else if (id == t->param.idMeta) {
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
|
|
@ -463,11 +463,11 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_meta.ringbufferAlign, "i", 16);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -475,7 +475,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int clear_buffers(struct impl *this, struct port *port)
|
||||
|
|
@ -485,7 +485,7 @@ static int clear_buffers(struct impl *this, struct port *port)
|
|||
port->n_buffers = 0;
|
||||
spa_list_init(&port->queue);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
@ -516,14 +516,14 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (info.media_type != t->media_type.audio ||
|
||||
info.media_subtype != t->media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_format_audio_raw_parse(format, &info.info.raw, &t->format_audio) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (this->have_format) {
|
||||
if (memcmp(&info, &this->format, sizeof(struct spa_audio_info)))
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
} else {
|
||||
if (info.info.raw.format == t->audio_format.S16) {
|
||||
this->copy = this->ops.copy[CONV_S16_S16];
|
||||
|
|
@ -536,7 +536,7 @@ static int port_set_format(struct spa_node *node,
|
|||
this->bpf = sizeof(float) * info.info.raw.channels;
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
this->have_format = true;
|
||||
this->format = info;
|
||||
|
|
@ -548,7 +548,7 @@ static int port_set_format(struct spa_node *node,
|
|||
}
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -561,18 +561,18 @@ impl_node_port_set_param(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (id == t->param.idFormat) {
|
||||
return port_set_format(node, direction, port_id, flags, param);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -587,16 +587,16 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
uint32_t i;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
spa_return_val_if_fail(port->have_format, SPA_RESULT_NO_FORMAT);
|
||||
spa_return_val_if_fail(port->have_format, -EIO);
|
||||
|
||||
clear_buffers(this, port);
|
||||
|
||||
|
|
@ -626,14 +626,14 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
d[0].type == t->data.DmaBuf) && d[0].data != NULL)) {
|
||||
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
|
||||
buffers[i]);
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!b->outstanding)
|
||||
spa_list_append(&port->queue, &b->link);
|
||||
}
|
||||
port->n_buffers = n_buffers;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -645,7 +645,7 @@ impl_node_port_alloc_buffers(struct spa_node *node,
|
|||
struct spa_buffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -657,16 +657,16 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void recycle_buffer(struct impl *this, uint32_t id)
|
||||
|
|
@ -688,16 +688,15 @@ static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id),
|
||||
SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id), -EINVAL);
|
||||
|
||||
recycle_buffer(this, buffer_id);
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -706,7 +705,7 @@ impl_node_port_send_command(struct spa_node *node,
|
|||
uint32_t port_id,
|
||||
const struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
@ -768,7 +767,7 @@ static int mix_output(struct impl *this, size_t n_bytes)
|
|||
|
||||
if (spa_list_is_empty(&outport->queue)) {
|
||||
spa_log_trace(this->log, NAME " %p: out of buffers", this);
|
||||
return SPA_RESULT_OUT_OF_BUFFERS;
|
||||
return -EPIPE;
|
||||
}
|
||||
|
||||
outbuf = spa_list_first(&outport->queue, struct buffer, link);
|
||||
|
|
@ -822,9 +821,9 @@ static int mix_output(struct impl *this, size_t n_bytes)
|
|||
spa_ringbuffer_write_update(outbuf->rb, index + n_bytes);
|
||||
|
||||
outio->buffer_id = outbuf->outbuf->id;
|
||||
outio->status = SPA_RESULT_HAVE_BUFFER;
|
||||
outio->status = SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
}
|
||||
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
|
|
@ -835,16 +834,16 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
size_t min_queued = SIZE_MAX;
|
||||
struct spa_port_io *outio;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
outport = GET_OUT_PORT(this, 0);
|
||||
outio = outport->io;
|
||||
spa_return_val_if_fail(outio != NULL, SPA_RESULT_ERROR);
|
||||
spa_return_val_if_fail(outio != NULL, -EIO);
|
||||
|
||||
if (outio->status == SPA_RESULT_HAVE_BUFFER)
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
if (outio->status == SPA_STATUS_HAVE_BUFFER)
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
for (i = 0; i < this->last_port; i++) {
|
||||
struct port *inport = GET_IN_PORT(this, i);
|
||||
|
|
@ -854,20 +853,20 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
continue;
|
||||
|
||||
if (inport->queued_bytes == 0 &&
|
||||
inio->status == SPA_RESULT_HAVE_BUFFER && inio->buffer_id < inport->n_buffers) {
|
||||
inio->status == SPA_STATUS_HAVE_BUFFER && inio->buffer_id < inport->n_buffers) {
|
||||
struct buffer *b = &inport->buffers[inio->buffer_id];
|
||||
uint32_t index;
|
||||
|
||||
if (!b->outstanding) {
|
||||
spa_log_warn(this->log, NAME " %p: buffer %u in use", this,
|
||||
inio->buffer_id);
|
||||
inio->status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
inio->status = -EINVAL;
|
||||
continue;
|
||||
}
|
||||
|
||||
b->outstanding = false;
|
||||
inio->buffer_id = SPA_ID_INVALID;
|
||||
inio->status = SPA_RESULT_OK;
|
||||
inio->status = SPA_STATUS_OK;
|
||||
|
||||
spa_list_append(&inport->queue, &b->link);
|
||||
|
||||
|
|
@ -887,7 +886,7 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
if (min_queued != SIZE_MAX && min_queued > 0) {
|
||||
outio->status = mix_output(this, min_queued);
|
||||
} else {
|
||||
outio->status = SPA_RESULT_NEED_BUFFER;
|
||||
outio->status = SPA_STATUS_NEED_BUFFER;
|
||||
}
|
||||
return outio->status;
|
||||
}
|
||||
|
|
@ -900,16 +899,16 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
int i;
|
||||
size_t min_queued = SIZE_MAX;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
outport = GET_OUT_PORT(this, 0);
|
||||
outio = outport->io;
|
||||
spa_return_val_if_fail(outio != NULL, SPA_RESULT_ERROR);
|
||||
spa_return_val_if_fail(outio != NULL, -EIO);
|
||||
|
||||
if (outio->status == SPA_RESULT_HAVE_BUFFER)
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
if (outio->status == SPA_STATUS_HAVE_BUFFER)
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
/* recycle */
|
||||
if (outio->buffer_id < outport->n_buffers) {
|
||||
|
|
@ -939,9 +938,9 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
|
||||
if (inport->queued_bytes == 0) {
|
||||
inio->range = outio->range;
|
||||
inio->status = SPA_RESULT_NEED_BUFFER;
|
||||
inio->status = SPA_STATUS_NEED_BUFFER;
|
||||
} else {
|
||||
inio->status = SPA_RESULT_OK;
|
||||
inio->status = SPA_STATUS_OK;
|
||||
}
|
||||
spa_log_trace(this->log, NAME " %p: port %d %d queued %zd, res %d", this,
|
||||
i, outio->range.min_size, inport->queued_bytes, inio->status);
|
||||
|
|
@ -977,22 +976,22 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -1006,8 +1005,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct port *port;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -1022,7 +1021,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "an id-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -1036,7 +1035,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
spa_audiomixer_get_ops(&this->ops);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -1046,19 +1045,21 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[*index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_audiomixer_factory = {
|
||||
|
|
|
|||
|
|
@ -17,21 +17,25 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
|
||||
extern const struct spa_handle_factory spa_audiomixer_factory;
|
||||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*factory = &spa_audiomixer_factory;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
|
@ -176,9 +177,9 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
uint32_t offset;
|
||||
struct spa_pod *param;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -188,7 +189,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
next:
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
|
|
@ -198,7 +199,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
|
|
@ -212,7 +213,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
2, 0.0, 10.0);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -220,7 +221,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
|
|
@ -229,7 +230,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -239,7 +240,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
|
||||
if (param == NULL) {
|
||||
reset_props(this, p);
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":",t->prop_live, "?b", &p->live,
|
||||
|
|
@ -254,9 +255,9 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
this->info.flags &= ~SPA_PORT_INFO_FLAG_LIVE;
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "render.c"
|
||||
|
|
@ -302,7 +303,7 @@ static int make_buffer(struct impl *this)
|
|||
if (spa_list_is_empty(&this->empty)) {
|
||||
set_timer(this, false);
|
||||
spa_log_error(this->log, NAME " %p: out of buffers", this);
|
||||
return SPA_RESULT_OUT_OF_BUFFERS;
|
||||
return -EPIPE;
|
||||
}
|
||||
b = spa_list_first(&this->empty, struct buffer, link);
|
||||
spa_list_remove(&b->link);
|
||||
|
|
@ -363,7 +364,7 @@ static int make_buffer(struct impl *this)
|
|||
set_timer(this, true);
|
||||
|
||||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_HAVE_BUFFER;
|
||||
io->status = SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
return io->status;
|
||||
}
|
||||
|
|
@ -375,7 +376,7 @@ static void on_output(struct spa_source *source)
|
|||
|
||||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER)
|
||||
if (res == SPA_STATUS_HAVE_BUFFER)
|
||||
this->callbacks->have_output(this->callbacks_data);
|
||||
}
|
||||
|
||||
|
|
@ -383,8 +384,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -392,13 +393,12 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
struct timespec now;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if (this->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
if (this->props.live)
|
||||
|
|
@ -412,20 +412,19 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
set_timer(this, true);
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if (!this->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
this->started = false;
|
||||
set_timer(this, false);
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -435,14 +434,14 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -452,7 +451,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
|
|
@ -463,7 +462,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -473,23 +472,23 @@ impl_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -500,16 +499,16 @@ impl_node_port_get_info(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
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), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -538,9 +537,9 @@ port_enum_formats(struct impl *this,
|
|||
2, 1, INT32_MAX);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -554,10 +553,9 @@ port_get_format(struct impl *this,
|
|||
struct type *t = &this->type;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = spa_pod_builder_object(builder,
|
||||
t->param.idFormat, t->format,
|
||||
|
|
@ -567,7 +565,7 @@ port_get_format(struct impl *this,
|
|||
":", t->format_audio.rate, "i", this->current_format.info.raw.rate,
|
||||
":", t->format_audio.channels, "i", this->current_format.info.raw.channels);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -583,14 +581,14 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
struct spa_pod *param;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
offset = builder->offset;
|
||||
|
||||
|
|
@ -605,21 +603,21 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
if ((res = port_enum_formats(this, direction, port_id, index, ¶m, builder)) < 0)
|
||||
if ((res = port_enum_formats(this, direction, port_id, index, ¶m, builder)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if ((res = port_get_format(this, direction, port_id, index, ¶m, builder)) < 0)
|
||||
if ((res = port_get_format(this, direction, port_id, index, ¶m, builder)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param_buffers.Buffers,
|
||||
|
|
@ -633,7 +631,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
}
|
||||
else if (id == t->param.idMeta) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
|
|
@ -654,11 +652,11 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_meta.ringbufferAlign, "i", 16);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -666,7 +664,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int clear_buffers(struct impl *this)
|
||||
|
|
@ -678,7 +676,7 @@ static int clear_buffers(struct impl *this)
|
|||
this->started = false;
|
||||
set_timer(this, false);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -704,10 +702,10 @@ port_set_format(struct impl *this,
|
|||
|
||||
if (info.media_type != t->media_type.audio ||
|
||||
info.media_subtype != t->media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_format_audio_raw_parse(format, &info.info.raw, &t->format_audio) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (info.info.raw.format == t->audio_format.S16)
|
||||
idx = 0;
|
||||
|
|
@ -718,7 +716,7 @@ port_set_format(struct impl *this,
|
|||
else if (info.info.raw.format == t->audio_format.F64)
|
||||
idx = 3;
|
||||
else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
this->bpf = sizes[idx] * info.info.raw.channels;
|
||||
this->current_format = info;
|
||||
|
|
@ -729,7 +727,7 @@ port_set_format(struct impl *this,
|
|||
if (this->have_format) {
|
||||
this->info.rate = this->current_format.info.raw.rate;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -741,17 +739,17 @@ impl_node_port_set_param(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (id == t->param.idFormat)
|
||||
return port_set_format(this, direction, port_id, flags, param);
|
||||
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -764,14 +762,14 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
clear_buffers(this);
|
||||
|
||||
|
|
@ -790,13 +788,13 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
d[0].type == this->type.data.DmaBuf) && d[0].data == NULL) {
|
||||
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
|
||||
buffers[i]);
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
spa_list_append(&this->empty, &b->link);
|
||||
}
|
||||
this->n_buffers = n_buffers;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -810,16 +808,16 @@ impl_node_port_alloc_buffers(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -830,15 +828,15 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
this->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void reuse_buffer(struct impl *this, uint32_t id)
|
||||
|
|
@ -859,17 +857,16 @@ static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(port_id == 0, SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(this->n_buffers > 0, SPA_RESULT_NO_BUFFERS);
|
||||
spa_return_val_if_fail(buffer_id < this->n_buffers, SPA_RESULT_INVALID_BUFFER_ID);
|
||||
spa_return_val_if_fail(port_id == 0, -EINVAL);
|
||||
spa_return_val_if_fail(buffer_id < this->n_buffers, -EINVAL);
|
||||
|
||||
reuse_buffer(this, buffer_id);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -878,12 +875,12 @@ impl_node_port_send_command(struct spa_node *node,
|
|||
uint32_t port_id,
|
||||
const struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
|
|
@ -891,24 +888,24 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
struct impl *this;
|
||||
struct spa_port_io *io;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
io = this->io;
|
||||
spa_return_val_if_fail(io != NULL, SPA_RESULT_UNEXPECTED);
|
||||
spa_return_val_if_fail(io != NULL, -EIO);
|
||||
|
||||
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
if (io->status == SPA_STATUS_HAVE_BUFFER)
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
if (io->buffer_id < this->n_buffers) {
|
||||
reuse_buffer(this, this->io->buffer_id);
|
||||
this->io->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
if (!this->props.live && (io->status == SPA_RESULT_NEED_BUFFER))
|
||||
if (!this->props.live && (io->status == SPA_STATUS_NEED_BUFFER))
|
||||
return make_buffer(this);
|
||||
else
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_STATUS_OK;
|
||||
}
|
||||
|
||||
static const struct spa_dict_item node_info_items[] = {
|
||||
|
|
@ -946,13 +943,13 @@ static const struct spa_node impl_node = {
|
|||
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_clock_set_param(struct spa_clock *clock, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -964,7 +961,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
struct timespec now;
|
||||
uint64_t tnow;
|
||||
|
||||
spa_return_val_if_fail(clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(clock != NULL, -EINVAL);
|
||||
|
||||
if (rate)
|
||||
*rate = SPA_NSEC_PER_SEC;
|
||||
|
|
@ -977,7 +974,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
if (monotonic_time)
|
||||
*monotonic_time = tnow;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
|
|
@ -993,8 +990,8 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -1003,16 +1000,16 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
else if (interface_id == this->type.clock)
|
||||
*interface = &this->clock;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -1020,7 +1017,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
spa_loop_remove_source(this->data_loop, &this->timer_source);
|
||||
close(this->timer_source.fd);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -1033,8 +1030,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -1051,7 +1048,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -1080,7 +1077,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
spa_log_info(this->log, NAME " %p: initialized", this);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -1091,19 +1088,22 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[*index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_dict_item info_items[] = {
|
||||
|
|
|
|||
|
|
@ -17,21 +17,25 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
|
||||
extern const struct spa_handle_factory spa_audiotestsrc_factory;
|
||||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*factory = &spa_audiotestsrc_factory;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -88,14 +89,14 @@ static int spa_ffmpeg_dec_node_enum_params(struct spa_node *node,
|
|||
const struct spa_pod_object *filter,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_set_param(struct spa_node *node,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
|
|
@ -103,7 +104,7 @@ static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, const struct
|
|||
struct impl *this;
|
||||
|
||||
if (node == NULL || command == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -112,9 +113,9 @@ static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, const struct
|
|||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
this->started = false;
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -125,14 +126,14 @@ spa_ffmpeg_dec_node_set_callbacks(struct spa_node *node,
|
|||
struct impl *this;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -143,7 +144,7 @@ spa_ffmpeg_dec_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *max_output_ports)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
|
|
@ -154,7 +155,7 @@ spa_ffmpeg_dec_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -165,21 +166,21 @@ spa_ffmpeg_dec_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t *output_ids)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ports > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -187,7 +188,7 @@ spa_ffmpeg_dec_node_remove_port(struct spa_node *node,
|
|||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -200,18 +201,18 @@ spa_ffmpeg_dec_node_port_get_info(struct spa_node *node,
|
|||
struct port *port;
|
||||
|
||||
if (node == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
*info = &port->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
|
|
@ -224,23 +225,21 @@ static int port_enum_formats(struct spa_node *node,
|
|||
//struct impl *this;
|
||||
|
||||
if (node == NULL || index == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
//this = SPA_CONTAINER_OF (node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*param = NULL;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
|
|
@ -257,14 +256,14 @@ static int port_get_format(struct spa_node *node,
|
|||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = NULL;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -291,18 +290,18 @@ spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -310,7 +309,7 @@ spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
@ -322,19 +321,19 @@ static int port_set_format(struct spa_node *node,
|
|||
struct port *port;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (format == NULL) {
|
||||
port->have_format = false;
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
} else {
|
||||
struct spa_video_info info = { 0 };
|
||||
|
||||
|
|
@ -344,17 +343,17 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (info.media_type != this->type.media_type.video &&
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (!(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
|
||||
port->current_format = info;
|
||||
port->have_format = true;
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -370,7 +369,7 @@ spa_ffmpeg_dec_node_port_set_param(struct spa_node *node,
|
|||
return port_set_format(node, direction, port_id, flags, param);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -381,12 +380,12 @@ spa_ffmpeg_dec_node_port_use_buffers(struct spa_node *node,
|
|||
uint32_t n_buffers)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (!IS_VALID_PORT(node, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -398,7 +397,7 @@ spa_ffmpeg_dec_node_port_alloc_buffers(struct spa_node *node,
|
|||
struct spa_buffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -411,23 +410,23 @@ spa_ffmpeg_dec_node_port_set_io(struct spa_node *node,
|
|||
struct port *port;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_process_output(struct spa_node *node)
|
||||
|
|
@ -437,34 +436,34 @@ static int spa_ffmpeg_dec_node_process_output(struct spa_node *node)
|
|||
struct spa_port_io *output;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
port = &this->out_ports[0];
|
||||
|
||||
if ((output = port->io) == NULL)
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EIO;
|
||||
|
||||
if (!port->have_format) {
|
||||
output->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
output->status = -EIO;
|
||||
return -EIO;
|
||||
}
|
||||
output->status = SPA_RESULT_OK;
|
||||
output->status = SPA_STATUS_OK;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -473,7 +472,7 @@ spa_ffmpeg_dec_node_port_send_command(struct spa_node *node,
|
|||
uint32_t port_id,
|
||||
const struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -506,16 +505,16 @@ spa_ffmpeg_dec_get_interface(struct spa_handle *handle, uint32_t interface_id, v
|
|||
struct impl *this;
|
||||
|
||||
if (handle == NULL || interface == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -539,7 +538,7 @@ spa_ffmpeg_dec_init(struct spa_handle *handle,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -548,5 +547,5 @@ spa_ffmpeg_dec_init(struct spa_handle *handle,
|
|||
this->in_ports[0].info.flags = 0;
|
||||
this->out_ports[0].info.flags = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -92,13 +93,13 @@ static int spa_ffmpeg_enc_node_enum_params(struct spa_node *node,
|
|||
const struct spa_pod_object *filter,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
|
|
@ -106,7 +107,7 @@ static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, const struct
|
|||
struct impl *this;
|
||||
|
||||
if (node == NULL || command == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -115,9 +116,9 @@ static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, const struct
|
|||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
this->started = false;
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -128,14 +129,14 @@ spa_ffmpeg_enc_node_set_callbacks(struct spa_node *node,
|
|||
struct impl *this;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -146,7 +147,7 @@ spa_ffmpeg_enc_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *max_output_ports)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
|
|
@ -157,7 +158,7 @@ spa_ffmpeg_enc_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -168,28 +169,28 @@ spa_ffmpeg_enc_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t *output_ids)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ports > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_remove_port(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -201,18 +202,18 @@ spa_ffmpeg_enc_node_port_get_info(struct spa_node *node,
|
|||
struct port *port;
|
||||
|
||||
if (node == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
*info = &port->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
|
|
@ -232,9 +233,9 @@ static int port_enum_formats(struct spa_node *node,
|
|||
*param = NULL;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
|
|
@ -251,14 +252,14 @@ static int port_get_format(struct spa_node *node,
|
|||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = NULL;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -285,18 +286,18 @@ spa_ffmpeg_enc_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -304,7 +305,7 @@ spa_ffmpeg_enc_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
@ -319,7 +320,7 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (format == NULL) {
|
||||
port->have_format = false;
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
} else {
|
||||
struct spa_video_info info = { 0 };
|
||||
|
||||
|
|
@ -329,17 +330,17 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (info.media_type != this->type.media_type.video &&
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (!(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
|
||||
port->current_format = info;
|
||||
port->have_format = true;
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -355,7 +356,7 @@ spa_ffmpeg_enc_node_port_set_param(struct spa_node *node,
|
|||
return port_set_format(node, direction, port_id, flags, param);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -365,12 +366,12 @@ spa_ffmpeg_enc_node_port_use_buffers(struct spa_node *node,
|
|||
struct spa_buffer **buffers, uint32_t n_buffers)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (!IS_VALID_PORT(node, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -382,7 +383,7 @@ spa_ffmpeg_enc_node_port_alloc_buffers(struct spa_node *node,
|
|||
struct spa_buffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -394,30 +395,30 @@ spa_ffmpeg_enc_node_port_set_io(struct spa_node *node,
|
|||
struct port *port;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -425,12 +426,12 @@ spa_ffmpeg_enc_node_port_send_command(struct spa_node *node,
|
|||
enum spa_direction direction,
|
||||
uint32_t port_id, const struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_process_output(struct spa_node *node)
|
||||
|
|
@ -440,22 +441,22 @@ static int spa_ffmpeg_enc_node_process_output(struct spa_node *node)
|
|||
struct spa_port_io *output;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if ((output = this->out_ports[0].io) == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
return -EIO;
|
||||
|
||||
port = &this->out_ports[0];
|
||||
|
||||
if (!port->have_format) {
|
||||
output->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
output->status = -EIO;
|
||||
return -EIO;
|
||||
}
|
||||
output->status = SPA_RESULT_OK;
|
||||
output->status = SPA_STATUS_OK;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_STATUS_OK;
|
||||
}
|
||||
|
||||
static const struct spa_node ffmpeg_enc_node = {
|
||||
|
|
@ -487,16 +488,16 @@ spa_ffmpeg_enc_get_interface(struct spa_handle *handle, uint32_t interface_id, v
|
|||
struct impl *this;
|
||||
|
||||
if (handle == NULL || interface == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -519,7 +520,7 @@ spa_ffmpeg_enc_init(struct spa_handle *handle,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
this->node = ffmpeg_enc_node;
|
||||
|
|
@ -527,5 +528,5 @@ spa_ffmpeg_enc_init(struct spa_handle *handle,
|
|||
this->in_ports[0].info.flags = 0;
|
||||
this->out_ports[0].info.flags = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
|
|
@ -38,7 +39,7 @@ ffmpeg_dec_init(const struct spa_handle_factory *factory,
|
|||
uint32_t n_support)
|
||||
{
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
return spa_ffmpeg_dec_init(handle, info, support, n_support);
|
||||
}
|
||||
|
|
@ -51,7 +52,7 @@ ffmpeg_enc_init(const struct spa_handle_factory *factory,
|
|||
uint32_t n_support)
|
||||
{
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
return spa_ffmpeg_enc_init(handle, info, support, n_support);
|
||||
}
|
||||
|
|
@ -63,20 +64,20 @@ static const struct spa_interface_info ffmpeg_interfaces[] = {
|
|||
static int
|
||||
ffmpeg_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
if (factory == NULL || info == NULL || index == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
if (*index < SPA_N_ELEMENTS(ffmpeg_interfaces))
|
||||
*info = &ffmpeg_interfaces[(*index)++];
|
||||
else
|
||||
return 0;
|
||||
|
||||
*info = &ffmpeg_interfaces[index];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
||||
{
|
||||
static const AVCodec *c = NULL;
|
||||
static int ci = 0;
|
||||
|
|
@ -85,16 +86,16 @@ int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t
|
|||
|
||||
av_register_all();
|
||||
|
||||
if (index == 0) {
|
||||
if (*index == 0) {
|
||||
c = av_codec_next(NULL);
|
||||
ci = 0;
|
||||
}
|
||||
while (index > ci && c) {
|
||||
while (*index > ci && c) {
|
||||
c = av_codec_next(c);
|
||||
ci++;
|
||||
}
|
||||
if (c == NULL)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
if (av_codec_is_encoder(c)) {
|
||||
snprintf(name, 128, "ffenc_%s", c->name);
|
||||
|
|
@ -108,6 +109,7 @@ int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t
|
|||
f.enum_interface_info = ffmpeg_enum_interface_info;
|
||||
|
||||
*factory = &f;
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,24 +151,24 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.log)
|
||||
*interface = &this->log;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
close(this->source.fd);
|
||||
this->have_source = false;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -191,8 +191,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
uint32_t i;
|
||||
struct spa_loop *loop = NULL;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -209,7 +209,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(&this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
spa_log_debug(&this->log, NAME " %p: initialized", this);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -237,19 +237,22 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[*index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_handle_factory logger_factory = {
|
||||
|
|
|
|||
|
|
@ -157,9 +157,9 @@ static int loop_add_source(struct spa_loop *loop, struct spa_source *source)
|
|||
ep.data.ptr = source;
|
||||
|
||||
if (epoll_ctl(impl->epoll_fd, EPOLL_CTL_ADD, source->fd, &ep) < 0)
|
||||
return SPA_RESULT_ERRNO;
|
||||
return errno;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int loop_update_source(struct spa_source *source)
|
||||
|
|
@ -175,9 +175,9 @@ static int loop_update_source(struct spa_source *source)
|
|||
ep.data.ptr = source;
|
||||
|
||||
if (epoll_ctl(impl->epoll_fd, EPOLL_CTL_MOD, source->fd, &ep) < 0)
|
||||
return SPA_RESULT_ERRNO;
|
||||
return errno;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void loop_remove_source(struct spa_source *source)
|
||||
|
|
@ -215,12 +215,12 @@ loop_invoke(struct spa_loop *loop,
|
|||
filled = spa_ringbuffer_get_write_index(&impl->buffer, &idx);
|
||||
if (filled < 0 || filled > impl->buffer.size) {
|
||||
spa_log_warn(impl->log, NAME " %p: queue xrun %d", impl, filled);
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EPIPE;
|
||||
}
|
||||
avail = impl->buffer.size - filled;
|
||||
if (avail < sizeof(struct invoke_item)) {
|
||||
spa_log_warn(impl->log, NAME " %p: queue full %d", impl, avail);
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EPIPE;
|
||||
}
|
||||
offset = idx & impl->buffer.mask;
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ loop_invoke(struct spa_loop *loop,
|
|||
if (seq != SPA_ID_INVALID)
|
||||
res = SPA_RESULT_RETURN_ASYNC(seq);
|
||||
else
|
||||
res = SPA_RESULT_OK;
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
|
@ -329,10 +329,8 @@ static int loop_iterate(struct spa_loop_control *ctrl, int timeout)
|
|||
|
||||
spa_hook_list_call(&impl->hooks_list, struct spa_loop_control_hooks, after);
|
||||
|
||||
if (SPA_UNLIKELY(nfds < 0)) {
|
||||
errno = save_errno;
|
||||
return SPA_RESULT_ERRNO;
|
||||
}
|
||||
if (SPA_UNLIKELY(nfds < 0))
|
||||
return save_errno;
|
||||
|
||||
/* first we set all the rmasks, then call the callbacks. The reason is that
|
||||
* some callback might also want to look at other sources it manages and
|
||||
|
|
@ -352,7 +350,7 @@ static int loop_iterate(struct spa_loop_control *ctrl, int timeout)
|
|||
|
||||
spa_list_init(&impl->destroy_list);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void source_io_func(struct spa_source *source)
|
||||
|
|
@ -555,9 +553,9 @@ loop_update_timer(struct spa_source *source,
|
|||
flags |= TFD_TIMER_ABSTIME;
|
||||
|
||||
if (timerfd_settime(source->fd, flags, &its, NULL) < 0)
|
||||
return SPA_RESULT_ERRNO;
|
||||
return errno;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void source_signal_func(struct spa_source *source)
|
||||
|
|
@ -660,8 +658,8 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *impl;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
impl = (struct impl *) handle;
|
||||
|
||||
|
|
@ -672,9 +670,9 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
else if (interface_id == impl->type.loop_utils)
|
||||
*interface = &impl->utils;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
|
|
@ -682,7 +680,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
struct impl *impl;
|
||||
struct source_impl *source, *tmp;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
impl = (struct impl *) handle;
|
||||
|
||||
|
|
@ -694,7 +692,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
close(impl->ack_fd);
|
||||
close(impl->epoll_fd);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -707,8 +705,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct impl *impl;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -726,13 +724,13 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (impl->map == NULL) {
|
||||
spa_log_error(impl->log, NAME " %p: a type-map is needed", impl);
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&impl->type, impl->map);
|
||||
|
||||
impl->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
|
||||
if (impl->epoll_fd == -1)
|
||||
return SPA_RESULT_ERRNO;
|
||||
return errno;
|
||||
|
||||
spa_list_init(&impl->source_list);
|
||||
spa_list_init(&impl->destroy_list);
|
||||
|
|
@ -745,7 +743,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
spa_log_info(impl->log, NAME " %p: initialized", impl);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -757,16 +755,17 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
if (index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
if (*index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return 0;
|
||||
|
||||
*info = &impl_interfaces[index];
|
||||
return SPA_RESULT_OK;
|
||||
*info = &impl_interfaces[(*index)++];
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_handle_factory loop_factory = {
|
||||
|
|
|
|||
|
|
@ -125,24 +125,24 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *impl;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
impl = (struct impl *) handle;
|
||||
|
||||
if (interface_id == impl->type.type_map)
|
||||
*interface = &impl->map;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *impl;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
impl = (struct impl *) handle;
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
if (impl->strings.data)
|
||||
free(impl->strings.data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -163,8 +163,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
{
|
||||
struct impl *impl;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -175,7 +175,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
init_type(&impl->type, &impl->map);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -185,19 +185,21 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[*index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_handle_factory type_map_factory = {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
|
|
@ -36,13 +37,14 @@ spa_handle_factory_register(const struct spa_handle_factory *factory)
|
|||
}
|
||||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
if (index >= n_factories)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
if (*index >= n_factories)
|
||||
return 0;
|
||||
|
||||
*factory = factories[index];
|
||||
return SPA_RESULT_OK;
|
||||
*factory = factories[(*index)++];
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
|
@ -137,8 +138,8 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
uint32_t offset;
|
||||
struct spa_pod *param;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -148,7 +149,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
next:
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
|
|
@ -156,14 +157,14 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
}
|
||||
else if (id == t->param.idProps) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
":", t->prop_live, "b", this->props.live);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -171,7 +172,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
|
|
@ -180,7 +181,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -188,7 +189,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
if (id == t->param.idProps) {
|
||||
if (param == NULL) {
|
||||
reset_props(this, &this->props);
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_live, "?b", &this->props.live, NULL);
|
||||
|
|
@ -199,9 +200,9 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
this->info.flags &= ~SPA_PORT_INFO_FLAG_LIVE;
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
|
|
@ -247,13 +248,13 @@ static int consume_buffer(struct impl *this)
|
|||
read_timer(this);
|
||||
|
||||
if (spa_list_is_empty(&this->ready)) {
|
||||
io->status = SPA_RESULT_NEED_BUFFER;
|
||||
io->status = SPA_STATUS_NEED_BUFFER;
|
||||
if (this->callbacks->need_input)
|
||||
this->callbacks->need_input(this->callbacks_data);
|
||||
}
|
||||
if (spa_list_is_empty(&this->ready)) {
|
||||
spa_log_error(this->log, NAME " %p: no buffers", this);
|
||||
return SPA_RESULT_NEED_BUFFER;
|
||||
return -EPIPE;
|
||||
}
|
||||
|
||||
b = spa_list_first(&this->ready, struct buffer, link);
|
||||
|
|
@ -280,10 +281,10 @@ static int consume_buffer(struct impl *this)
|
|||
set_timer(this, true);
|
||||
|
||||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_NEED_BUFFER;
|
||||
io->status = SPA_STATUS_NEED_BUFFER;
|
||||
b->outstanding = true;
|
||||
|
||||
return SPA_RESULT_NEED_BUFFER;
|
||||
return SPA_STATUS_NEED_BUFFER;
|
||||
}
|
||||
|
||||
static void on_input(struct spa_source *source)
|
||||
|
|
@ -297,8 +298,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -306,13 +307,12 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
struct timespec now;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if (this->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
if (this->props.live)
|
||||
|
|
@ -326,20 +326,19 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
set_timer(this, true);
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if (!this->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
this->started = false;
|
||||
set_timer(this, false);
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -349,18 +348,18 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks != NULL && callbacks->need_input != NULL) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -370,7 +369,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
|
|
@ -381,7 +380,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -391,23 +390,23 @@ impl_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -418,16 +417,16 @@ impl_node_port_get_info(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
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), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
|
|
@ -437,7 +436,7 @@ static int port_enum_formats(struct spa_node *node,
|
|||
struct spa_pod_builder *builder,
|
||||
struct spa_pod **param)
|
||||
{
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
|
|
@ -450,14 +449,14 @@ static int port_get_format(struct spa_node *node,
|
|||
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = SPA_MEMBER(this->format_buffer, 0, struct spa_pod);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -473,14 +472,14 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
struct spa_pod *param;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
offset = builder->offset;
|
||||
|
||||
|
|
@ -495,19 +494,19 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param_buffers.Buffers,
|
||||
|
|
@ -526,11 +525,11 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_meta.size, "i", sizeof(struct spa_meta_header));
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -538,7 +537,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int clear_buffers(struct impl *this)
|
||||
|
|
@ -550,7 +549,7 @@ static int clear_buffers(struct impl *this)
|
|||
this->started = false;
|
||||
set_timer(this, false);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
@ -565,11 +564,11 @@ static int port_set_format(struct spa_node *node,
|
|||
clear_buffers(this);
|
||||
} else {
|
||||
if (SPA_POD_SIZE(format) > sizeof(this->format_buffer))
|
||||
return SPA_RESULT_ERROR;
|
||||
return -ENOSPC;
|
||||
memcpy(this->format_buffer, format, SPA_POD_SIZE(format));
|
||||
this->have_format = true;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -581,18 +580,18 @@ impl_node_port_set_param(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (id == t->param.idFormat) {
|
||||
return port_set_format(node, direction, port_id, flags, param);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -605,14 +604,14 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
clear_buffers(this);
|
||||
|
||||
|
|
@ -634,7 +633,7 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
}
|
||||
this->n_buffers = n_buffers;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -648,16 +647,16 @@ impl_node_port_alloc_buffers(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -668,20 +667,20 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
this->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -690,7 +689,7 @@ impl_node_port_send_command(struct spa_node *node,
|
|||
uint32_t port_id,
|
||||
const struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
|
|
@ -698,20 +697,20 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
struct impl *this;
|
||||
struct spa_port_io *input;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
input = this->io;
|
||||
spa_return_val_if_fail(input != NULL, SPA_RESULT_UNEXPECTED);
|
||||
spa_return_val_if_fail(input != NULL, -EIO);
|
||||
|
||||
if (input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id < this->n_buffers) {
|
||||
if (input->status == SPA_STATUS_HAVE_BUFFER && input->buffer_id < this->n_buffers) {
|
||||
struct buffer *b = &this->buffers[input->buffer_id];
|
||||
|
||||
if (!b->outstanding) {
|
||||
spa_log_warn(this->log, NAME " %p: buffer %u in use", this,
|
||||
input->buffer_id);
|
||||
input->status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
return SPA_RESULT_ERROR;
|
||||
input->status = -EINVAL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
spa_log_trace(this->log, NAME " %p: queue buffer %u", this, input->buffer_id);
|
||||
|
|
@ -720,17 +719,17 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
b->outstanding = false;
|
||||
|
||||
input->buffer_id = SPA_ID_INVALID;
|
||||
input->status = SPA_RESULT_OK;
|
||||
input->status = SPA_STATUS_OK;
|
||||
}
|
||||
if (this->callbacks == NULL || this->callbacks->need_input == NULL)
|
||||
return consume_buffer(this);
|
||||
else
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_STATUS_OK;
|
||||
}
|
||||
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
|
|
@ -759,13 +758,13 @@ static const struct spa_node impl_node = {
|
|||
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_clock_set_param(struct spa_clock *clock, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -777,7 +776,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
struct timespec now;
|
||||
uint64_t tnow;
|
||||
|
||||
spa_return_val_if_fail(clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(clock != NULL, -EINVAL);
|
||||
|
||||
if (rate)
|
||||
*rate = SPA_NSEC_PER_SEC;
|
||||
|
|
@ -790,7 +789,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
if (monotonic_time)
|
||||
*monotonic_time = tnow;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
|
|
@ -806,8 +805,8 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -816,16 +815,16 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
else if (interface_id == this->type.clock)
|
||||
*interface = &this->clock;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -833,7 +832,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
spa_loop_remove_source(this->data_loop, &this->timer_source);
|
||||
close(this->timer_source.fd);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -846,8 +845,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -864,7 +863,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -893,7 +892,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
spa_log_info(this->log, NAME " %p: initialized", this);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -904,19 +903,21 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[*index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_fakesink_factory = {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
|
@ -143,9 +144,9 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
uint32_t offset;
|
||||
struct spa_pod *param;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -155,7 +156,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
next:
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
|
|
@ -165,7 +166,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
|
|
@ -174,7 +175,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
1, p->pattern);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -182,7 +183,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
|
|
@ -191,7 +192,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -201,7 +202,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
|
||||
if (param == NULL) {
|
||||
reset_props(this, p);
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_live, "?b", &p->live,
|
||||
|
|
@ -213,14 +214,14 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
this->info.flags &= ~SPA_PORT_INFO_FLAG_LIVE;
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fill_buffer(struct impl *this, struct buffer *b)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
|
|
@ -265,7 +266,7 @@ static int make_buffer(struct impl *this)
|
|||
set_timer(this, false);
|
||||
this->underrun = true;
|
||||
spa_log_error(this->log, NAME " %p: out of buffers", this);
|
||||
return SPA_RESULT_OUT_OF_BUFFERS;
|
||||
return -EPIPE;
|
||||
}
|
||||
b = spa_list_first(&this->empty, struct buffer, link);
|
||||
spa_list_remove(&b->link);
|
||||
|
|
@ -292,9 +293,9 @@ static int make_buffer(struct impl *this)
|
|||
set_timer(this, true);
|
||||
|
||||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_HAVE_BUFFER;
|
||||
io->status = SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
}
|
||||
|
||||
static void on_output(struct spa_source *source)
|
||||
|
|
@ -304,7 +305,7 @@ static void on_output(struct spa_source *source)
|
|||
|
||||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER && this->callbacks && this->callbacks->have_output)
|
||||
if (res == SPA_STATUS_HAVE_BUFFER && this->callbacks && this->callbacks->have_output)
|
||||
this->callbacks->have_output(this->callbacks_data);
|
||||
}
|
||||
|
||||
|
|
@ -312,8 +313,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -321,13 +322,13 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
struct timespec now;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if (this->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
if (this->props.live)
|
||||
|
|
@ -341,20 +342,19 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
set_timer(this, true);
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if (!this->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
this->started = false;
|
||||
set_timer(this, false);
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -364,18 +364,18 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && (callbacks != NULL && callbacks->have_output != NULL)) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -385,7 +385,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
|
|
@ -396,7 +396,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -406,23 +406,23 @@ impl_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -433,16 +433,16 @@ impl_node_port_get_info(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
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), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
|
|
@ -452,7 +452,7 @@ static int port_enum_formats(struct spa_node *node,
|
|||
struct spa_pod_builder *builder,
|
||||
struct spa_pod **param)
|
||||
{
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
|
|
@ -465,13 +465,13 @@ static int port_get_format(struct spa_node *node,
|
|||
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = SPA_MEMBER(this->format_buffer, 0, struct spa_pod);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -487,14 +487,14 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
struct spa_pod *param;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
offset = builder->offset;
|
||||
|
||||
|
|
@ -509,19 +509,19 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param_buffers.Buffers,
|
||||
|
|
@ -540,11 +540,11 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_meta.size, "i", sizeof(struct spa_meta_header));
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -552,7 +552,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int clear_buffers(struct impl *this)
|
||||
|
|
@ -564,7 +564,7 @@ static int clear_buffers(struct impl *this)
|
|||
this->started = false;
|
||||
set_timer(this, false);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
@ -579,11 +579,11 @@ static int port_set_format(struct spa_node *node,
|
|||
clear_buffers(this);
|
||||
} else {
|
||||
if (SPA_POD_SIZE(format) > sizeof(this->format_buffer))
|
||||
return SPA_RESULT_ERROR;
|
||||
return -ENOSPC;
|
||||
memcpy(this->format_buffer, format, SPA_POD_SIZE(format));
|
||||
this->have_format = true;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -595,18 +595,18 @@ impl_node_port_set_param(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (id == t->param.idFormat) {
|
||||
return port_set_format(node, direction, port_id, flags, param);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -619,14 +619,14 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
clear_buffers(this);
|
||||
|
||||
|
|
@ -650,7 +650,7 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
this->n_buffers = n_buffers;
|
||||
this->underrun = false;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -664,16 +664,16 @@ impl_node_port_alloc_buffers(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -684,15 +684,15 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
this->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void reuse_buffer(struct impl *this, uint32_t id)
|
||||
|
|
@ -715,17 +715,16 @@ static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(port_id == 0, SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(this->n_buffers > 0, SPA_RESULT_NO_BUFFERS);
|
||||
spa_return_val_if_fail(buffer_id < this->n_buffers, SPA_RESULT_INVALID_BUFFER_ID);
|
||||
spa_return_val_if_fail(port_id == 0, -EINVAL);
|
||||
spa_return_val_if_fail(buffer_id < this->n_buffers, -EINVAL);
|
||||
|
||||
reuse_buffer(this, buffer_id);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -734,12 +733,12 @@ impl_node_port_send_command(struct spa_node *node,
|
|||
uint32_t port_id,
|
||||
const struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
|
|
@ -747,14 +746,14 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
struct impl *this;
|
||||
struct spa_port_io *io;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
io = this->io;
|
||||
spa_return_val_if_fail(io != NULL, SPA_RESULT_UNEXPECTED);
|
||||
spa_return_val_if_fail(io != NULL, -EIO);
|
||||
|
||||
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
if (io->status == SPA_STATUS_HAVE_BUFFER)
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
if (io->buffer_id < this->n_buffers) {
|
||||
reuse_buffer(this, this->io->buffer_id);
|
||||
|
|
@ -762,10 +761,10 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
}
|
||||
|
||||
if ((this->callbacks == NULL || this->callbacks->have_output == NULL) &&
|
||||
(io->status == SPA_RESULT_NEED_BUFFER))
|
||||
(io->status == SPA_STATUS_NEED_BUFFER))
|
||||
return make_buffer(this);
|
||||
else
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_STATUS_OK;
|
||||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
|
|
@ -794,13 +793,13 @@ static const struct spa_node impl_node = {
|
|||
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_clock_set_param(struct spa_clock *clock, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -812,7 +811,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
struct timespec now;
|
||||
uint64_t tnow;
|
||||
|
||||
spa_return_val_if_fail(clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(clock != NULL, -EINVAL);
|
||||
|
||||
if (rate)
|
||||
*rate = SPA_NSEC_PER_SEC;
|
||||
|
|
@ -825,7 +824,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
if (monotonic_time)
|
||||
*monotonic_time = tnow;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
|
|
@ -841,8 +840,8 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -851,16 +850,16 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
else if (interface_id == this->type.clock)
|
||||
*interface = &this->clock;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -868,7 +867,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
spa_loop_remove_source(this->data_loop, &this->timer_source);
|
||||
close(this->timer_source.fd);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -881,8 +880,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -899,7 +898,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -928,7 +927,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
spa_log_info(this->log, NAME " %p: initialized", this);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -939,19 +938,21 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[*index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_fakesrc_factory = {
|
||||
|
|
|
|||
|
|
@ -17,17 +17,20 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
|
||||
extern const struct spa_handle_factory spa_fakesrc_factory;
|
||||
extern const struct spa_handle_factory spa_fakesink_factory;
|
||||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*factory = &spa_fakesrc_factory;
|
||||
break;
|
||||
|
|
@ -35,7 +38,8 @@ spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t inde
|
|||
*factory = &spa_fakesink_factory;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
|
@ -79,11 +80,13 @@ struct impl {
|
|||
static int impl_udev_open(struct impl *this)
|
||||
{
|
||||
if (this->udev != NULL)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
this->udev = udev_new();
|
||||
if (this->udev == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fill_item(struct impl *this, struct item *item, struct udev_device *udevice)
|
||||
|
|
@ -216,7 +219,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
int res;
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(monitor != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
|
|
@ -230,7 +233,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
udev_monitor_unref(this->umonitor);
|
||||
this->umonitor = udev_monitor_new_from_netlink(this->udev, "udev");
|
||||
if (this->umonitor == NULL)
|
||||
return SPA_RESULT_ERROR;
|
||||
return -ENOMEM;
|
||||
|
||||
udev_monitor_filter_add_match_subsystem_devtype(this->umonitor,
|
||||
"video4linux", NULL);
|
||||
|
|
@ -246,25 +249,26 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
spa_loop_remove_source(this->main_loop, &this->source);
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_monitor_enum_items(struct spa_monitor *monitor, struct spa_monitor_item **item, uint32_t index)
|
||||
impl_monitor_enum_items(struct spa_monitor *monitor, struct spa_monitor_item **item, uint32_t *index)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
struct udev_device *dev;
|
||||
|
||||
spa_return_val_if_fail(monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(item != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(monitor != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(item != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
return res;
|
||||
|
||||
if (index == 0) {
|
||||
if (*index == 0) {
|
||||
if (this->enumerate)
|
||||
udev_enumerate_unref(this->enumerate);
|
||||
this->enumerate = udev_enumerate_new(this->udev);
|
||||
|
|
@ -275,27 +279,28 @@ impl_monitor_enum_items(struct spa_monitor *monitor, struct spa_monitor_item **i
|
|||
this->devices = udev_enumerate_get_list_entry(this->enumerate);
|
||||
this->index = 0;
|
||||
}
|
||||
while (index > this->index && this->devices) {
|
||||
while (*index > this->index && this->devices) {
|
||||
this->devices = udev_list_entry_get_next(this->devices);
|
||||
this->index++;
|
||||
}
|
||||
if (this->devices == NULL) {
|
||||
fill_item(this, &this->uitem, NULL);
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
|
||||
dev = udev_device_new_from_syspath(this->udev, udev_list_entry_get_name(this->devices));
|
||||
|
||||
fill_item(this, &this->uitem, dev);
|
||||
if (dev == NULL)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*item = this->uitem.item;
|
||||
|
||||
this->devices = udev_list_entry_get_next(this->devices);
|
||||
this->index++;
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_monitor impl_monitor = {
|
||||
|
|
@ -309,17 +314,17 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.monitor.Monitor)
|
||||
*interface = &this->monitor;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
|
|
@ -333,7 +338,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
if (this->udev)
|
||||
udev_unref(this->udev);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -346,8 +351,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -364,17 +369,17 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (this->main_loop == NULL) {
|
||||
spa_log_error(this->log, "a main-loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
this->monitor = impl_monitor;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -384,17 +389,18 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
if (index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
if (*index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return 0;
|
||||
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[(*index)++];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_v4l2_monitor_factory = {
|
||||
|
|
|
|||
|
|
@ -178,9 +178,9 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct spa_pod *param;
|
||||
uint32_t offset;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -190,7 +190,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
next:
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
|
|
@ -200,7 +200,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder, t->param.idProps, t->props,
|
||||
":", t->prop_device, "S", p->device, sizeof(p->device),
|
||||
|
|
@ -208,7 +208,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
":", t->prop_device_fd, "i-r", p->device_fd);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(struct spa_node *node,
|
||||
|
|
@ -226,7 +226,7 @@ static int impl_node_set_param(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -236,15 +236,15 @@ static int impl_node_set_param(struct spa_node *node,
|
|||
|
||||
if (param == NULL) {
|
||||
reset_props(p);
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_device, "?S", p->device, sizeof(p->device), NULL);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_pause_done(struct spa_loop *loop,
|
||||
|
|
@ -262,7 +262,7 @@ static int do_pause_done(struct spa_loop *loop,
|
|||
|
||||
this->callbacks->done(this->callbacks_data, seq, res);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_pause(struct spa_loop *loop,
|
||||
|
|
@ -302,7 +302,7 @@ static int do_start_done(struct spa_loop *loop,
|
|||
|
||||
this->callbacks->done(this->callbacks_data, seq, res);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_start(struct spa_loop *loop,
|
||||
|
|
@ -327,15 +327,15 @@ static int do_start(struct spa_loop *loop,
|
|||
false,
|
||||
this);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -344,10 +344,9 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
int res;
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (port->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if ((res = spa_v4l2_stream_on(this)) < 0)
|
||||
return res;
|
||||
|
|
@ -363,10 +362,9 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
struct port *port = &this->out_ports[0];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (port->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
return spa_loop_invoke(this->out_ports[0].data_loop,
|
||||
do_pause,
|
||||
|
|
@ -376,9 +374,9 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
false,
|
||||
this);
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.ClockUpdate) {
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_set_callbacks(struct spa_node *node,
|
||||
|
|
@ -387,14 +385,14 @@ static int impl_node_set_callbacks(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -404,7 +402,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
|
|
@ -415,7 +413,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_get_port_ids(struct spa_node *node,
|
||||
|
|
@ -424,12 +422,12 @@ static int impl_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -437,14 +435,14 @@ static int impl_node_add_port(struct spa_node *node,
|
|||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_remove_port(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_port_get_info(struct spa_node *node,
|
||||
|
|
@ -454,16 +452,16 @@ static int impl_node_port_get_info(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
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), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->out_ports[port_id].info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
|
|
@ -478,9 +476,9 @@ static int port_get_format(struct spa_node *node,
|
|||
struct port *port = &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
spa_pod_builder_push_object(builder, t->param.idFormat, t->format);
|
||||
|
||||
|
|
@ -503,11 +501,11 @@ static int port_get_format(struct spa_node *node,
|
|||
":", t->format_video.size, "R", &port->current_format.info.h264.size,
|
||||
":", t->format_video.framerate, "F", &port->current_format.info.h264.framerate, 0);
|
||||
} else
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
*param = spa_pod_builder_pop_deref(builder);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int impl_node_port_enum_params(struct spa_node *node,
|
||||
|
|
@ -525,14 +523,14 @@ static int impl_node_port_enum_params(struct spa_node *node,
|
|||
uint32_t offset;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = &this->out_ports[port_id];
|
||||
|
||||
|
|
@ -549,20 +547,20 @@ static int impl_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
return spa_v4l2_enum_format(this, index, filter, builder);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param_buffers.Buffers,
|
||||
|
|
@ -581,11 +579,11 @@ static int impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_meta.size, "i", sizeof(struct spa_meta_header));
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -593,7 +591,7 @@ static int impl_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
@ -611,7 +609,7 @@ static int port_set_format(struct spa_node *node,
|
|||
spa_v4l2_clear_buffers(this);
|
||||
spa_v4l2_close(this);
|
||||
port->have_format = false;
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
} else {
|
||||
spa_pod_object_parse(format,
|
||||
"I", &info.media_type,
|
||||
|
|
@ -619,13 +617,13 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (info.media_type != t->media_type.video) {
|
||||
spa_log_error(this->log, "media type must be video");
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (info.media_subtype == t->media_subtype.raw) {
|
||||
if (spa_format_video_raw_parse(format, &info.info.raw, &t->format_video) < 0) {
|
||||
spa_log_error(this->log, "can't parse video raw");
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (port->have_format && info.media_type == port->current_format.media_type &&
|
||||
|
|
@ -633,25 +631,25 @@ static int port_set_format(struct spa_node *node,
|
|||
info.info.raw.format == port->current_format.info.raw.format &&
|
||||
info.info.raw.size.width == port->current_format.info.raw.size.width &&
|
||||
info.info.raw.size.height == port->current_format.info.raw.size.height)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
} else if (info.media_subtype == t->media_subtype_video.mjpg) {
|
||||
if (spa_format_video_mjpg_parse(format, &info.info.mjpg, &t->format_video) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (port->have_format && info.media_type == port->current_format.media_type &&
|
||||
info.media_subtype == port->current_format.media_subtype &&
|
||||
info.info.mjpg.size.width == port->current_format.info.mjpg.size.width &&
|
||||
info.info.mjpg.size.height == port->current_format.info.mjpg.size.height)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
} else if (info.media_subtype == t->media_subtype_video.h264) {
|
||||
if (spa_format_video_h264_parse(format, &info.info.h264, &t->format_video) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (port->have_format && info.media_type == port->current_format.media_type &&
|
||||
info.media_subtype == port->current_format.media_subtype &&
|
||||
info.info.h264.size.width == port->current_format.info.h264.size.width &&
|
||||
info.info.h264.size.height == port->current_format.info.h264.size.height)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -661,14 +659,14 @@ static int port_set_format(struct spa_node *node,
|
|||
}
|
||||
|
||||
if (spa_v4l2_set_format(this, &info, flags & SPA_NODE_PARAM_FLAG_TEST_ONLY) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (!(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
|
||||
port->current_format = info;
|
||||
port->have_format = true;
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_port_set_param(struct spa_node *node,
|
||||
|
|
@ -679,18 +677,18 @@ static int impl_node_port_set_param(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (id == t->param.idFormat) {
|
||||
return port_set_format(node, direction, port_id, flags, param);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int impl_node_port_use_buffers(struct spa_node *node,
|
||||
|
|
@ -703,16 +701,16 @@ static int impl_node_port_use_buffers(struct spa_node *node,
|
|||
struct port *port;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
if (port->n_buffers) {
|
||||
spa_v4l2_stream_off(this);
|
||||
|
|
@ -723,7 +721,7 @@ static int impl_node_port_use_buffers(struct spa_node *node,
|
|||
if ((res = spa_v4l2_use_buffers(this, buffers, n_buffers)) < 0)
|
||||
return res;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -739,17 +737,17 @@ impl_node_port_alloc_buffers(struct spa_node *node,
|
|||
struct port *port;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(buffers != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(buffers != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
res = spa_v4l2_alloc_buffers(this, params, n_params, buffers, n_buffers);
|
||||
|
||||
|
|
@ -763,15 +761,15 @@ static int impl_node_port_set_io(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
this->out_ports[port_id].io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node,
|
||||
|
|
@ -782,14 +780,13 @@ static int impl_node_port_reuse_buffer(struct spa_node *node,
|
|||
struct port *port;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(port_id == 0, SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(port_id == 0, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
port = &this->out_ports[port_id];
|
||||
|
||||
spa_return_val_if_fail(port->n_buffers > 0, SPA_RESULT_NO_BUFFERS);
|
||||
spa_return_val_if_fail(buffer_id < port->n_buffers, SPA_RESULT_INVALID_BUFFER_ID);
|
||||
spa_return_val_if_fail(buffer_id < port->n_buffers, -EINVAL);
|
||||
|
||||
res = spa_v4l2_buffer_recycle(this, buffer_id);
|
||||
|
||||
|
|
@ -804,44 +801,44 @@ static int impl_node_port_send_command(struct spa_node *node,
|
|||
struct impl *this;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
res = spa_v4l2_port_set_enabled(this, false);
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Start) {
|
||||
res = spa_v4l2_port_set_enabled(this, true);
|
||||
} else
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
res = -ENOTSUP;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
int res = SPA_RESULT_OK;
|
||||
int res = SPA_STATUS_OK;
|
||||
struct spa_port_io *io;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
port = &this->out_ports[0];
|
||||
io = port->io;
|
||||
spa_return_val_if_fail(io != NULL, SPA_RESULT_UNEXPECTED);
|
||||
spa_return_val_if_fail(io != NULL, -EIO);
|
||||
|
||||
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
if (io->status == SPA_STATUS_HAVE_BUFFER)
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
if (io->buffer_id < this->out_ports[0].n_buffers) {
|
||||
res = spa_v4l2_buffer_recycle(this, io->buffer_id);
|
||||
|
|
@ -885,14 +882,14 @@ static const struct spa_node impl_node = {
|
|||
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_clock_set_param(struct spa_clock *clock,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_clock_get_time(struct spa_clock *clock,
|
||||
|
|
@ -903,7 +900,7 @@ static int impl_clock_get_time(struct spa_clock *clock,
|
|||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(clock != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(clock, struct impl, clock);
|
||||
port = &this->out_ports[0];
|
||||
|
|
@ -915,7 +912,7 @@ static int impl_clock_get_time(struct spa_clock *clock,
|
|||
if (monotonic_time)
|
||||
*monotonic_time = port->last_monotonic;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
|
|
@ -931,8 +928,8 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -941,14 +938,14 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
else if (interface_id == this->type.clock)
|
||||
*interface = &this->clock;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -962,8 +959,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
uint32_t i;
|
||||
const char *str;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear, this = (struct impl *) handle;
|
||||
|
|
@ -980,15 +977,15 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (this->out_ports[0].main_loop == NULL) {
|
||||
spa_log_error(this->log, "a main_loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (this->out_ports[0].data_loop == NULL) {
|
||||
spa_log_error(this->log, "a data_loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -1006,7 +1003,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
strncpy(this->props.device, str, 63);
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -1016,17 +1013,18 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
|
||||
static int impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
if (index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
if (*index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return 0;
|
||||
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[(*index)++];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_v4l2_source_factory = {
|
||||
|
|
|
|||
|
|
@ -100,15 +100,16 @@ static int spa_v4l2_buffer_recycle(struct impl *this, uint32_t buffer_id)
|
|||
struct buffer *b = &port->buffers[buffer_id];
|
||||
|
||||
if (!b->outstanding)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
b->outstanding = false;
|
||||
spa_log_trace(port->log, "v4l2 %p: recycle buffer %d", this, buffer_id);
|
||||
|
||||
if (xioctl(port->fd, VIDIOC_QBUF, &b->v4l2_buffer) < 0) {
|
||||
perror("VIDIOC_QBUF");
|
||||
return errno;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spa_v4l2_clear_buffers(struct impl *this)
|
||||
|
|
@ -118,7 +119,7 @@ static int spa_v4l2_clear_buffers(struct impl *this)
|
|||
int i;
|
||||
|
||||
if (port->n_buffers == 0)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < port->n_buffers; i++) {
|
||||
struct buffer *b;
|
||||
|
|
@ -147,7 +148,7 @@ static int spa_v4l2_clear_buffers(struct impl *this)
|
|||
}
|
||||
port->n_buffers = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spa_v4l2_port_set_enabled(struct impl *this, bool enabled)
|
||||
|
|
@ -161,7 +162,7 @@ static int spa_v4l2_port_set_enabled(struct impl *this, bool enabled)
|
|||
else
|
||||
spa_loop_remove_source(port->data_loop, &port->source);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spa_v4l2_close(struct impl *this)
|
||||
|
|
@ -535,8 +536,8 @@ spa_v4l2_enum_format(struct impl *this,
|
|||
uint32_t filter_media_type, filter_media_subtype;
|
||||
struct type *t = &this->type;
|
||||
|
||||
if (spa_v4l2_open(this) < 0)
|
||||
return SPA_RESULT_ERROR;
|
||||
if ((res = spa_v4l2_open(this)) < 0)
|
||||
return res;
|
||||
|
||||
if (*index == 0) {
|
||||
spa_zero(port->fmtdesc);
|
||||
|
|
@ -568,7 +569,7 @@ spa_v4l2_enum_format(struct impl *this,
|
|||
filter, port->fmtdesc.index);
|
||||
|
||||
if (video_format == t->video_format.UNKNOWN)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
info = find_format_info_by_media_type(t,
|
||||
filter_media_type,
|
||||
|
|
@ -582,7 +583,7 @@ spa_v4l2_enum_format(struct impl *this,
|
|||
if ((res = xioctl(port->fd, VIDIOC_ENUM_FMT, &port->fmtdesc)) < 0) {
|
||||
if (errno != EINVAL)
|
||||
perror("VIDIOC_ENUM_FMT");
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
port->next_fmtdesc = false;
|
||||
|
|
@ -603,7 +604,7 @@ spa_v4l2_enum_format(struct impl *this,
|
|||
goto do_frmsize;
|
||||
|
||||
if (p->body.value.type != SPA_POD_TYPE_RECTANGLE)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
if (!(p->body.flags & SPA_POD_PROP_FLAG_UNSET)) {
|
||||
const struct spa_rectangle *values =
|
||||
|
|
@ -624,7 +625,7 @@ spa_v4l2_enum_format(struct impl *this,
|
|||
goto next_fmtdesc;
|
||||
|
||||
perror("VIDIOC_ENUM_FRAMESIZES");
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
if (filter) {
|
||||
struct spa_pod_prop *p;
|
||||
|
|
@ -713,7 +714,7 @@ spa_v4l2_enum_format(struct impl *this,
|
|||
break;
|
||||
}
|
||||
perror("VIDIOC_ENUM_FRAMEINTERVALS");
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
if (filter) {
|
||||
struct spa_pod_prop *p;
|
||||
|
|
@ -725,7 +726,7 @@ spa_v4l2_enum_format(struct impl *this,
|
|||
goto have_framerate;
|
||||
|
||||
if (p->body.value.type != SPA_POD_TYPE_FRACTION)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
range = p->body.flags & SPA_POD_PROP_RANGE_MASK;
|
||||
values = SPA_POD_BODY_CONST(&p->body.value);
|
||||
|
|
@ -793,7 +794,7 @@ spa_v4l2_enum_format(struct impl *this,
|
|||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int spa_v4l2_set_format(struct impl *this, struct spa_video_info *format, bool try_only)
|
||||
|
|
@ -906,16 +907,8 @@ static int mmap_read(struct impl *this)
|
|||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.memory = port->memtype;
|
||||
|
||||
if (xioctl(port->fd, VIDIOC_DQBUF, &buf) < 0) {
|
||||
switch (errno) {
|
||||
case EAGAIN:
|
||||
return SPA_RESULT_ERROR;
|
||||
case EIO:
|
||||
default:
|
||||
perror("VIDIOC_DQBUF");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
}
|
||||
if (xioctl(port->fd, VIDIOC_DQBUF, &buf) < 0)
|
||||
return errno;
|
||||
|
||||
port->last_ticks = (int64_t) buf.timestamp.tv_sec * SPA_USEC_PER_SEC +
|
||||
(uint64_t) buf.timestamp.tv_usec;
|
||||
|
|
@ -942,12 +935,12 @@ static int mmap_read(struct impl *this)
|
|||
|
||||
b->outstanding = true;
|
||||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_HAVE_BUFFER;
|
||||
io->status = SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
spa_log_trace(port->log, "v4l2 %p: have output %d", this, io->buffer_id);
|
||||
this->callbacks->have_output(this->callbacks_data);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void v4l2_on_fd_events(struct spa_source *source)
|
||||
|
|
@ -982,7 +975,7 @@ static int spa_v4l2_use_buffers(struct impl *this, struct spa_buffer **buffers,
|
|||
} else {
|
||||
spa_log_error(state->log, "v4l2: can't use buffers of type %s (%d)",
|
||||
spa_type_map_get_type (this->map, d[0].type), d[0].type);
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -993,12 +986,12 @@ static int spa_v4l2_use_buffers(struct impl *this, struct spa_buffer **buffers,
|
|||
|
||||
if (xioctl(state->fd, VIDIOC_REQBUFS, &reqbuf) < 0) {
|
||||
perror("VIDIOC_REQBUFS");
|
||||
return SPA_RESULT_ERROR;
|
||||
return errno;
|
||||
}
|
||||
spa_log_info(state->log, "v4l2: got %d buffers", reqbuf.count);
|
||||
if (reqbuf.count < n_buffers) {
|
||||
spa_log_error(state->log, "v4l2: can't allocate enough buffers");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (i = 0; i < reqbuf.count; i++) {
|
||||
|
|
@ -1014,7 +1007,7 @@ static int spa_v4l2_use_buffers(struct impl *this, struct spa_buffer **buffers,
|
|||
|
||||
if (buffers[i]->n_datas < 1) {
|
||||
spa_log_error(state->log, "v4l2: invalid memory on buffer %p", buffers[i]);
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
d = buffers[i]->datas;
|
||||
|
||||
|
|
@ -1033,7 +1026,7 @@ static int spa_v4l2_use_buffers(struct impl *this, struct spa_buffer **buffers,
|
|||
}
|
||||
state->n_buffers = reqbuf.count;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -1056,7 +1049,7 @@ mmap_init(struct impl *this,
|
|||
|
||||
if (xioctl(state->fd, VIDIOC_REQBUFS, &reqbuf) < 0) {
|
||||
perror("VIDIOC_REQBUFS");
|
||||
return SPA_RESULT_ERROR;
|
||||
return errno;
|
||||
}
|
||||
|
||||
spa_log_info(state->log, "v4l2: got %d buffers", reqbuf.count);
|
||||
|
|
@ -1064,7 +1057,7 @@ mmap_init(struct impl *this,
|
|||
|
||||
if (reqbuf.count < 2) {
|
||||
spa_log_error(state->log, "v4l2: can't allocate enough buffers");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (state->export_buf)
|
||||
spa_log_info(state->log, "v4l2: using EXPBUF");
|
||||
|
|
@ -1075,7 +1068,7 @@ mmap_init(struct impl *this,
|
|||
|
||||
if (buffers[i]->n_datas < 1) {
|
||||
spa_log_error(state->log, "v4l2: invalid buffer data");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
b = &state->buffers[i];
|
||||
|
|
@ -1091,7 +1084,7 @@ mmap_init(struct impl *this,
|
|||
|
||||
if (xioctl(state->fd, VIDIOC_QUERYBUF, &b->v4l2_buffer) < 0) {
|
||||
perror("VIDIOC_QUERYBUF");
|
||||
return SPA_RESULT_ERROR;
|
||||
return errno;
|
||||
}
|
||||
|
||||
d = buffers[i]->datas;
|
||||
|
|
@ -1132,17 +1125,17 @@ mmap_init(struct impl *this,
|
|||
}
|
||||
state->n_buffers = reqbuf.count;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int userptr_init(struct impl *this)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int read_init(struct impl *this)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -1156,7 +1149,7 @@ spa_v4l2_alloc_buffers(struct impl *this,
|
|||
struct port *state = &this->out_ports[0];
|
||||
|
||||
if (state->n_buffers > 0)
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EIO;
|
||||
|
||||
if (state->cap.capabilities & V4L2_CAP_STREAMING) {
|
||||
if ((res = mmap_init(this, params, n_params, buffers, n_buffers)) < 0)
|
||||
|
|
@ -1166,9 +1159,9 @@ spa_v4l2_alloc_buffers(struct impl *this,
|
|||
if ((res = read_init(this)) < 0)
|
||||
return res;
|
||||
} else
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EIO;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spa_v4l2_stream_on(struct impl *this)
|
||||
|
|
@ -1177,16 +1170,16 @@ static int spa_v4l2_stream_on(struct impl *this)
|
|||
enum v4l2_buf_type type;
|
||||
|
||||
if (state->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
if (xioctl(state->fd, VIDIOC_STREAMON, &type) < 0) {
|
||||
spa_log_error(this->log, "VIDIOC_STREAMON: %s", strerror(errno));
|
||||
return SPA_RESULT_ERROR;
|
||||
return errno;
|
||||
}
|
||||
state->started = true;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spa_v4l2_stream_off(struct impl *this)
|
||||
|
|
@ -1196,14 +1189,14 @@ static int spa_v4l2_stream_off(struct impl *this)
|
|||
int i;
|
||||
|
||||
if (!state->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
spa_v4l2_port_set_enabled(this, false);
|
||||
|
||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
if (xioctl(state->fd, VIDIOC_STREAMOFF, &type) < 0) {
|
||||
spa_log_error(this->log, "VIDIOC_STREAMOFF: %s", strerror(errno));
|
||||
return SPA_RESULT_ERROR;
|
||||
return errno;
|
||||
}
|
||||
for (i = 0; i < state->n_buffers; i++) {
|
||||
struct buffer *b;
|
||||
|
|
@ -1215,5 +1208,5 @@ static int spa_v4l2_stream_off(struct impl *this)
|
|||
}
|
||||
state->started = false;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
|
||||
extern const struct spa_handle_factory spa_v4l2_source_factory;
|
||||
|
|
@ -24,12 +26,12 @@ extern const struct spa_handle_factory spa_v4l2_monitor_factory;
|
|||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL,
|
||||
SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*factory = &spa_v4l2_source_factory;
|
||||
break;
|
||||
|
|
@ -37,7 +39,8 @@ spa_handle_factory_enum(const struct spa_handle_factory **factory,
|
|||
*factory = &spa_v4l2_monitor_factory;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
typedef enum {
|
||||
GRAY = 0,
|
||||
YELLOW,
|
||||
|
|
@ -135,21 +137,21 @@ static int drawing_data_init(DrawingData * dd, struct impl *this, char *data)
|
|||
|
||||
if ((format->media_type != this->type.media_type.video) ||
|
||||
(format->media_subtype != this->type.media_subtype.raw))
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
if (format->info.raw.format == this->type.video_format.RGB) {
|
||||
dd->draw_pixel = draw_pixel_rgb;
|
||||
} else if (format->info.raw.format == this->type.video_format.UYVY) {
|
||||
dd->draw_pixel = draw_pixel_uyvy;
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
dd->line = data;
|
||||
dd->width = size->width;
|
||||
dd->height = size->height;
|
||||
dd->stride = this->stride;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void draw_pixels(DrawingData * dd, int offset, Color color, int length)
|
||||
|
|
@ -264,8 +266,7 @@ static int draw(struct impl *this, char *data)
|
|||
|
||||
init_colors();
|
||||
|
||||
res = drawing_data_init(&dd, this, data);
|
||||
if (res != SPA_RESULT_OK)
|
||||
if ((res = drawing_data_init(&dd, this, data)) < 0)
|
||||
return res;
|
||||
|
||||
pattern = this->props.pattern;
|
||||
|
|
@ -274,7 +275,7 @@ static int draw(struct impl *this, char *data)
|
|||
else if (pattern == this->type.pattern_snow)
|
||||
draw_snow(&dd);
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,21 +17,25 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
|
||||
extern const struct spa_handle_factory spa_videotestsrc_factory;
|
||||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*factory = &spa_videotestsrc_factory;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
|
@ -160,8 +161,8 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
uint32_t offset;
|
||||
struct spa_pod *param;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -171,7 +172,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
next:
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
|
|
@ -181,7 +182,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct props *p = &this->props;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
|
|
@ -191,7 +192,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
t->pattern_snow);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -199,7 +200,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
|
|
@ -208,7 +209,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -227,9 +228,9 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
this->info.flags &= ~SPA_PORT_INFO_FLAG_LIVE;
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "draw.c"
|
||||
|
|
@ -280,7 +281,7 @@ static int make_buffer(struct impl *this)
|
|||
if (spa_list_is_empty(&this->empty)) {
|
||||
set_timer(this, false);
|
||||
spa_log_error(this->log, NAME " %p: out of buffers", this);
|
||||
return SPA_RESULT_OUT_OF_BUFFERS;
|
||||
return -EPIPE;
|
||||
}
|
||||
b = spa_list_first(&this->empty, struct buffer, link);
|
||||
spa_list_remove(&b->link);
|
||||
|
|
@ -307,7 +308,7 @@ static int make_buffer(struct impl *this)
|
|||
set_timer(this, true);
|
||||
|
||||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_HAVE_BUFFER;
|
||||
io->status = SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
return io->status;
|
||||
}
|
||||
|
|
@ -319,7 +320,7 @@ static void on_output(struct spa_source *source)
|
|||
|
||||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER)
|
||||
if (res == SPA_STATUS_HAVE_BUFFER)
|
||||
this->callbacks->have_output(this->callbacks_data);
|
||||
}
|
||||
|
||||
|
|
@ -327,8 +328,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -336,13 +337,12 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
struct timespec now;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if (this->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
if (this->props.live)
|
||||
|
|
@ -356,20 +356,19 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
set_timer(this, true);
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if (!this->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
this->started = false;
|
||||
set_timer(this, false);
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -379,14 +378,14 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -396,7 +395,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
|
|
@ -407,7 +406,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -417,23 +416,23 @@ impl_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -444,16 +443,16 @@ impl_node_port_get_info(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
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), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
|
|
@ -483,9 +482,9 @@ static int port_enum_formats(struct spa_node *node,
|
|||
&SPA_FRACTION(INT32_MAX, 1));
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
|
|
@ -499,9 +498,9 @@ static int port_get_format(struct spa_node *node,
|
|||
struct type *t = &this->type;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = spa_pod_builder_object(builder,
|
||||
t->param.idFormat, t->format,
|
||||
|
|
@ -511,7 +510,7 @@ static int port_get_format(struct spa_node *node,
|
|||
":", t->format_video.size, "R", &this->current_format.info.raw.size,
|
||||
":", t->format_video.framerate, "F", &this->current_format.info.raw.framerate);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -527,14 +526,14 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
struct spa_pod *param;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
offset = builder->offset;
|
||||
|
||||
|
|
@ -549,23 +548,23 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
struct spa_video_info_raw *raw_info = &this->current_format.info.raw;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param_buffers.Buffers,
|
||||
|
|
@ -577,7 +576,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
}
|
||||
else if (id == t->param.idMeta) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
|
|
@ -588,11 +587,11 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
break;
|
||||
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -600,7 +599,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int clear_buffers(struct impl *this)
|
||||
|
|
@ -612,7 +611,7 @@ static int clear_buffers(struct impl *this)
|
|||
this->started = false;
|
||||
set_timer(this, false);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
@ -634,17 +633,17 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (info.media_type != this->type.media_type.video &&
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (info.info.raw.format == this->type.video_format.RGB)
|
||||
this->bpp = 3;
|
||||
else if (info.info.raw.format == this->type.video_format.UYVY)
|
||||
this->bpp = 2;
|
||||
else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
this->current_format = info;
|
||||
this->have_format = true;
|
||||
|
|
@ -655,7 +654,7 @@ static int port_set_format(struct spa_node *node,
|
|||
this->stride = SPA_ROUND_UP_N(this->bpp * raw_info->size.width, 4);
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -667,18 +666,18 @@ impl_node_port_set_param(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (id == t->param.idFormat) {
|
||||
return port_set_format(node, direction, port_id, flags, param);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -691,14 +690,14 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
clear_buffers(this);
|
||||
|
||||
|
|
@ -716,13 +715,13 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
d[0].type == this->type.data.DmaBuf) && d[0].data == NULL) {
|
||||
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
|
||||
buffers[i]);
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
spa_list_append(&this->empty, &b->link);
|
||||
}
|
||||
this->n_buffers = n_buffers;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -736,16 +735,16 @@ impl_node_port_alloc_buffers(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -756,15 +755,15 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
this->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void reuse_buffer(struct impl *this, uint32_t id)
|
||||
|
|
@ -785,17 +784,16 @@ static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(port_id == 0, SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(this->n_buffers > 0, SPA_RESULT_NO_BUFFERS);
|
||||
spa_return_val_if_fail(buffer_id < this->n_buffers, SPA_RESULT_INVALID_BUFFER_ID);
|
||||
spa_return_val_if_fail(port_id == 0, -EINVAL);
|
||||
spa_return_val_if_fail(buffer_id < this->n_buffers, -EINVAL);
|
||||
|
||||
reuse_buffer(this, buffer_id);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -804,12 +802,12 @@ impl_node_port_send_command(struct spa_node *node,
|
|||
uint32_t port_id,
|
||||
const struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
|
|
@ -817,24 +815,24 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
struct impl *this;
|
||||
struct spa_port_io *io;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
io = this->io;
|
||||
spa_return_val_if_fail(io != NULL, SPA_RESULT_UNEXPECTED);
|
||||
spa_return_val_if_fail(io != NULL, -EIO);
|
||||
|
||||
if (io->status == SPA_RESULT_HAVE_BUFFER)
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
if (io->status == SPA_STATUS_HAVE_BUFFER)
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
if (io->buffer_id < this->n_buffers) {
|
||||
reuse_buffer(this, this->io->buffer_id);
|
||||
this->io->buffer_id = SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
if (!this->props.live && (io->status == SPA_RESULT_NEED_BUFFER))
|
||||
if (!this->props.live && (io->status == SPA_STATUS_NEED_BUFFER))
|
||||
return make_buffer(this);
|
||||
else
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_STATUS_OK;
|
||||
}
|
||||
|
||||
static const struct spa_dict_item node_info_items[] = {
|
||||
|
|
@ -872,13 +870,13 @@ static const struct spa_node impl_node = {
|
|||
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_clock_set_param(struct spa_clock *clock, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -890,7 +888,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
struct timespec now;
|
||||
uint64_t tnow;
|
||||
|
||||
spa_return_val_if_fail(clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(clock != NULL, -EINVAL);
|
||||
|
||||
if (rate)
|
||||
*rate = SPA_NSEC_PER_SEC;
|
||||
|
|
@ -903,7 +901,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
if (monotonic_time)
|
||||
*monotonic_time = tnow;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
|
|
@ -919,8 +917,8 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -929,16 +927,16 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
else if (interface_id == this->type.clock)
|
||||
*interface = &this->clock;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -946,7 +944,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
spa_loop_remove_source(this->data_loop, &this->timer_source);
|
||||
close(this->timer_source.fd);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -959,8 +957,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -977,7 +975,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -1006,7 +1004,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
spa_log_info(this->log, NAME " %p: initialized", this);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -1017,19 +1015,21 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[*index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_dict_item info_items[] = {
|
||||
|
|
|
|||
|
|
@ -17,20 +17,24 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
|
||||
extern const struct spa_handle_factory spa_volume_factory;
|
||||
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*factory = &spa_volume_factory;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
|
@ -147,9 +148,9 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
uint32_t offset;
|
||||
struct spa_pod *param;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -159,7 +160,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
next:
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
|
|
@ -169,7 +170,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
struct props *p = &this->props;
|
||||
|
||||
if(*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
|
|
@ -177,7 +178,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
":", t->prop_mute, "b", p->mute);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -185,7 +186,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
|
|
@ -194,7 +195,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -204,24 +205,24 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
|
||||
if (param == NULL) {
|
||||
reset_props(p);
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_volume, "?d", &p->volume,
|
||||
":", t->prop_mute, "?b", &p->mute, NULL);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -230,9 +231,9 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
this->started = false;
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -242,14 +243,14 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -259,7 +260,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
|
|
@ -270,7 +271,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -280,26 +281,26 @@ impl_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports > 0 && input_ids)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ports > 0 && output_ids)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -311,17 +312,17 @@ impl_node_port_get_info(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
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), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
*info = &port->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
|
|
@ -347,9 +348,9 @@ static int port_enum_formats(struct spa_node *node,
|
|||
":", t->format_audio.channels,"iru", 2, 2, 1, INT32_MAX);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
|
|
@ -366,9 +367,9 @@ static int port_get_format(struct spa_node *node,
|
|||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = spa_pod_builder_object(builder,
|
||||
t->param.idFormat, t->format,
|
||||
|
|
@ -378,7 +379,7 @@ static int port_get_format(struct spa_node *node,
|
|||
":", t->format_audio.rate, "i", this->current_format.info.raw.rate,
|
||||
":", t->format_audio.channels, "i", this->current_format.info.raw.channels);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -395,14 +396,14 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
struct spa_pod *param;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
|
|
@ -419,21 +420,21 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param_buffers.Buffers,
|
||||
|
|
@ -454,11 +455,11 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_meta.size, "i", sizeof(struct spa_meta_header));
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -466,7 +467,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int clear_buffers(struct impl *this, struct port *port)
|
||||
|
|
@ -476,7 +477,7 @@ static int clear_buffers(struct impl *this, struct port *port)
|
|||
port->n_buffers = 0;
|
||||
spa_list_init(&port->empty);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
@ -501,17 +502,17 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (info.media_type != this->type.media_type.audio ||
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
this->bpf = 2 * info.info.raw.channels;
|
||||
this->current_format = info;
|
||||
port->have_format = true;
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -523,18 +524,18 @@ impl_node_port_set_param(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (id == t->param.idFormat) {
|
||||
return port_set_format(node, direction, port_id, flags, param);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -548,16 +549,16 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
struct port *port;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
clear_buffers(this, port);
|
||||
|
||||
|
|
@ -578,14 +579,14 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
} else {
|
||||
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
|
||||
buffers[i]);
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!b->outstanding)
|
||||
spa_list_append(&port->empty, &b->link);
|
||||
}
|
||||
port->n_buffers = n_buffers;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -597,7 +598,7 @@ impl_node_port_alloc_buffers(struct spa_node *node,
|
|||
struct spa_buffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -609,16 +610,16 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
port = GET_PORT(this, direction, port_id);
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void recycle_buffer(struct impl *this, uint32_t id)
|
||||
|
|
@ -641,24 +642,21 @@ static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id,
|
|||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id),
|
||||
SPA_RESULT_INVALID_PORT);
|
||||
-EINVAL);
|
||||
|
||||
port = GET_OUT_PORT(this, port_id);
|
||||
|
||||
if (port->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (buffer_id >= port->n_buffers)
|
||||
return SPA_RESULT_INVALID_BUFFER_ID;
|
||||
return -EINVAL;
|
||||
|
||||
recycle_buffer(this, buffer_id);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -667,7 +665,7 @@ impl_node_port_send_command(struct spa_node *node,
|
|||
uint32_t port_id,
|
||||
const struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static struct spa_buffer *find_free_buffer(struct impl *this, struct port *port)
|
||||
|
|
@ -737,40 +735,40 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
struct port *in_port, *out_port;
|
||||
struct spa_buffer *dbuf, *sbuf;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
out_port = GET_OUT_PORT(this, 0);
|
||||
output = out_port->io;
|
||||
spa_return_val_if_fail(output != NULL, SPA_RESULT_ERROR);
|
||||
spa_return_val_if_fail(output != NULL, -EIO);
|
||||
|
||||
if (output->status == SPA_RESULT_HAVE_BUFFER)
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
if (output->status == SPA_STATUS_HAVE_BUFFER)
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
in_port = GET_IN_PORT(this, 0);
|
||||
input = in_port->io;
|
||||
spa_return_val_if_fail(input != NULL, SPA_RESULT_ERROR);
|
||||
spa_return_val_if_fail(input != NULL, -EIO);
|
||||
|
||||
if (input->buffer_id >= in_port->n_buffers)
|
||||
return SPA_RESULT_NEED_BUFFER;
|
||||
return SPA_STATUS_NEED_BUFFER;
|
||||
|
||||
if ((dbuf = find_free_buffer(this, out_port)) == NULL) {
|
||||
spa_log_error(this->log, NAME " %p: out of buffers", this);
|
||||
return SPA_RESULT_OUT_OF_BUFFERS;
|
||||
return -EPIPE;
|
||||
}
|
||||
|
||||
sbuf = in_port->buffers[input->buffer_id].outbuf;
|
||||
|
||||
input->status = SPA_RESULT_OK;
|
||||
input->status = SPA_STATUS_OK;
|
||||
|
||||
spa_log_trace(this->log, NAME " %p: do volume %d -> %d", this, sbuf->id, dbuf->id);
|
||||
do_volume(this, dbuf, sbuf);
|
||||
|
||||
output->buffer_id = dbuf->id;
|
||||
output->status = SPA_RESULT_HAVE_BUFFER;
|
||||
output->status = SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
}
|
||||
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
|
|
@ -779,16 +777,16 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
struct port *in_port, *out_port;
|
||||
struct spa_port_io *input, *output;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
out_port = GET_OUT_PORT(this, 0);
|
||||
output = out_port->io;
|
||||
spa_return_val_if_fail(output != NULL, SPA_RESULT_ERROR);
|
||||
spa_return_val_if_fail(output != NULL, -EIO);
|
||||
|
||||
if (output->status == SPA_RESULT_HAVE_BUFFER)
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
if (output->status == SPA_STATUS_HAVE_BUFFER)
|
||||
return SPA_STATUS_HAVE_BUFFER;
|
||||
|
||||
/* recycle */
|
||||
if (output->buffer_id < out_port->n_buffers) {
|
||||
|
|
@ -798,12 +796,12 @@ static int impl_node_process_output(struct spa_node *node)
|
|||
|
||||
in_port = GET_IN_PORT(this, 0);
|
||||
input = in_port->io;
|
||||
spa_return_val_if_fail(input != NULL, SPA_RESULT_ERROR);
|
||||
spa_return_val_if_fail(input != NULL, -EIO);
|
||||
|
||||
input->range = output->range;
|
||||
input->status = SPA_RESULT_NEED_BUFFER;
|
||||
input->status = SPA_STATUS_NEED_BUFFER;
|
||||
|
||||
return SPA_RESULT_NEED_BUFFER;
|
||||
return SPA_STATUS_NEED_BUFFER;
|
||||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
|
|
@ -833,22 +831,22 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -861,8 +859,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -877,7 +875,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -892,7 +890,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
spa_list_init(&this->out_ports[0].empty);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -902,19 +900,21 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[*index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_volume_factory = {
|
||||
|
|
|
|||
|
|
@ -187,20 +187,20 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
|
||||
if ((hnd = dlopen(lib, RTLD_NOW)) == NULL) {
|
||||
printf("can't load %s: %s\n", lib, dlerror());
|
||||
return SPA_RESULT_ERROR;
|
||||
return -errno;
|
||||
}
|
||||
if ((enum_func = dlsym(hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
|
||||
printf("can't find enum function\n");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -errno;
|
||||
}
|
||||
|
||||
for (i = 0;; i++) {
|
||||
for (i = 0;;) {
|
||||
const struct spa_handle_factory *factory;
|
||||
void *iface;
|
||||
|
||||
if ((res = enum_func(&factory, i)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("can't enumerate factories: %d\n", res);
|
||||
if ((res = enum_func(&factory, &i)) <= 0) {
|
||||
if (res != 0)
|
||||
printf("can't enumerate factories: %s\n", spa_strerror(res));
|
||||
break;
|
||||
}
|
||||
if (strcmp(factory->name, name))
|
||||
|
|
@ -218,9 +218,9 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
return res;
|
||||
}
|
||||
*node = iface;
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
static void on_sink_done(void *data, int seq, int res)
|
||||
|
|
@ -263,12 +263,12 @@ static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
|||
data->n_sources++;
|
||||
data->rebuild_fds = true;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_update_source(struct spa_source *source)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void do_remove_source(struct spa_source *source)
|
||||
|
|
@ -392,8 +392,8 @@ static int negotiate_formats(struct data *data)
|
|||
if ((res = spa_node_port_enum_params(data->sink,
|
||||
SPA_DIRECTION_INPUT, 0,
|
||||
data->type.param.idEnumFormat, &state,
|
||||
filter, &b)) < 0)
|
||||
return res;
|
||||
filter, &b)) <= 0)
|
||||
return -EBADF;
|
||||
|
||||
format = spa_pod_builder_deref(&b, ref);
|
||||
spa_debug_pod(&format->pod, 0);
|
||||
|
|
@ -439,7 +439,7 @@ static int negotiate_formats(struct data *data)
|
|||
1)) < 0)
|
||||
return res;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *loop(void *user_data)
|
||||
|
|
|
|||
|
|
@ -198,20 +198,20 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
|
||||
if ((hnd = dlopen(lib, RTLD_NOW)) == NULL) {
|
||||
printf("can't load %s: %s\n", lib, dlerror());
|
||||
return SPA_RESULT_ERROR;
|
||||
return -errno;
|
||||
}
|
||||
if ((enum_func = dlsym(hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
|
||||
printf("can't find enum function\n");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -errno;
|
||||
}
|
||||
|
||||
for (i = 0;; i++) {
|
||||
for (i = 0;;) {
|
||||
const struct spa_handle_factory *factory;
|
||||
void *iface;
|
||||
|
||||
if ((res = enum_func(&factory, i)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("can't enumerate factories: %d\n", res);
|
||||
if ((res = enum_func(&factory, &i)) <= 0) {
|
||||
if (res != 0)
|
||||
printf("can't enumerate factories: %s\n", spa_strerror(res));
|
||||
break;
|
||||
}
|
||||
if (strcmp(factory->name, name))
|
||||
|
|
@ -229,9 +229,9 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
return res;
|
||||
}
|
||||
*node = iface;
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
static void on_sink_done(void *data, int seq, int res)
|
||||
|
|
@ -253,26 +253,26 @@ static void on_sink_need_input(void *_data)
|
|||
int res;
|
||||
|
||||
res = spa_node_process_output(data->mix);
|
||||
if (res == SPA_RESULT_NEED_BUFFER) {
|
||||
if (data->source1_mix_io[0].status == SPA_RESULT_NEED_BUFFER) {
|
||||
if (res == SPA_STATUS_NEED_BUFFER) {
|
||||
if (data->source1_mix_io[0].status == SPA_STATUS_NEED_BUFFER) {
|
||||
res = spa_node_process_output(data->source1);
|
||||
if (res != SPA_RESULT_HAVE_BUFFER)
|
||||
if (res != SPA_STATUS_HAVE_BUFFER)
|
||||
printf("got process_output error from source1 %d\n", res);
|
||||
}
|
||||
|
||||
if (data->source2_mix_io[0].status == SPA_RESULT_NEED_BUFFER) {
|
||||
if (data->source2_mix_io[0].status == SPA_STATUS_NEED_BUFFER) {
|
||||
res = spa_node_process_output(data->source2);
|
||||
if (res != SPA_RESULT_HAVE_BUFFER)
|
||||
if (res != SPA_STATUS_HAVE_BUFFER)
|
||||
printf("got process_output error from source2 %d\n", res);
|
||||
}
|
||||
|
||||
res = spa_node_process_input(data->mix);
|
||||
if (res == SPA_RESULT_HAVE_BUFFER)
|
||||
if (res == SPA_STATUS_HAVE_BUFFER)
|
||||
goto push;
|
||||
else
|
||||
printf("got process_input error from mixer %d\n", res);
|
||||
|
||||
} else if (res == SPA_RESULT_HAVE_BUFFER) {
|
||||
} else if (res == SPA_STATUS_HAVE_BUFFER) {
|
||||
push:
|
||||
if ((res = spa_node_process_input(data->sink)) < 0)
|
||||
printf("got process_input error from sink %d\n", res);
|
||||
|
|
@ -307,12 +307,12 @@ static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
|||
data->n_sources++;
|
||||
data->rebuild_fds = true;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_update_source(struct spa_source *source)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void do_remove_source(struct spa_source *source)
|
||||
|
|
@ -474,8 +474,8 @@ static int negotiate_formats(struct data *data)
|
|||
spa_node_port_enum_params(data->sink,
|
||||
SPA_DIRECTION_INPUT, 0,
|
||||
data->type.param.idEnumFormat, &state,
|
||||
filter, &b)) < 0)
|
||||
return res;
|
||||
filter, &b)) <= 0)
|
||||
return -EBADF;
|
||||
|
||||
format = spa_pod_builder_deref(&b, ref);
|
||||
|
||||
|
|
@ -547,7 +547,7 @@ static int negotiate_formats(struct data *data)
|
|||
data->source2_buffers, 2)) < 0)
|
||||
return res;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *loop(void *user_data)
|
||||
|
|
|
|||
|
|
@ -183,21 +183,21 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
if (data->hnd == NULL) {
|
||||
if ((data->hnd = dlopen(lib, RTLD_NOW)) == NULL) {
|
||||
printf("can't load %s: %s\n", lib, dlerror());
|
||||
return SPA_RESULT_ERROR;
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
if ((enum_func = dlsym(data->hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
|
||||
printf("can't find enum function\n");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -errno;
|
||||
}
|
||||
|
||||
for (i = 0;; i++) {
|
||||
for (i = 0;;) {
|
||||
const struct spa_handle_factory *factory;
|
||||
void *iface;
|
||||
|
||||
if ((res = enum_func(&factory, i)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("can't enumerate factories: %d\n", res);
|
||||
if ((res = enum_func(&factory, &i)) <= 0) {
|
||||
if (res != 0)
|
||||
printf("can't enumerate factories: %s\n", spa_strerror(res));
|
||||
break;
|
||||
}
|
||||
if (strcmp(factory->name, name))
|
||||
|
|
@ -215,15 +215,15 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
return res;
|
||||
}
|
||||
*node = iface;
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
static void on_sink_pull(struct data *data)
|
||||
{
|
||||
spa_log_trace(data->log, "do sink pull");
|
||||
data->sink_node.state = SPA_RESULT_NEED_BUFFER;
|
||||
data->sink_node.state = SPA_STATUS_NEED_BUFFER;
|
||||
if (data->mode & MODE_DIRECT) {
|
||||
spa_node_process_output(data->source);
|
||||
spa_node_process_input(data->sink);
|
||||
|
|
@ -317,12 +317,12 @@ static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
|||
data->n_sources++;
|
||||
data->rebuild_fds = true;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_update_source(struct spa_source *source)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void do_remove_source(struct spa_source *source)
|
||||
|
|
@ -359,7 +359,7 @@ static int make_nodes(struct data *data)
|
|||
spa_node_set_callbacks(data->source, &source_callbacks, data);
|
||||
|
||||
data->source_sink_io[0] = SPA_PORT_IO_INIT;
|
||||
data->source_sink_io[0].status = SPA_RESULT_NEED_BUFFER;
|
||||
data->source_sink_io[0].status = SPA_STATUS_NEED_BUFFER;
|
||||
|
||||
spa_node_port_set_io(data->source, SPA_DIRECTION_OUTPUT, 0, &data->source_sink_io[0]);
|
||||
spa_node_port_set_io(data->sink, SPA_DIRECTION_INPUT, 0, &data->source_sink_io[0]);
|
||||
|
|
@ -421,7 +421,7 @@ static int negotiate_formats(struct data *data)
|
|||
1)) < 0)
|
||||
return res;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *loop(void *user_data)
|
||||
|
|
|
|||
|
|
@ -171,20 +171,20 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
|
||||
if ((hnd = dlopen(lib, RTLD_NOW)) == NULL) {
|
||||
printf("can't load %s: %s\n", lib, dlerror());
|
||||
return SPA_RESULT_ERROR;
|
||||
return -errno;
|
||||
}
|
||||
if ((enum_func = dlsym(hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
|
||||
printf("can't find enum function\n");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -errno;
|
||||
}
|
||||
|
||||
for (i = 0;; i++) {
|
||||
for (i = 0;;) {
|
||||
const struct spa_handle_factory *factory;
|
||||
void *iface;
|
||||
|
||||
if ((res = enum_func(&factory, i)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("can't enumerate factories: %d\n", res);
|
||||
if ((res = enum_func(&factory, &i)) <= 0) {
|
||||
if (res != 0)
|
||||
printf("can't enumerate factories: %s\n", spa_strerror(res));
|
||||
break;
|
||||
}
|
||||
if (strcmp(factory->name, name))
|
||||
|
|
@ -202,9 +202,9 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
return res;
|
||||
}
|
||||
*node = iface;
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
static void on_sink_done(void *data, int seq, int res)
|
||||
|
|
@ -223,7 +223,7 @@ static void on_sink_need_input(void *_data)
|
|||
int res;
|
||||
|
||||
res = spa_node_process_output(data->source);
|
||||
if (res != SPA_RESULT_HAVE_BUFFER)
|
||||
if (res != SPA_STATUS_HAVE_BUFFER)
|
||||
printf("got process_output error from source %d\n", res);
|
||||
|
||||
if ((res = spa_node_process_input(data->sink)) < 0)
|
||||
|
|
@ -255,12 +255,12 @@ static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
|||
data->n_sources++;
|
||||
data->rebuild_fds = true;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_update_source(struct spa_source *source)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void do_remove_source(struct spa_source *source)
|
||||
|
|
@ -338,8 +338,8 @@ static int negotiate_formats(struct data *data)
|
|||
if ((res = spa_node_port_enum_params(data->sink,
|
||||
SPA_DIRECTION_INPUT, 0,
|
||||
data->type.param.idEnumFormat, &state,
|
||||
filter, &b)) < 0)
|
||||
return res;
|
||||
filter, &b)) <= 0)
|
||||
return -EBADF;
|
||||
|
||||
format = spa_pod_builder_deref(&b, ref);
|
||||
|
||||
|
|
@ -370,7 +370,7 @@ static int negotiate_formats(struct data *data)
|
|||
1)) < 0)
|
||||
return res;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *loop(void *user_data)
|
||||
|
|
|
|||
|
|
@ -132,20 +132,20 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
|
||||
if ((hnd = dlopen(lib, RTLD_NOW)) == NULL) {
|
||||
printf("can't load %s: %s\n", lib, dlerror());
|
||||
return SPA_RESULT_ERROR;
|
||||
return -errno;
|
||||
}
|
||||
if ((enum_func = dlsym(hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
|
||||
printf("can't find enum function\n");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -errno;
|
||||
}
|
||||
|
||||
for (i = 0;; i++) {
|
||||
for (i = 0;;) {
|
||||
const struct spa_handle_factory *factory;
|
||||
void *iface;
|
||||
|
||||
if ((res = enum_func(&factory, i)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("can't enumerate factories: %d\n", res);
|
||||
if ((res = enum_func(&factory, &i)) <= 0) {
|
||||
if (res != 0)
|
||||
printf("can't enumerate factories: %s\n", spa_strerror(res));
|
||||
break;
|
||||
}
|
||||
if (strcmp(factory->name, name))
|
||||
|
|
@ -163,9 +163,9 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
return res;
|
||||
}
|
||||
*node = iface;
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
static void handle_events(struct data *data)
|
||||
|
|
@ -258,7 +258,7 @@ static void on_source_have_output(void *_data)
|
|||
SDL_RenderPresent(data->renderer);
|
||||
}
|
||||
|
||||
io->status = SPA_RESULT_NEED_BUFFER;
|
||||
io->status = SPA_STATUS_NEED_BUFFER;
|
||||
|
||||
if ((res = spa_node_process_output(data->source)) < 0)
|
||||
printf("got pull error %d\n", res);
|
||||
|
|
@ -279,12 +279,12 @@ static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
|||
data->n_sources++;
|
||||
data->rebuild_fds = true;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_update_source(struct spa_source *source)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void do_remove_source(struct spa_source *source)
|
||||
|
|
@ -342,11 +342,11 @@ static int alloc_buffers(struct data *data)
|
|||
SDL_TEXTUREACCESS_STREAMING, 320, 240);
|
||||
if (!texture) {
|
||||
printf("can't create texture: %s\n", SDL_GetError());
|
||||
return SPA_RESULT_ERROR;
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (SDL_LockTexture(texture, NULL, &ptr, &stride) < 0) {
|
||||
fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError());
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
b->buffer.id = i;
|
||||
|
|
@ -404,8 +404,8 @@ static int negotiate_formats(struct data *data)
|
|||
#if 0
|
||||
void *state = NULL;
|
||||
|
||||
if ((res = spa_node_port_enum_formats(data->source, 0, &format, NULL, &state)) < 0)
|
||||
return res;
|
||||
if ((res = spa_node_port_enum_formats(data->source, 0, &format, NULL, &state)) <= 0)
|
||||
return -EBADF;
|
||||
#else
|
||||
|
||||
format = spa_pod_builder_object(&b,
|
||||
|
|
@ -448,7 +448,7 @@ static int negotiate_formats(struct data *data)
|
|||
}
|
||||
data->n_buffers = n_buffers;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *loop(void *user_data)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <error.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -69,9 +70,9 @@ inspect_node_params(struct data *data, struct spa_node *node)
|
|||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
if ((res = spa_node_enum_params(node,
|
||||
data->type.param.idList, &idx1,
|
||||
NULL, &b)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("enum_params error %d\n", res);
|
||||
NULL, &b)) <= 0) {
|
||||
if (res != 0)
|
||||
error(0, -res, "enum_params");
|
||||
break;
|
||||
}
|
||||
param = spa_pod_builder_deref(&b, 0);
|
||||
|
|
@ -87,9 +88,9 @@ inspect_node_params(struct data *data, struct spa_node *node)
|
|||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
if ((res = spa_node_enum_params(node,
|
||||
id, &idx2,
|
||||
NULL, &b)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("enum_params %id error %d\n", id, res);
|
||||
NULL, &b)) <= 0) {
|
||||
if (res != 0)
|
||||
error(0, -res, "enum_params %d", id);
|
||||
break;
|
||||
}
|
||||
param = spa_pod_builder_deref(&b, 0);
|
||||
|
|
@ -115,9 +116,9 @@ inspect_port_params(struct data *data, struct spa_node *node,
|
|||
if ((res = spa_node_port_enum_params(node,
|
||||
direction, port_id,
|
||||
data->type.param.idList, &idx1,
|
||||
NULL, &b)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("port_enum_params error %d\n", res);
|
||||
NULL, &b)) <= 0) {
|
||||
if (res != 0)
|
||||
error(0, -res, "port_enum_params");
|
||||
break;
|
||||
}
|
||||
param = spa_pod_builder_deref(&b, 0);
|
||||
|
|
@ -133,9 +134,9 @@ inspect_port_params(struct data *data, struct spa_node *node,
|
|||
if ((res = spa_node_port_enum_params(node,
|
||||
direction, port_id,
|
||||
id, &idx2,
|
||||
NULL, &b)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("port_enum_params error %d\n", res);
|
||||
NULL, &b)) <= 0) {
|
||||
if (res != 0)
|
||||
error(0, -res, "port_enum_params");
|
||||
break;
|
||||
}
|
||||
param = spa_pod_builder_deref(&b, 0);
|
||||
|
|
@ -191,7 +192,7 @@ static void inspect_factory(struct data *data, const struct spa_handle_factory *
|
|||
int res;
|
||||
struct spa_handle *handle;
|
||||
void *interface;
|
||||
uint32_t index = 0;
|
||||
uint32_t index;
|
||||
|
||||
printf("factory name:\t\t'%s'\n", factory->name);
|
||||
printf("factory info:\n");
|
||||
|
|
@ -209,17 +210,16 @@ static void inspect_factory(struct data *data, const struct spa_handle_factory *
|
|||
|
||||
printf("factory interfaces:\n");
|
||||
|
||||
while (true) {
|
||||
for (index = 0;;) {
|
||||
const struct spa_interface_info *info;
|
||||
uint32_t interface_id;
|
||||
|
||||
if ((res = spa_handle_factory_enum_interface_info(factory, &info, index)) < 0) {
|
||||
if (res == SPA_RESULT_ENUM_END)
|
||||
if ((res = spa_handle_factory_enum_interface_info(factory, &info, &index)) <= 0) {
|
||||
if (res == 0)
|
||||
break;
|
||||
else
|
||||
printf("can't enumerate interfaces: %d\n", res);
|
||||
error(0, -res, "spa_handle_factory_enum_interface_info");
|
||||
}
|
||||
index++;
|
||||
printf(" interface: '%s'\n", info->type);
|
||||
|
||||
interface_id = spa_type_map_get_id(data->map, info->type);
|
||||
|
|
@ -238,12 +238,12 @@ static void inspect_factory(struct data *data, const struct spa_handle_factory *
|
|||
|
||||
static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_update_source(struct spa_source *source)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void do_remove_source(struct spa_source *source)
|
||||
|
|
@ -256,7 +256,7 @@ int main(int argc, char *argv[])
|
|||
int res;
|
||||
void *handle;
|
||||
spa_handle_factory_enum_func_t enum_func;
|
||||
uint32_t index = 0;
|
||||
uint32_t index;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("usage: %s <plugin.so>\n", argv[0]);
|
||||
|
|
@ -296,16 +296,15 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
for (index = 0;;) {
|
||||
const struct spa_handle_factory *factory;
|
||||
|
||||
if ((res = enum_func(&factory, index)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("can't enumerate factories: %d\n", res);
|
||||
if ((res = enum_func(&factory, &index)) <= 0) {
|
||||
if (res != 0)
|
||||
error(0, -res, "enum_func");
|
||||
break;
|
||||
}
|
||||
inspect_factory(&data, factory);
|
||||
index++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -87,12 +87,12 @@ static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
|||
data->n_sources++;
|
||||
data->rebuild_fds = true;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 9;
|
||||
}
|
||||
|
||||
static int do_update_source(struct spa_source *source)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
return 9;
|
||||
}
|
||||
|
||||
static void do_remove_source(struct spa_source *source)
|
||||
|
|
@ -112,12 +112,12 @@ static void handle_monitor(struct data *data, struct spa_monitor *monitor)
|
|||
if (monitor->info)
|
||||
spa_debug_dict(monitor->info);
|
||||
|
||||
for (index = 0;; index++) {
|
||||
for (index = 0;;) {
|
||||
struct spa_monitor_item *item;
|
||||
|
||||
if ((res = spa_monitor_enum_items(monitor, &item, index)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
printf("spa_monitor_enum_items: got error %d\n", res);
|
||||
if ((res = spa_monitor_enum_items(monitor, &item, &index)) <= 0) {
|
||||
if (res != 0)
|
||||
printf("spa_monitor_enum_items: %s\n", spa_strerror(res));
|
||||
break;
|
||||
}
|
||||
inspect_item(data, item);
|
||||
|
|
@ -198,22 +198,22 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
for (fidx = 0;; fidx++) {
|
||||
for (fidx = 0;;) {
|
||||
const struct spa_handle_factory *factory;
|
||||
uint32_t iidx;
|
||||
|
||||
if ((res = enum_func(&factory, fidx)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
if ((res = enum_func(&factory, &fidx)) <= 0) {
|
||||
if (res != 0)
|
||||
printf("can't enumerate factories: %d\n", res);
|
||||
break;
|
||||
}
|
||||
|
||||
for (iidx = 0;; iidx++) {
|
||||
for (iidx = 0;;) {
|
||||
const struct spa_interface_info *info;
|
||||
|
||||
if ((res =
|
||||
spa_handle_factory_enum_interface_info(factory, &info, iidx)) < 0) {
|
||||
if (res != SPA_RESULT_ENUM_END)
|
||||
spa_handle_factory_enum_interface_info(factory, &info, &iidx)) <= 0) {
|
||||
if (res != 0)
|
||||
printf("can't enumerate interfaces: %d\n", res);
|
||||
break;
|
||||
}
|
||||
|
|
@ -226,14 +226,14 @@ int main(int argc, char *argv[])
|
|||
if ((res =
|
||||
spa_handle_factory_init(factory, handle, NULL, data.support,
|
||||
data.n_support)) < 0) {
|
||||
printf("can't make factory instance: %d\n", res);
|
||||
printf("can't make factory instance: %s\n", strerror(res));
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((res =
|
||||
spa_handle_get_interface(handle, data.type.monitor.Monitor,
|
||||
&interface)) < 0) {
|
||||
printf("can't get interface: %d\n", res);
|
||||
printf("can't get interface: %s\n", strerror(res));
|
||||
continue;
|
||||
}
|
||||
handle_monitor(&data, interface);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue