diff --git a/spa/include/spa/clock/clock.h b/spa/include/spa/clock/clock.h index e08f89eb5..ceefd0ffd 100644 --- a/spa/include/spa/clock/clock.h +++ b/spa/include/spa/clock/clock.h @@ -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, diff --git a/spa/include/spa/graph/graph-scheduler1.h b/spa/include/spa/graph/graph-scheduler1.h index 82bea6043..8f3f62174 100644 --- a/spa/include/spa/graph/graph-scheduler1.h +++ b/spa/include/spa/graph/graph-scheduler1.h @@ -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 = { diff --git a/spa/include/spa/graph/graph-scheduler2.h b/spa/include/spa/graph/graph-scheduler2.h index e59cfd8f5..a1e10cb6f 100644 --- a/spa/include/spa/graph/graph-scheduler2.h +++ b/spa/include/spa/graph/graph-scheduler2.h @@ -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) diff --git a/spa/include/spa/graph/graph-scheduler3.h b/spa/include/spa/graph/graph-scheduler3.h index a4e3c97a2..84dda6a8d 100644 --- a/spa/include/spa/graph/graph-scheduler3.h +++ b/spa/include/spa/graph/graph-scheduler3.h @@ -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 = { diff --git a/spa/include/spa/graph/graph-scheduler4.h b/spa/include/spa/graph/graph-scheduler4.h index bc049f5fa..f245c342e 100644 --- a/spa/include/spa/graph/graph-scheduler4.h +++ b/spa/include/spa/graph/graph-scheduler4.h @@ -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 = { diff --git a/spa/include/spa/graph/graph-scheduler5.h b/spa/include/spa/graph/graph-scheduler5.h index 27e1d070c..6109cc640 100644 --- a/spa/include/spa/graph/graph-scheduler5.h +++ b/spa/include/spa/graph/graph-scheduler5.h @@ -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 = { diff --git a/spa/include/spa/graph/graph-scheduler6.h b/spa/include/spa/graph/graph-scheduler6.h index cbb9fa029..e40bde173 100644 --- a/spa/include/spa/graph/graph-scheduler6.h +++ b/spa/include/spa/graph/graph-scheduler6.h @@ -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 = { diff --git a/spa/include/spa/graph/graph.h b/spa/include/spa/graph/graph.h index 811566058..2efccff85 100644 --- a/spa/include/spa/graph/graph.h +++ b/spa/include/spa/graph/graph.h @@ -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); diff --git a/spa/include/spa/monitor/monitor.h b/spa/include/spa/monitor/monitor.h index 7e86bd3c2..51f32c969 100644 --- a/spa/include/spa/monitor/monitor.h +++ b/spa/include/spa/monitor/monitor.h @@ -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); }; diff --git a/spa/include/spa/node/node.h b/spa/include/spa/node/node.h index e97c2e9f6..33c47abb1 100644 --- a/spa/include/spa/node/node.h +++ b/spa/include/spa/node/node.h @@ -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 diff --git a/spa/include/spa/pod/builder.h b/spa/include/spa/pod/builder.h index 2c307f3b4..d013598b0 100644 --- a/spa/include/spa/pod/builder.h +++ b/spa/include/spa/pod/builder.h @@ -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) { diff --git a/spa/include/spa/pod/iter.h b/spa/include/spa/pod/iter.h index e0378e00a..5211ce0b0 100644 --- a/spa/include/spa/pod/iter.h +++ b/spa/include/spa/pod/iter.h @@ -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 diff --git a/spa/include/spa/pod/parser.h b/spa/include/spa/pod/parser.h index 0a4ea662e..e36da81c0 100644 --- a/spa/include/spa/pod/parser.h +++ b/spa/include/spa/pod/parser.h @@ -24,6 +24,7 @@ extern "C" { #endif +#include #include #include @@ -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: diff --git a/spa/include/spa/support/plugin.h b/spa/include/spa/support/plugin.h index d5afbf722..82f3ee07f 100644 --- a/spa/include/spa/support/plugin.h +++ b/spa/include/spa/support/plugin.h @@ -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); diff --git a/spa/include/spa/utils/defs.h b/spa/include/spa/utils/defs.h index 5ef0bd6d6..ef64a69b4 100644 --- a/spa/include/spa/utils/defs.h +++ b/spa/include/spa/utils/defs.h @@ -30,47 +30,6 @@ extern "C" { #include #include -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 diff --git a/spa/lib/debug.c b/spa/lib/debug.c index 4c5065a74..056d1937c 100644 --- a/spa/lib/debug.c +++ b/spa/lib/debug.c @@ -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; } diff --git a/spa/lib/pod.c b/spa/lib/pod.c index 3bbce5d74..21d41d672 100644 --- a/spa/lib/pod.c +++ b/spa/lib/pod.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -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)); } diff --git a/spa/plugins/alsa/alsa-monitor.c b/spa/plugins/alsa/alsa-monitor.c index 7ca054c24..98628b28b 100644 --- a/spa/plugins/alsa/alsa-monitor.c +++ b/spa/plugins/alsa/alsa-monitor.c @@ -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 = { diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 3f3522b4b..b49ccd668 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -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[] = { diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index e7029ee05..b90795f9a 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -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[] = { diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c index c78f19174..938c075d0 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -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; } diff --git a/spa/plugins/alsa/alsa.c b/spa/plugins/alsa/alsa.c index 723c0eb83..41f7a2014 100644 --- a/spa/plugins/alsa/alsa.c +++ b/spa/plugins/alsa/alsa.c @@ -17,17 +17,20 @@ * Boston, MA 02110-1301, USA. */ +#include + #include 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; } diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index 4391bbc49..f3f744768 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include @@ -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 = { diff --git a/spa/plugins/audiomixer/plugin.c b/spa/plugins/audiomixer/plugin.c index 3b93d4c90..8735390e7 100644 --- a/spa/plugins/audiomixer/plugin.c +++ b/spa/plugins/audiomixer/plugin.c @@ -17,21 +17,25 @@ * Boston, MA 02110-1301, USA. */ +#include + #include 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; } diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index 91c79b352..9eb11ef41 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -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[] = { diff --git a/spa/plugins/audiotestsrc/plugin.c b/spa/plugins/audiotestsrc/plugin.c index aec67a7ef..b2029a19b 100644 --- a/spa/plugins/audiotestsrc/plugin.c +++ b/spa/plugins/audiotestsrc/plugin.c @@ -17,21 +17,25 @@ * Boston, MA 02110-1301, USA. */ +#include + #include 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; } diff --git a/spa/plugins/ffmpeg/ffmpeg-dec.c b/spa/plugins/ffmpeg/ffmpeg-dec.c index b507d727e..d4687d159 100644 --- a/spa/plugins/ffmpeg/ffmpeg-dec.c +++ b/spa/plugins/ffmpeg/ffmpeg-dec.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -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; } diff --git a/spa/plugins/ffmpeg/ffmpeg-enc.c b/spa/plugins/ffmpeg/ffmpeg-enc.c index 865eb0ce1..db37fbac8 100644 --- a/spa/plugins/ffmpeg/ffmpeg-enc.c +++ b/spa/plugins/ffmpeg/ffmpeg-enc.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -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; } diff --git a/spa/plugins/ffmpeg/ffmpeg.c b/spa/plugins/ffmpeg/ffmpeg.c index 6f8391ce3..e9ff12197 100644 --- a/spa/plugins/ffmpeg/ffmpeg.c +++ b/spa/plugins/ffmpeg/ffmpeg.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include @@ -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; } diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index 268e31b3d..5ea27cd72 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -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 = { diff --git a/spa/plugins/support/loop.c b/spa/plugins/support/loop.c index ea04aae03..f4b42d5a0 100644 --- a/spa/plugins/support/loop.c +++ b/spa/plugins/support/loop.c @@ -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 = { diff --git a/spa/plugins/support/mapper.c b/spa/plugins/support/mapper.c index 315283a6f..74ab6ad39 100644 --- a/spa/plugins/support/mapper.c +++ b/spa/plugins/support/mapper.c @@ -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 = { diff --git a/spa/plugins/support/plugin.c b/spa/plugins/support/plugin.c index 2b61b988b..ad360b5ae 100644 --- a/spa/plugins/support/plugin.c +++ b/spa/plugins/support/plugin.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include @@ -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; } diff --git a/spa/plugins/test/fakesink.c b/spa/plugins/test/fakesink.c index 831fe5f8d..690b1a994 100644 --- a/spa/plugins/test/fakesink.c +++ b/spa/plugins/test/fakesink.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -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 = { diff --git a/spa/plugins/test/fakesrc.c b/spa/plugins/test/fakesrc.c index c985a8442..0c4d87219 100644 --- a/spa/plugins/test/fakesrc.c +++ b/spa/plugins/test/fakesrc.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -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 = { diff --git a/spa/plugins/test/plugin.c b/spa/plugins/test/plugin.c index da99cb36c..1bddeeb0e 100644 --- a/spa/plugins/test/plugin.c +++ b/spa/plugins/test/plugin.c @@ -17,17 +17,20 @@ * Boston, MA 02110-1301, USA. */ +#include + #include 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; } diff --git a/spa/plugins/v4l2/v4l2-monitor.c b/spa/plugins/v4l2/v4l2-monitor.c index 94e57b8d9..e77fec976 100644 --- a/spa/plugins/v4l2/v4l2-monitor.c +++ b/spa/plugins/v4l2/v4l2-monitor.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -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 = { diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index ea58806e8..fc473798b 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -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 = { diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index 4d8e55946..ea9b4399f 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -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; } diff --git a/spa/plugins/v4l2/v4l2.c b/spa/plugins/v4l2/v4l2.c index 44244df84..8079965b3 100644 --- a/spa/plugins/v4l2/v4l2.c +++ b/spa/plugins/v4l2/v4l2.c @@ -17,6 +17,8 @@ * Boston, MA 02110-1301, USA. */ +#include + #include 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; } diff --git a/spa/plugins/videotestsrc/draw.c b/spa/plugins/videotestsrc/draw.c index 98f14dd50..8117dd049 100644 --- a/spa/plugins/videotestsrc/draw.c +++ b/spa/plugins/videotestsrc/draw.c @@ -17,6 +17,8 @@ * Boston, MA 02110-1301, USA. */ +#include + 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; } diff --git a/spa/plugins/videotestsrc/plugin.c b/spa/plugins/videotestsrc/plugin.c index 974fe5f53..c565bb727 100644 --- a/spa/plugins/videotestsrc/plugin.c +++ b/spa/plugins/videotestsrc/plugin.c @@ -17,21 +17,25 @@ * Boston, MA 02110-1301, USA. */ +#include + #include 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; } diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index 3a956fc22..0e32f3b36 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -18,6 +18,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -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[] = { diff --git a/spa/plugins/volume/plugin.c b/spa/plugins/volume/plugin.c index 865fdd508..488896a79 100644 --- a/spa/plugins/volume/plugin.c +++ b/spa/plugins/volume/plugin.c @@ -17,20 +17,24 @@ * Boston, MA 02110-1301, USA. */ +#include + #include 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; } diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index 1976822ba..faf97523d 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include @@ -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 = { diff --git a/spa/tests/test-graph.c b/spa/tests/test-graph.c index 689f86c0a..bd834fbdf 100644 --- a/spa/tests/test-graph.c +++ b/spa/tests/test-graph.c @@ -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) diff --git a/spa/tests/test-mixer.c b/spa/tests/test-mixer.c index cb33276f1..0dff3da2d 100644 --- a/spa/tests/test-mixer.c +++ b/spa/tests/test-mixer.c @@ -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) diff --git a/spa/tests/test-perf.c b/spa/tests/test-perf.c index 5445571ed..4ad5b3d4b 100644 --- a/spa/tests/test-perf.c +++ b/spa/tests/test-perf.c @@ -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) diff --git a/spa/tests/test-ringbuffer.c b/spa/tests/test-ringbuffer.c index 3bd7fbbad..122472b32 100644 --- a/spa/tests/test-ringbuffer.c +++ b/spa/tests/test-ringbuffer.c @@ -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) diff --git a/spa/tests/test-v4l2.c b/spa/tests/test-v4l2.c index 31d53788b..81487a875 100644 --- a/spa/tests/test-v4l2.c +++ b/spa/tests/test-v4l2.c @@ -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) diff --git a/spa/tools/spa-inspect.c b/spa/tools/spa-inspect.c index d0882d579..6e29d0594 100644 --- a/spa/tools/spa-inspect.c +++ b/spa/tools/spa-inspect.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -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 \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; diff --git a/spa/tools/spa-monitor.c b/spa/tools/spa-monitor.c index d0c2722eb..d5509c629 100644 --- a/spa/tools/spa-monitor.c +++ b/spa/tools/spa-monitor.c @@ -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); diff --git a/src/examples/export-sink.c b/src/examples/export-sink.c index 9f1d522d4..5467d1820 100644 --- a/src/examples/export-sink.c +++ b/src/examples/export-sink.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include @@ -179,7 +180,7 @@ static Uint32 id_to_sdl_format(struct data *data, uint32_t id) static int impl_send_command(struct spa_node *node, const struct spa_command *command) { - return SPA_RESULT_OK; + return 0; } static int impl_set_callbacks(struct spa_node *node, @@ -188,7 +189,7 @@ static int impl_set_callbacks(struct spa_node *node, struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); d->callbacks = callbacks; d->callbacks_data = data; - return SPA_RESULT_OK; + return 0; } static int impl_get_n_ports(struct spa_node *node, @@ -199,7 +200,7 @@ static int impl_get_n_ports(struct spa_node *node, { *n_input_ports = *max_input_ports = 1; *n_output_ports = *max_output_ports = 0; - return SPA_RESULT_OK; + return 0; } static int impl_get_port_ids(struct spa_node *node, @@ -210,7 +211,7 @@ static int impl_get_port_ids(struct spa_node *node, { if (n_input_ports > 0) input_ids[0] = 0; - return SPA_RESULT_OK; + return 0; } static int impl_port_set_io(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -218,7 +219,7 @@ static int impl_port_set_io(struct spa_node *node, enum spa_direction direction, { struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); d->io = io; - return SPA_RESULT_OK; + return 0; } static int impl_port_get_info(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -232,7 +233,7 @@ static int impl_port_get_info(struct spa_node *node, enum spa_direction directio *info = &d->port_info; - return SPA_RESULT_OK; + return 0; } static int port_enum_formats(struct spa_node *node, @@ -246,7 +247,7 @@ static int port_enum_formats(struct spa_node *node, int i, c; if (*index != 0) - return SPA_RESULT_ENUM_END; + return 0; SDL_GetRendererInfo(d->renderer, &info); @@ -287,7 +288,7 @@ static int port_enum_formats(struct spa_node *node, (*index)++; - return SPA_RESULT_OK; + return 1; } static int port_get_format(struct spa_node *node, @@ -299,7 +300,7 @@ static int port_get_format(struct spa_node *node, struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); if (*index != 0 || d->format.format == 0) - return SPA_RESULT_ENUM_END; + return 0; spa_pod_builder_object(builder, d->t->param.idFormat, d->type.format, @@ -311,7 +312,7 @@ static int port_get_format(struct spa_node *node, (*index)++; - return SPA_RESULT_OK; + return 1; } static int impl_port_enum_params(struct spa_node *node, @@ -334,7 +335,7 @@ static int impl_port_enum_params(struct spa_node *node, 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 port_enum_formats(node, direction, port_id, index, filter, builder); @@ -344,7 +345,7 @@ static int impl_port_enum_params(struct spa_node *node, } else if (id == t->param.idBuffers) { if (*index != 0) - return SPA_RESULT_ENUM_END; + return 0; spa_pod_builder_object(builder, id, t->param_buffers.Buffers, @@ -356,7 +357,7 @@ static int impl_port_enum_params(struct spa_node *node, } else if (id == t->param.idMeta) { if (*index != 0) - return SPA_RESULT_ENUM_END; + return 0; spa_pod_builder_object(builder, id, t->param_meta.Meta, @@ -364,11 +365,11 @@ static int impl_port_enum_params(struct spa_node *node, ":", t->param_meta.size, "i", sizeof(struct spa_meta_header)); } else - return SPA_RESULT_UNKNOWN_PARAM; + return -ENOENT; (*index)++; - return SPA_RESULT_OK; + return 1; } static int port_set_format(struct spa_node *node, @@ -380,7 +381,7 @@ static int port_set_format(struct spa_node *node, void *dest; if (format == NULL) - return SPA_RESULT_OK; + return 0; spa_debug_pod(&format->pod, SPA_DEBUG_FLAG_FORMAT); @@ -388,7 +389,7 @@ static int port_set_format(struct spa_node *node, sdl_format = id_to_sdl_format(d, d->format.format); if (sdl_format == SDL_PIXELFORMAT_UNKNOWN) - return SPA_RESULT_ERROR; + return -EINVAL; d->texture = SDL_CreateTexture(d->renderer, sdl_format, @@ -398,7 +399,7 @@ static int port_set_format(struct spa_node *node, SDL_LockTexture(d->texture, NULL, &dest, &d->stride); SDL_UnlockTexture(d->texture); - return SPA_RESULT_OK; + return 0; } static int impl_port_set_param(struct spa_node *node, @@ -413,7 +414,7 @@ static int impl_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 impl_port_use_buffers(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -424,7 +425,7 @@ static int impl_port_use_buffers(struct spa_node *node, enum spa_direction direc for (i = 0; i < n_buffers; i++) d->buffers[i] = buffers[i]; d->n_buffers = n_buffers; - return SPA_RESULT_OK; + return 0; } static int impl_node_process_input(struct spa_node *node) @@ -437,7 +438,7 @@ static int impl_node_process_input(struct spa_node *node) int i; uint8_t *src, *dst; - if (d->io->status != SPA_RESULT_HAVE_BUFFER) + if (d->io->status != SPA_STATUS_HAVE_BUFFER) goto done; if (d->io->buffer_id > d->n_buffers) @@ -454,11 +455,11 @@ static int impl_node_process_input(struct spa_node *node) map = NULL; sdata = buf->datas[0].data; } else - return SPA_RESULT_ERROR; + return -EINVAL; if (SDL_LockTexture(d->texture, NULL, &ddata, &dstride) < 0) { fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError()); - return SPA_RESULT_ERROR; + return -EIO; } sstride = buf->datas[0].chunk->stride; ostride = SPA_MIN(sstride, dstride); @@ -482,7 +483,7 @@ static int impl_node_process_input(struct spa_node *node) done: handle_events(d); - return d->io->status = SPA_RESULT_NEED_BUFFER; + return d->io->status = SPA_STATUS_NEED_BUFFER; } static const struct spa_node impl_node = { diff --git a/src/examples/export-source.c b/src/examples/export-source.c index 3f4cb420c..4214f825f 100644 --- a/src/examples/export-source.c +++ b/src/examples/export-source.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -96,7 +97,7 @@ struct data { static int impl_send_command(struct spa_node *node, const struct spa_command *command) { - return SPA_RESULT_OK; + return 0; } static int impl_set_callbacks(struct spa_node *node, @@ -105,7 +106,7 @@ static int impl_set_callbacks(struct spa_node *node, struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); d->callbacks = callbacks; d->callbacks_data = data; - return SPA_RESULT_OK; + return 0; } static int impl_get_n_ports(struct spa_node *node, @@ -116,7 +117,7 @@ static int impl_get_n_ports(struct spa_node *node, { *n_input_ports = *max_input_ports = 0; *n_output_ports = *max_output_ports = 1; - return SPA_RESULT_OK; + return 0; } static int impl_get_port_ids(struct spa_node *node, @@ -127,7 +128,7 @@ static int impl_get_port_ids(struct spa_node *node, { if (n_output_ports > 0) output_ids[0] = 0; - return SPA_RESULT_OK; + return 0; } static int impl_port_set_io(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -135,7 +136,7 @@ static int impl_port_set_io(struct spa_node *node, enum spa_direction direction, { struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); d->io = io; - return SPA_RESULT_OK; + return 0; } static int impl_port_get_info(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -149,7 +150,7 @@ static int impl_port_get_info(struct spa_node *node, enum spa_direction directio *info = &d->port_info; - return SPA_RESULT_OK; + return 0; } static int port_enum_formats(struct spa_node *node, @@ -161,7 +162,7 @@ static int port_enum_formats(struct spa_node *node, struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); if (*index != 0) - return SPA_RESULT_ENUM_END; + return 0; spa_pod_builder_object(builder, d->t->param.idEnumFormat, d->type.format, @@ -173,7 +174,7 @@ static int port_enum_formats(struct spa_node *node, (*index)++; - return SPA_RESULT_OK; + return 1; } static int port_get_format(struct spa_node *node, @@ -185,10 +186,10 @@ static int port_get_format(struct spa_node *node, struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); if (*index != 0) - return SPA_RESULT_ENUM_END; + return 0; if (d->format.format == 0) - return SPA_RESULT_ENUM_END; + return 0; spa_pod_builder_object(builder, d->t->param.idFormat, d->type.format, @@ -200,7 +201,7 @@ static int port_get_format(struct spa_node *node, (*index)++; - return SPA_RESULT_OK; + return 1; } static int impl_port_enum_params(struct spa_node *node, @@ -223,7 +224,7 @@ static int impl_port_enum_params(struct spa_node *node, 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 port_enum_formats(node, direction, port_id, index, filter, builder); @@ -233,7 +234,7 @@ static int impl_port_enum_params(struct spa_node *node, } else if (id == t->param.idBuffers) { if (*index > 0) - return SPA_RESULT_ENUM_END; + return 0; spa_pod_builder_object(builder, id, t->param_buffers.Buffers, @@ -264,15 +265,15 @@ static int impl_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)++; - return SPA_RESULT_OK; + return 1; } static int port_set_format(struct spa_node *node, @@ -283,18 +284,18 @@ static int port_set_format(struct spa_node *node, if (format == NULL) { d->format.format = 0; - return SPA_RESULT_OK; + return 0; } spa_debug_pod(&format->pod, SPA_DEBUG_FLAG_FORMAT); if (spa_format_audio_raw_parse(format, &d->format, &d->type.format_audio) < 0) - return SPA_RESULT_INVALID_MEDIA_TYPE; + return -EINVAL; if (d->format.format != d->type.audio_format.S16) - return SPA_RESULT_ERROR; + return -EINVAL; - return SPA_RESULT_OK; + return 0; } static int impl_port_set_param(struct spa_node *node, @@ -309,7 +310,7 @@ static int impl_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 impl_port_use_buffers(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -331,7 +332,7 @@ static int impl_port_use_buffers(struct spa_node *node, enum spa_direction direc MAP_SHARED, datas[0].fd, 0); if (b->ptr == MAP_FAILED) { pw_log_error("failed to buffer mem"); - return SPA_RESULT_ERROR; + return -errno; } b->ptr = SPA_MEMBER(b->ptr, datas[0].mapoffset, void); @@ -339,7 +340,7 @@ static int impl_port_use_buffers(struct spa_node *node, enum spa_direction direc } else { pw_log_error("invalid buffer mem"); - return SPA_RESULT_ERROR; + return -EINVAL; } b->buffer = buffers[i]; b->rb = spa_buffer_find_meta(buffers[i], d->type.meta.Ringbuffer); @@ -347,7 +348,7 @@ static int impl_port_use_buffers(struct spa_node *node, enum spa_direction direc spa_list_append(&d->empty, &b->link); } d->n_buffers = n_buffers; - return SPA_RESULT_OK; + return 0; } static inline void reuse_buffer(struct data *d, uint32_t id) @@ -360,7 +361,7 @@ static int impl_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint3 { struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); reuse_buffer(d, buffer_id); - return SPA_RESULT_OK; + return 0; } static int impl_node_process_output(struct spa_node *node) @@ -378,7 +379,7 @@ static int impl_node_process_output(struct spa_node *node) } if (spa_list_is_empty(&d->empty)) { pw_log_error("sine-source %p: out of buffers", d); - return SPA_RESULT_OUT_OF_BUFFERS; + return -EPIPE; } b = spa_list_first(&d->empty, struct buffer, link); spa_list_remove(&b->link); @@ -424,9 +425,9 @@ static int impl_node_process_output(struct spa_node *node) } io->buffer_id = b->buffer->id; - io->status = SPA_RESULT_HAVE_BUFFER; + io->status = SPA_STATUS_HAVE_BUFFER; - return SPA_RESULT_HAVE_BUFFER; + return SPA_STATUS_HAVE_BUFFER; } static const struct spa_node impl_node = { diff --git a/src/examples/local-v4l2.c b/src/examples/local-v4l2.c index 6626ca8fd..06b458194 100644 --- a/src/examples/local-v4l2.c +++ b/src/examples/local-v4l2.c @@ -175,7 +175,7 @@ static Uint32 id_to_sdl_format(struct data *data, uint32_t id) static int impl_send_command(struct spa_node *node, const struct spa_command *command) { - return SPA_RESULT_OK; + return 0; } static int impl_set_callbacks(struct spa_node *node, @@ -184,7 +184,7 @@ static int impl_set_callbacks(struct spa_node *node, struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); d->callbacks = callbacks; d->callbacks_data = data; - return SPA_RESULT_OK; + return 0; } static int impl_get_n_ports(struct spa_node *node, @@ -195,7 +195,7 @@ static int impl_get_n_ports(struct spa_node *node, { *n_input_ports = *max_input_ports = 1; *n_output_ports = *max_output_ports = 0; - return SPA_RESULT_OK; + return 0; } static int impl_get_port_ids(struct spa_node *node, @@ -206,7 +206,7 @@ static int impl_get_port_ids(struct spa_node *node, { if (n_input_ports > 0) input_ids[0] = 0; - return SPA_RESULT_OK; + return 0; } static int impl_port_set_io(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -214,7 +214,7 @@ static int impl_port_set_io(struct spa_node *node, enum spa_direction direction, { struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node); d->io = io; - return SPA_RESULT_OK; + return 0; } static int impl_port_get_info(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -228,7 +228,7 @@ static int impl_port_get_info(struct spa_node *node, enum spa_direction directio *info = &d->port_info; - return SPA_RESULT_OK; + return 0; } static int port_enum_formats(struct spa_node *node, @@ -242,7 +242,7 @@ static int port_enum_formats(struct spa_node *node, int i, c; if (*index != 0) - return SPA_RESULT_ENUM_END; + return 0; SDL_GetRendererInfo(d->renderer, &info); @@ -284,7 +284,7 @@ static int port_enum_formats(struct spa_node *node, (*index)++; - return SPA_RESULT_OK; + return 1; } static int impl_port_enum_params(struct spa_node *node, @@ -301,7 +301,7 @@ static int impl_port_enum_params(struct spa_node *node, } else if (id == t->param.idBuffers) { if (*index > 0) - return SPA_RESULT_ENUM_END; + return 0; spa_pod_builder_object(builder, id, t->param_buffers.Buffers, @@ -313,7 +313,7 @@ static int impl_port_enum_params(struct spa_node *node, } else if (id == t->param.idMeta) { if (*index > 0) - return SPA_RESULT_ENUM_END; + return 0; spa_pod_builder_object(builder, id, t->param_meta.Meta, @@ -321,10 +321,10 @@ static int impl_port_enum_params(struct spa_node *node, ":", t->param_meta.size, "i", sizeof(struct spa_meta_header)); } else - return SPA_RESULT_UNKNOWN_PARAM; + return -ENOENT; (*index)++; - return SPA_RESULT_OK; + return 1; } static int port_set_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -335,7 +335,7 @@ static int port_set_format(struct spa_node *node, enum spa_direction direction, void *dest; if (format == NULL) - return SPA_RESULT_OK; + return 0; spa_debug_pod(&format->pod, SPA_DEBUG_FLAG_FORMAT); @@ -343,7 +343,7 @@ static int port_set_format(struct spa_node *node, enum spa_direction direction, sdl_format = id_to_sdl_format(d, d->format.format); if (sdl_format == SDL_PIXELFORMAT_UNKNOWN) - return SPA_RESULT_ERROR; + return -EINVAL; d->texture = SDL_CreateTexture(d->renderer, sdl_format, @@ -353,7 +353,7 @@ static int port_set_format(struct spa_node *node, enum spa_direction direction, SDL_LockTexture(d->texture, NULL, &dest, &d->stride); SDL_UnlockTexture(d->texture); - return SPA_RESULT_OK; + return 0; } static int impl_port_set_param(struct spa_node *node, @@ -368,7 +368,7 @@ static int impl_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 impl_port_use_buffers(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -379,7 +379,7 @@ static int impl_port_use_buffers(struct spa_node *node, enum spa_direction direc for (i = 0; i < n_buffers; i++) d->buffers[i] = buffers[i]; d->n_buffers = n_buffers; - return SPA_RESULT_OK; + return 0; } static int impl_node_process_input(struct spa_node *node) @@ -403,11 +403,11 @@ static int impl_node_process_input(struct spa_node *node) map = NULL; sdata = buf->datas[0].data; } else - return SPA_RESULT_ERROR; + return -EINVAL; if (SDL_LockTexture(d->texture, NULL, &ddata, &dstride) < 0) { fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError()); - return SPA_RESULT_ERROR; + return -EIO; } sstride = buf->datas[0].chunk->stride; ostride = SPA_MIN(sstride, dstride); @@ -430,9 +430,9 @@ static int impl_node_process_input(struct spa_node *node) handle_events(d); - d->io->status = SPA_RESULT_NEED_BUFFER; + d->io->status = SPA_STATUS_NEED_BUFFER; - return SPA_RESULT_NEED_BUFFER; + return SPA_STATUS_NEED_BUFFER; } static const struct spa_node impl_node = { diff --git a/src/examples/video-play.c b/src/examples/video-play.c index 8ef3b4df7..d4e4a657a 100644 --- a/src/examples/video-play.c +++ b/src/examples/video-play.c @@ -246,7 +246,7 @@ on_stream_format_changed(void *_data, struct spa_pod_object *format) void *d; if (format == NULL) { - pw_stream_finish_format(stream, SPA_RESULT_OK, 0, NULL); + pw_stream_finish_format(stream, 0, 0, NULL); return; } @@ -254,7 +254,7 @@ on_stream_format_changed(void *_data, struct spa_pod_object *format) sdl_format = id_to_sdl_format(data, data->format.format); if (sdl_format == SDL_PIXELFORMAT_UNKNOWN) { - pw_stream_finish_format(stream, SPA_RESULT_ERROR, 0, NULL); + pw_stream_finish_format(stream, -EINVAL, 0, NULL); return; } @@ -279,7 +279,7 @@ on_stream_format_changed(void *_data, struct spa_pod_object *format) ":", t->param_meta.type, "I", t->meta.Header, ":", t->param_meta.size, "i", sizeof(struct spa_meta_header)); - pw_stream_finish_format(stream, SPA_RESULT_OK, 2, params); + pw_stream_finish_format(stream, 0, 2, params); } static const struct pw_stream_events stream_events = { diff --git a/src/examples/video-src.c b/src/examples/video-src.c index 90340a453..231051d63 100644 --- a/src/examples/video-src.c +++ b/src/examples/video-src.c @@ -176,7 +176,7 @@ on_stream_format_changed(void *_data, struct spa_pod_object *format) struct spa_pod_object *params[2]; if (format == NULL) { - pw_stream_finish_format(stream, SPA_RESULT_OK, 0, NULL); + pw_stream_finish_format(stream, 0, 0, NULL); return; } spa_format_video_raw_parse(format, &data->format, &data->type.format_video); @@ -196,7 +196,7 @@ on_stream_format_changed(void *_data, struct spa_pod_object *format) ":", t->param_meta.type, "I", t->meta.Header, ":", t->param_meta.size, "i", sizeof(struct spa_meta_header)); - pw_stream_finish_format(stream, SPA_RESULT_OK, 2, params); + pw_stream_finish_format(stream, 0, 2, params); } static const struct pw_stream_events stream_events = { diff --git a/src/gst/gstpipewiredeviceprovider.c b/src/gst/gstpipewiredeviceprovider.c index 336dcc097..a6c2989f6 100644 --- a/src/gst/gstpipewiredeviceprovider.c +++ b/src/gst/gstpipewiredeviceprovider.c @@ -525,7 +525,7 @@ gst_pipewire_device_provider_start (GstDeviceProvider * provider) } self->type = pw_core_get_type (self->core); - if (pw_thread_loop_start (self->main_loop) != SPA_RESULT_OK) { + if (pw_thread_loop_start (self->main_loop) < 0) { GST_ERROR_OBJECT (self, "Could not start PipeWire mainloop"); goto failed_start; } diff --git a/src/gst/gstpipewiresink.c b/src/gst/gstpipewiresink.c index ebf4e21cf..0081c3d49 100644 --- a/src/gst/gstpipewiresink.c +++ b/src/gst/gstpipewiresink.c @@ -265,7 +265,7 @@ pool_activated (GstPipeWirePool *pool, GstPipeWireSink *sink) ":", t->param_meta.ringbufferAlign, "i", 16); pw_thread_loop_lock (sink->main_loop); - pw_stream_finish_format (sink->stream, SPA_RESULT_OK, 2, port_params); + pw_stream_finish_format (sink->stream, 0, 2, port_params); pw_thread_loop_unlock (sink->main_loop); } @@ -803,7 +803,7 @@ gst_pipewire_sink_open (GstPipeWireSink * pwsink) { const char *error = NULL; - if (pw_thread_loop_start (pwsink->main_loop) != SPA_RESULT_OK) + if (pw_thread_loop_start (pwsink->main_loop) < 0) goto mainloop_error; pw_thread_loop_lock (pwsink->main_loop); diff --git a/src/gst/gstpipewiresrc.c b/src/gst/gstpipewiresrc.c index 8846c6aa1..6835d60de 100644 --- a/src/gst/gstpipewiresrc.c +++ b/src/gst/gstpipewiresrc.c @@ -736,7 +736,7 @@ on_format_changed (void *data, if (format == NULL) { GST_DEBUG_OBJECT (pwsrc, "clear format"); - pw_stream_finish_format (pwsrc->stream, SPA_RESULT_OK, 0, NULL); + pw_stream_finish_format (pwsrc->stream, 0, 0, NULL); return; } @@ -764,10 +764,10 @@ on_format_changed (void *data, ":", t->param_meta.size, "i", sizeof (struct spa_meta_header)); GST_DEBUG_OBJECT (pwsrc, "doing finish format"); - pw_stream_finish_format (pwsrc->stream, SPA_RESULT_OK, 2, params); + pw_stream_finish_format (pwsrc->stream, 0, 2, params); } else { GST_WARNING_OBJECT (pwsrc, "finish format with error"); - pw_stream_finish_format (pwsrc->stream, SPA_RESULT_INVALID_MEDIA_TYPE, 0, NULL); + pw_stream_finish_format (pwsrc->stream, -EINVAL, 0, NULL); } } @@ -1021,7 +1021,7 @@ gst_pipewire_src_open (GstPipeWireSrc * pwsrc) struct pw_properties *props; const char *error = NULL; - if (pw_thread_loop_start (pwsrc->main_loop) != SPA_RESULT_OK) + if (pw_thread_loop_start (pwsrc->main_loop) < 0) goto mainloop_failed; pw_thread_loop_lock (pwsrc->main_loop); diff --git a/src/modules/module-autolink.c b/src/modules/module-autolink.c index 820f58412..66be909de 100644 --- a/src/modules/module-autolink.c +++ b/src/modules/module-autolink.c @@ -124,7 +124,7 @@ link_state_changed(void *data, enum pw_link_state old, enum pw_link_state state, pw_log_debug("module %p: link %p: state error: %s", impl, link, error); if (owner) - pw_resource_error(pw_client_get_core_resource(owner), SPA_RESULT_ERROR, error); + pw_resource_error(pw_client_get_core_resource(owner), -ENODEV, error); break; } @@ -218,7 +218,7 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod struct pw_global *global = pw_node_get_global(info->node); struct pw_client *owner = pw_global_get_owner(global); if (owner) - pw_resource_error(pw_client_get_core_resource(owner), SPA_RESULT_ERROR, error); + pw_resource_error(pw_client_get_core_resource(owner), -EINVAL, error); } free(error); return; diff --git a/src/modules/module-client-node.c b/src/modules/module-client-node.c index 5522f16dc..6d4ea11d2 100644 --- a/src/modules/module-client-node.c +++ b/src/modules/module-client-node.c @@ -67,11 +67,11 @@ static void *create_object(void *_data, no_resource: pw_log_error("client-node needs a resource"); - pw_resource_error(resource, SPA_RESULT_INVALID_ARGUMENTS, "no resource"); + pw_resource_error(resource, -EINVAL, "no resource"); goto done; no_mem: pw_log_error("can't create node"); - pw_resource_error(resource, SPA_RESULT_NO_MEMORY, "no memory"); + pw_resource_error(resource, -ENOMEM, "no memory"); goto done; done: if (properties) diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index e9ed602d9..021ce5ba9 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -147,7 +147,7 @@ static int clear_buffers(struct proxy *this, struct proxy_port *port) spa_log_info(this->log, "proxy %p: clear buffers", this); port->n_buffers = 0; } - return SPA_RESULT_OK; + return 0; } static int spa_proxy_node_enum_params(struct spa_node *node, @@ -158,9 +158,9 @@ static int spa_proxy_node_enum_params(struct spa_node *node, struct proxy *this; 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 proxy, node); @@ -170,19 +170,19 @@ static int spa_proxy_node_enum_params(struct spa_node *node, struct spa_pod_object *param; if (*index >= this->n_params) - return SPA_RESULT_ENUM_END; + return 0; param = this->params[(*index)++]; if (param->body.id != id) continue; - if (spa_pod_filter(builder, ¶m->pod, &filter->pod) == SPA_RESULT_OK) + if (spa_pod_filter(builder, ¶m->pod, &filter->pod) == 0) break; spa_pod_builder_reset(builder, offset); } - return SPA_RESULT_OK; + return 1; } static int spa_proxy_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags, @@ -191,12 +191,12 @@ static int spa_proxy_node_set_param(struct spa_node *node, uint32_t id, uint32_t struct proxy *this; if (node == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); if (this->resource == NULL) - return SPA_RESULT_OK; + return 0; pw_client_node_resource_set_param(this->resource, this->seq, id, flags, param); @@ -214,16 +214,16 @@ static inline void do_flush(struct proxy *this) static int spa_proxy_node_send_command(struct spa_node *node, const struct spa_command *command) { struct proxy *this; - int res = SPA_RESULT_OK; + int res = 0; struct pw_type *t; if (node == NULL || command == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); if (this->resource == NULL) - return SPA_RESULT_OK; + return 0; t = this->impl->t; @@ -245,13 +245,13 @@ spa_proxy_node_set_callbacks(struct spa_node *node, struct proxy *this; if (node == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); this->callbacks = callbacks; this->callbacks_data = data; - return SPA_RESULT_OK; + return 0; } static int @@ -264,7 +264,7 @@ spa_proxy_node_get_n_ports(struct spa_node *node, struct proxy *this; if (node == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); @@ -277,7 +277,7 @@ spa_proxy_node_get_n_ports(struct spa_node *node, if (max_output_ports) *max_output_ports = this->max_outputs == 0 ? this->n_outputs : this->max_outputs; - return SPA_RESULT_OK; + return 0; } static int @@ -291,7 +291,7 @@ spa_proxy_node_get_port_ids(struct spa_node *node, int c, i; if (node == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); @@ -307,7 +307,7 @@ spa_proxy_node_get_port_ids(struct spa_node *node, output_ids[c++] = i; } } - return SPA_RESULT_OK; + return 0; } static void @@ -394,17 +394,17 @@ spa_proxy_node_add_port(struct spa_node *node, enum spa_direction direction, uin struct proxy_port *port; if (node == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); if (!CHECK_FREE_PORT(this, direction, port_id)) - return SPA_RESULT_INVALID_PORT; + return -EINVAL; port = GET_PORT(this, direction, port_id); clear_port(this, port, direction, port_id); - return SPA_RESULT_OK; + return 0; } static int @@ -413,16 +413,16 @@ spa_proxy_node_remove_port(struct spa_node *node, enum spa_direction direction, struct proxy *this; if (node == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); if (!CHECK_PORT(this, direction, port_id)) - return SPA_RESULT_INVALID_PORT; + return -EINVAL; do_uninit_port(this, direction, port_id); - return SPA_RESULT_OK; + return 0; } static int @@ -434,17 +434,17 @@ spa_proxy_node_port_get_info(struct spa_node *node, struct proxy_port *port; if (node == NULL || info == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); if (!CHECK_PORT(this, direction, port_id)) - return SPA_RESULT_INVALID_PORT; + return -EINVAL; port = GET_PORT(this, direction, port_id); *info = &port->info; - return SPA_RESULT_OK; + return 0; } static int @@ -458,13 +458,13 @@ spa_proxy_node_port_enum_params(struct spa_node *node, struct proxy_port *port; 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 proxy, 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); @@ -473,19 +473,19 @@ spa_proxy_node_port_enum_params(struct spa_node *node, struct spa_pod_object *param; if (*index >= port->n_params) - return SPA_RESULT_ENUM_END; + return 0; param = port->params[(*index)++]; if (param->body.id != id) continue; - if (spa_pod_filter(builder, ¶m->pod, &filter->pod) == SPA_RESULT_OK) + if (spa_pod_filter(builder, ¶m->pod, &filter->pod) == 0) break; spa_pod_builder_reset(builder, offset); } - return SPA_RESULT_OK; + return 1; } static int @@ -497,15 +497,15 @@ spa_proxy_node_port_set_param(struct spa_node *node, struct proxy *this; if (node == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); if (!CHECK_PORT(this, direction, port_id)) - return SPA_RESULT_INVALID_PORT; + return -EINVAL; if (this->resource == NULL) - return SPA_RESULT_OK; + return 0; pw_client_node_resource_port_set_param(this->resource, this->seq, @@ -524,17 +524,17 @@ spa_proxy_node_port_set_io(struct spa_node *node, struct proxy_port *port; if (node == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); if (!CHECK_PORT(this, direction, port_id)) - return SPA_RESULT_INVALID_PORT; + return -EINVAL; port = GET_PORT(this, direction, port_id); port->io = io; - return SPA_RESULT_OK; + return 0; } static int @@ -560,12 +560,12 @@ spa_proxy_node_port_use_buffers(struct spa_node *node, t = impl->t; if (!CHECK_PORT(this, direction, port_id)) - return SPA_RESULT_INVALID_PORT; + return -EINVAL; port = GET_PORT(this, direction, port_id); if (!port->have_format) - return SPA_RESULT_NO_FORMAT; + return -EIO; clear_buffers(this, port); @@ -578,7 +578,7 @@ spa_proxy_node_port_use_buffers(struct spa_node *node, port->n_buffers = n_buffers; if (this->resource == NULL) - return SPA_RESULT_OK; + return 0; n_mem = 0; for (i = 0; i < n_buffers; i++) { @@ -587,7 +587,7 @@ spa_proxy_node_port_use_buffers(struct spa_node *node, msh = spa_buffer_find_meta(buffers[i], t->meta.Shared); if (msh == NULL) { spa_log_error(this->log, "missing shared metadata on buffer %d", i); - return SPA_RESULT_ERROR; + return -EINVAL; } b->outbuf = buffers[i]; @@ -660,19 +660,19 @@ spa_proxy_node_port_alloc_buffers(struct spa_node *node, struct proxy_port *port; if (node == NULL || buffers == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); if (!CHECK_PORT(this, direction, port_id)) - return SPA_RESULT_INVALID_PORT; + return -EINVAL; port = GET_PORT(this, direction, port_id); if (!port->have_format) - return SPA_RESULT_NO_FORMAT; + return -EIO; - return SPA_RESULT_NOT_IMPLEMENTED; + return -ENOTSUP; } static int @@ -685,14 +685,14 @@ spa_proxy_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32 impl = this->impl; if (!CHECK_OUT_PORT(this, SPA_DIRECTION_OUTPUT, port_id)) - return SPA_RESULT_INVALID_PORT; + return -EINVAL; spa_log_trace(this->log, "reuse buffer %d", buffer_id); pw_client_node_transport_add_message(impl->transport, (struct pw_client_node_message *) &PW_CLIENT_NODE_MESSAGE_REUSE_BUFFER_INIT(port_id, buffer_id)); - return SPA_RESULT_OK; + return 0; } static int @@ -703,12 +703,12 @@ spa_proxy_node_port_send_command(struct spa_node *node, struct proxy *this; if (node == NULL || command == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; this = SPA_CONTAINER_OF(node, struct proxy, node); spa_log_warn(this->log, "unhandled command %d", SPA_COMMAND_TYPE(command)); - return SPA_RESULT_NOT_IMPLEMENTED; + return -ENOTSUP; } static int spa_proxy_node_process_input(struct spa_node *node) @@ -724,8 +724,8 @@ static int spa_proxy_node_process_input(struct spa_node *node) /* the client is not ready to receive our buffers, recycle them */ pw_log_trace("node not ready, recycle buffers"); spa_list_for_each(p, &n->ports[SPA_DIRECTION_INPUT], link) - p->io->status = SPA_RESULT_NEED_BUFFER; - res = SPA_RESULT_NEED_BUFFER; + p->io->status = SPA_STATUS_NEED_BUFFER; + res = SPA_STATUS_NEED_BUFFER; } else { spa_list_for_each(p, &n->ports[SPA_DIRECTION_INPUT], link) { @@ -743,7 +743,7 @@ static int spa_proxy_node_process_input(struct spa_node *node) do_flush(this); impl->input_ready--; - res = SPA_RESULT_OK; + res = SPA_STATUS_OK; } return res; } @@ -779,7 +779,7 @@ static int spa_proxy_node_process_output(struct spa_node *node) &PW_CLIENT_NODE_MESSAGE_INIT(PW_CLIENT_NODE_MESSAGE_PROCESS_OUTPUT)); do_flush(this); - return SPA_RESULT_OK; + return SPA_STATUS_OK; } static int handle_node_message(struct proxy *this, struct pw_client_node_message *message) @@ -812,7 +812,7 @@ static int handle_node_message(struct proxy *this, struct pw_client_node_message p->body.buffer_id.value); } } - return SPA_RESULT_OK; + return 0; } static void setup_transport(struct impl *impl) @@ -832,7 +832,7 @@ client_node_done(void *data, int seq, int res) struct impl *impl = data; struct proxy *this = &impl->proxy; - if (seq == 0 && res == SPA_RESULT_OK) + if (seq == 0 && res == 0) setup_transport(impl); this->callbacks->done(this->callbacks_data, seq, res); @@ -946,7 +946,7 @@ static void proxy_on_data_fd_events(struct spa_source *source) spa_log_warn(this->log, "proxy %p: error reading message: %s", this, strerror(errno)); - while (pw_client_node_transport_next_message(impl->transport, &message) == SPA_RESULT_OK) { + while (pw_client_node_transport_next_message(impl->transport, &message) == 1) { struct pw_client_node_message *msg = alloca(SPA_POD_SIZE(&message)); pw_client_node_transport_parse_message(impl->transport, msg); handle_node_message(this, msg); @@ -995,11 +995,11 @@ proxy_init(struct proxy *this, } if (this->data_loop == NULL) { spa_log_error(this->log, "a data-loop is needed"); - return SPA_RESULT_ERROR; + return -EINVAL; } if (this->map == NULL) { spa_log_error(this->log, "a type map is needed"); - return SPA_RESULT_ERROR; + return -EINVAL; } this->node = proxy_node; @@ -1026,7 +1026,7 @@ static int proxy_clear(struct proxy *this) clear_port(this, &this->out_ports[i], SPA_DIRECTION_OUTPUT, i); } - return SPA_RESULT_OK; + return 0; } static void client_node_resource_destroy(void *data) diff --git a/src/modules/module-client-node/transport.c b/src/modules/module-client-node/transport.c index 06afd780e..56a5f2b81 100644 --- a/src/modules/module-client-node/transport.c +++ b/src/modules/module-client-node/transport.c @@ -87,11 +87,11 @@ static void transport_reset_area(struct pw_client_node_transport *trans) struct pw_client_node_area *a = trans->area; for (i = 0; i < a->max_input_ports; i++) { - trans->inputs[i].status = SPA_RESULT_OK; + trans->inputs[i].status = SPA_STATUS_OK; trans->inputs[i].buffer_id = SPA_ID_INVALID; } for (i = 0; i < a->max_output_ports; i++) { - trans->outputs[i].status = SPA_RESULT_OK; + trans->outputs[i].status = SPA_STATUS_OK; trans->outputs[i].buffer_id = SPA_ID_INVALID; } spa_ringbuffer_init(trans->input_buffer, INPUT_BUFFER_SIZE); @@ -115,20 +115,20 @@ static int add_message(struct pw_client_node_transport *trans, struct pw_client_ uint32_t size, index; if (impl == NULL || message == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; filled = spa_ringbuffer_get_write_index(trans->output_buffer, &index); avail = trans->output_buffer->size - filled; size = SPA_POD_SIZE(message); if (avail < size) - return SPA_RESULT_ERROR; + return -ENOSPC; spa_ringbuffer_write_data(trans->output_buffer, trans->output_data, index & trans->output_buffer->mask, message, size); spa_ringbuffer_write_update(trans->output_buffer, index + size); - return SPA_RESULT_OK; + return 0; } static int next_message(struct pw_client_node_transport *trans, struct pw_client_node_message *message) @@ -137,11 +137,11 @@ static int next_message(struct pw_client_node_transport *trans, struct pw_client int32_t avail; if (impl == NULL || message == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; avail = spa_ringbuffer_get_read_index(trans->input_buffer, &impl->current_index); if (avail < sizeof(struct pw_client_node_message)) - return SPA_RESULT_ENUM_END; + return 0; spa_ringbuffer_read_data(trans->input_buffer, trans->input_data, @@ -150,7 +150,7 @@ static int next_message(struct pw_client_node_transport *trans, struct pw_client *message = impl->current; - return SPA_RESULT_OK; + return 1; } static int parse_message(struct pw_client_node_transport *trans, void *message) @@ -159,7 +159,7 @@ static int parse_message(struct pw_client_node_transport *trans, void *message) uint32_t size; if (impl == NULL || message == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; size = SPA_POD_SIZE(&impl->current); @@ -168,7 +168,7 @@ static int parse_message(struct pw_client_node_transport *trans, void *message) impl->current_index & trans->input_buffer->mask, message, size); spa_ringbuffer_read_update(trans->input_buffer, impl->current_index + size); - return SPA_RESULT_OK; + return 0; } /** Create a new transport @@ -229,7 +229,7 @@ pw_client_node_transport_new_from_info(struct pw_client_node_transport_info *inf impl->mem.fd = info->memfd; impl->mem.offset = info->offset; impl->mem.size = info->size; - if (pw_memblock_map(&impl->mem) != SPA_RESULT_OK) { + if (pw_memblock_map(&impl->mem) < 0) { pw_log_warn("transport %p: failed to map fd %d: %s", impl, info->memfd, strerror(errno)); goto mmap_failed; @@ -278,5 +278,5 @@ int pw_client_node_transport_get_info(struct pw_client_node_transport *trans, info->offset = impl->offset; info->size = impl->mem.size; - return SPA_RESULT_OK; + return 0; } diff --git a/src/modules/module-flatpak.c b/src/modules/module-flatpak.c index 58a2e45d7..de9c5939f 100644 --- a/src/modules/module-flatpak.c +++ b/src/modules/module-flatpak.c @@ -297,7 +297,7 @@ portal_response(DBusConnection *connection, DBusMessage *msg, void *user_data) &p->properties->dict, p->new_id); } else { - pw_resource_error(p->resource->resource, SPA_RESULT_NO_PERMISSION, "not allowed"); + pw_resource_error(p->resource->resource, -EPERM, "not allowed"); } free_pending(p); @@ -424,7 +424,7 @@ static void do_create_object(void *data, dbus_error_free(&error); goto not_allowed; not_allowed: - pw_resource_error(cinfo->core_resource->resource, SPA_RESULT_NO_PERMISSION, "not allowed"); + pw_resource_error(cinfo->core_resource->resource, -EPERM, "not allowed"); return; } @@ -442,7 +442,7 @@ do_create_link(void *data, struct client_info *cinfo = resource->cinfo; if (cinfo->is_sandboxed) { - pw_resource_error(resource->resource, SPA_RESULT_NO_PERMISSION, "not allowed"); + pw_resource_error(resource->resource, -EPERM, "not allowed"); return; } pw_resource_do_parent(resource->resource, diff --git a/src/modules/module-jack.c b/src/modules/module-jack.c index 7e93a588d..124c698ec 100644 --- a/src/modules/module-jack.c +++ b/src/modules/module-jack.c @@ -330,7 +330,7 @@ static int do_add_node(struct spa_loop *loop, bool async, uint32_t seq, size_t s struct jack_client *jc = user_data; struct impl *impl = jc->data; spa_list_append(&impl->rt.nodes, &jc->node->graph_link); - return SPA_RESULT_OK; + return 0; } static int do_remove_node(struct spa_loop *loop, bool async, uint32_t seq, size_t size, const void *data, @@ -338,7 +338,7 @@ static int do_remove_node(struct spa_loop *loop, bool async, uint32_t seq, size_ { struct jack_client *jc = user_data; spa_list_remove(&jc->node->graph_link); - return SPA_RESULT_OK; + return 0; } static int @@ -1102,7 +1102,7 @@ static int do_graph_order_changed(struct spa_loop *loop, } notify_clients(impl, jack_notify_GraphOrderCallback, false, "", 0, 0); - return SPA_RESULT_OK; + return 0; } static void jack_node_pull(void *data) @@ -1328,7 +1328,7 @@ static bool on_global(void *data, struct pw_global *global) return true; } - if (spa_node_enum_params(node->node, SPA_ID_INVALID, &index, NULL, &b) == SPA_RESULT_OK) { + if (spa_node_enum_params(node->node, SPA_ID_INVALID, &index, NULL, &b) == 1) { int min_latency = -1; struct spa_pod_object *props = spa_pod_builder_deref(&b, 0); diff --git a/src/modules/module-jack/jack-node.c b/src/modules/module-jack/jack-node.c index c91869a21..221123254 100644 --- a/src/modules/module-jack/jack-node.c +++ b/src/modules/module-jack/jack-node.c @@ -128,26 +128,26 @@ static int 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 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 node_send_command(struct spa_node *node, const struct spa_command *command) { - return SPA_RESULT_OK; + return 0; } static int node_set_callbacks(struct spa_node *node, const struct spa_node_callbacks *callbacks, void *data) { - return SPA_RESULT_OK; + return 0; } static int node_get_n_ports(struct spa_node *node, @@ -167,7 +167,7 @@ static int node_get_n_ports(struct spa_node *node, if (max_output_ports) *max_output_ports = PORT_NUM_FOR_CLIENT / 2; - return SPA_RESULT_OK; + return 0; } static int node_get_port_ids(struct spa_node *node, @@ -187,17 +187,17 @@ static int node_get_port_ids(struct spa_node *node, if (nd->port_data[SPA_DIRECTION_OUTPUT][i]) output_ids[c++] = nd->port_data[SPA_DIRECTION_OUTPUT][i]->port.port->port_id; } - return SPA_RESULT_OK; + return 0; } static int node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id) { - return SPA_RESULT_NOT_IMPLEMENTED; + return -ENOTSUP; } static int node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id) { - return SPA_RESULT_NOT_IMPLEMENTED; + return -ENOTSUP; } static struct buffer *buffer_dequeue(struct pw_jack_node *this, struct port_data *pd) @@ -222,7 +222,7 @@ static void recycle_buffer(struct pw_jack_node *this, struct port_data *pd, uint static int driver_process_input(struct spa_node *node) { - return SPA_RESULT_NOT_IMPLEMENTED; + return -ENOTSUP; } static void conv_f32_s16(int16_t *out, float *in, int n_samples, int stride) @@ -267,8 +267,8 @@ static int driver_process_output(struct spa_node *node) pw_log_trace(NAME "%p: process output", this); - if (out_io->status == SPA_RESULT_HAVE_BUFFER) - return SPA_RESULT_HAVE_BUFFER; + if (out_io->status == SPA_STATUS_HAVE_BUFFER) + return SPA_STATUS_HAVE_BUFFER; if (out_io->buffer_id < opd->n_buffers) { recycle_buffer(this, opd, out_io->buffer_id); @@ -277,10 +277,10 @@ static int driver_process_output(struct spa_node *node) out = buffer_dequeue(this, opd); if (out == NULL) - return SPA_RESULT_OUT_OF_BUFFERS; + return -EPIPE; out_io->buffer_id = out->outbuf->id; - out_io->status = SPA_RESULT_HAVE_BUFFER; + out_io->status = SPA_STATUS_HAVE_BUFFER; op = out->ptr; @@ -293,7 +293,7 @@ static int driver_process_output(struct spa_node *node) struct buffer *in; int stride = 2; - if (in_io->buffer_id < ipd->n_buffers && in_io->status == SPA_RESULT_HAVE_BUFFER) { + if (in_io->buffer_id < ipd->n_buffers && in_io->status == SPA_STATUS_HAVE_BUFFER) { in = &ipd->buffers[in_io->buffer_id]; conv_f32_s16(op, in->ptr, ctrl->buffer_size, stride); } @@ -301,14 +301,14 @@ static int driver_process_output(struct spa_node *node) fill_s16(op, ctrl->buffer_size, stride); } op++; - in_io->status = SPA_RESULT_NEED_BUFFER; + in_io->status = SPA_STATUS_NEED_BUFFER; } out->outbuf->datas[0].chunk->size = ctrl->buffer_size * sizeof(int16_t) * 2; spa_hook_list_call(&nd->listener_list, struct pw_jack_node_events, push); gn->ready[SPA_DIRECTION_INPUT] = gn->required[SPA_DIRECTION_OUTPUT] = 0; - return SPA_RESULT_HAVE_BUFFER; + return SPA_STATUS_HAVE_BUFFER; } static int node_process_input(struct spa_node *node) @@ -324,8 +324,8 @@ static int node_process_input(struct spa_node *node) int ref_num = this->control->ref_num; pw_log_trace(NAME " %p: process input", nd); - if (nd->status == SPA_RESULT_HAVE_BUFFER) - return SPA_RESULT_HAVE_BUFFER; + if (nd->status == SPA_STATUS_HAVE_BUFFER) + return SPA_STATUS_HAVE_BUFFER; mgr->client_timing[ref_num].status = Triggered; mgr->client_timing[ref_num].signaled_at = current_date; @@ -340,10 +340,10 @@ static int node_process_input(struct spa_node *node) struct port_data *opd = pw_port_get_user_data(port); struct spa_port_io *out_io = opd->io; out_io->buffer_id = 0; - out_io->status = SPA_RESULT_HAVE_BUFFER; + out_io->status = SPA_STATUS_HAVE_BUFFER; pw_log_trace(NAME " %p: port %p: %d %d", nd, p, out_io->buffer_id, out_io->status); } - return nd->status = SPA_RESULT_HAVE_BUFFER; + return nd->status = SPA_STATUS_HAVE_BUFFER; } static int node_process_output(struct spa_node *node) @@ -359,10 +359,10 @@ static int node_process_output(struct spa_node *node) struct port_data *ipd = pw_port_get_user_data(port); struct spa_port_io *in_io = ipd->io; in_io->buffer_id = 0; - in_io->status = SPA_RESULT_NEED_BUFFER; + in_io->status = SPA_STATUS_NEED_BUFFER; pw_log_trace(NAME " %p: port %p: %d %d", nd, p, in_io->buffer_id, in_io->status); } - return nd->status = SPA_RESULT_NEED_BUFFER; + return nd->status = SPA_STATUS_NEED_BUFFER; } @@ -372,7 +372,7 @@ static int port_set_io(struct spa_node *node, enum spa_direction direction, uint struct node_data *nd = SPA_CONTAINER_OF(node, struct node_data, node_impl); struct port_data *pd = nd->port_data[direction][port_id]; pd->io = io; - return SPA_RESULT_OK; + return 0; } static int port_get_info(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -389,7 +389,7 @@ static int port_get_info(struct spa_node *node, enum spa_direction direction, ui pd->info.rate = pd->node->node.server->engine_control->sample_rate; *info = &pd->info; - return SPA_RESULT_OK; + return 0; } static int port_enum_formats(struct spa_node *node, @@ -405,7 +405,7 @@ static int port_enum_formats(struct spa_node *node, struct jack_engine_control *ctrl = pd->node->node.server->engine_control; if (index > 0) - return SPA_RESULT_ENUM_END; + return 0; if (pd->port.jack_port) { if (pd->port.jack_port->type_id == 0) { @@ -424,7 +424,7 @@ static int port_enum_formats(struct spa_node *node, "I", t->media_subtype_audio.midi); } else - return SPA_RESULT_ENUM_END; + return 0; } else { *param = spa_pod_builder_object(builder, @@ -435,7 +435,7 @@ static int port_enum_formats(struct spa_node *node, ":", t->format_audio.rate, "i", ctrl->sample_rate, ":", t->format_audio.channels, "i", 2); } - return SPA_RESULT_OK; + return 1; } static int port_enum_params(struct spa_node *node, @@ -454,15 +454,15 @@ static int port_enum_params(struct spa_node *node, next: 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_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 - return SPA_RESULT_UNKNOWN_PARAM; + return -ENOENT; (*index)++; @@ -470,7 +470,7 @@ static int port_enum_params(struct spa_node *node, if ((res = spa_pod_filter(builder, param, (struct spa_pod*)filter)) < 0) goto next; - return SPA_RESULT_ENUM_END; + return 1; } static int port_set_param(struct spa_node *node, @@ -478,7 +478,7 @@ static int port_set_param(struct spa_node *node, uint32_t id, uint32_t flags, const struct spa_pod_object *param) { - return SPA_RESULT_OK; + return 0; } static int port_use_buffers(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -490,7 +490,7 @@ static int port_use_buffers(struct spa_node *node, enum spa_direction direction, int i; if (pd->have_buffers) - return SPA_RESULT_OK; + return 0; pw_log_debug("use_buffers %d", n_buffers); for (i = 0; i < n_buffers; i++) { @@ -505,13 +505,13 @@ static int port_use_buffers(struct spa_node *node, enum spa_direction direction, b->ptr = d[0].data; } else { pw_log_error(NAME " %p: invalid memory on buffer %p", pd, buffers[i]); - return SPA_RESULT_ERROR; + return -EINVAL; } spa_list_append(&pd->empty, &b->link); } pd->n_buffers = n_buffers; - return SPA_RESULT_OK; + return 0; } static int port_alloc_buffers(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -537,12 +537,12 @@ static int port_alloc_buffers(struct spa_node *node, enum spa_direction directio } pd->n_buffers = *n_buffers; - return SPA_RESULT_OK; + return 0; } static int port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { - return SPA_RESULT_OK; + return 0; } static int driver_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id) @@ -553,13 +553,13 @@ static int driver_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t recycle_buffer(this, opd, buffer_id); - return SPA_RESULT_OK; + return 0; } static int port_send_command(struct spa_node *node, enum spa_direction direction, uint32_t port_id, const struct spa_command *command) { - return SPA_RESULT_OK; + return 0; } static const struct spa_node driver_impl = { @@ -624,7 +624,7 @@ static int schedule_mix_input(struct spa_node *_node) pw_log_trace("mix %p: input %d %d", node, p->io->buffer_id, link->output->n_buffers); - if (!(p->io->buffer_id < link->output->n_buffers && p->io->status == SPA_RESULT_HAVE_BUFFER)) + if (!(p->io->buffer_id < link->output->n_buffers && p->io->status == SPA_STATUS_HAVE_BUFFER)) continue; inbuf = link->output->buffers[p->io->buffer_id]; @@ -638,10 +638,10 @@ static int schedule_mix_input(struct spa_node *_node) p, p->io, io, p->io->status, p->io->buffer_id); *io = *p->io; io->buffer_id = 0; - p->io->status = SPA_RESULT_OK; + p->io->status = SPA_STATUS_OK; p->io->buffer_id = SPA_ID_INVALID; } - return SPA_RESULT_HAVE_BUFFER; + return SPA_STATUS_HAVE_BUFFER; } static int schedule_mix_output(struct spa_node *_node) diff --git a/src/modules/module-mixer.c b/src/modules/module-mixer.c index 91e9115b7..1709c8f23 100644 --- a/src/modules/module-mixer.c +++ b/src/modules/module-mixer.c @@ -74,10 +74,10 @@ static const struct spa_handle_factory *find_factory(struct impl *impl) goto no_symbol; } - for (index = 0;; index++) { - if ((res = enum_func(&factory, index)) < 0) { - if (res != SPA_RESULT_ENUM_END) - pw_log_error("can't enumerate factories: %d", res); + for (index = 0;;) { + if ((res = enum_func(&factory, &index)) <= 0) { + if (res != 0) + pw_log_error("can't enumerate factories: %s", spa_strerror(res)); goto enum_failed; } if (strcmp(factory->name, "audiomixer") == 0) diff --git a/src/modules/spa/module-node-factory.c b/src/modules/spa/module-node-factory.c index fcae2e90d..544f68096 100644 --- a/src/modules/spa/module-node-factory.c +++ b/src/modules/spa/module-node-factory.c @@ -83,7 +83,7 @@ static void *create_object(void *_data, no_properties: pw_log_error("needed properties: spa.library.name= spa.factory.name="); if (resource) { - pw_resource_error(resource, SPA_RESULT_INVALID_ARGUMENTS, + pw_resource_error(resource, -EINVAL, "needed properties: " "spa.library.name= " "spa.factory.name="); @@ -92,7 +92,7 @@ static void *create_object(void *_data, no_mem: pw_log_error("can't create node"); if (resource) { - pw_resource_error(resource, SPA_RESULT_NO_MEMORY, "no memory"); + pw_resource_error(resource, -ENOMEM, "no memory"); } return NULL; } diff --git a/src/modules/spa/spa-monitor.c b/src/modules/spa/spa-monitor.c index d17dd3ecc..cb6ca021d 100644 --- a/src/modules/spa/spa-monitor.c +++ b/src/modules/spa/spa-monitor.c @@ -253,10 +253,10 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core, goto no_symbol; } - for (index = 0;; index++) { - if ((res = enum_func(&factory, index)) < 0) { - if (res != SPA_RESULT_ENUM_END) - pw_log_error("can't enumerate factories: %d", res); + for (index = 0;;) { + if ((res = enum_func(&factory, &index)) <= 0) { + if (res != 0) + pw_log_error("can't enumerate factories: %s", spa_strerror(res)); goto enum_failed; } if (strcmp(factory->name, factory_name) == 0) @@ -294,13 +294,13 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core, spa_list_init(&impl->item_list); - for (index = 0;; index++) { + for (index = 0;;) { struct spa_monitor_item *item; int res; - if ((res = spa_monitor_enum_items(this->monitor, &item, index)) < 0) { - if (res != SPA_RESULT_ENUM_END) - pw_log_debug("spa_monitor_enum_items: got error %d\n", res); + if ((res = spa_monitor_enum_items(this->monitor, &item, &index)) <= 0) { + if (res != 0) + pw_log_debug("spa_monitor_enum_items: %s\n", spa_strerror(res)); break; } add_item(this, item); diff --git a/src/modules/spa/spa-node.c b/src/modules/spa/spa-node.c index 830039772..1606c61c6 100644 --- a/src/modules/spa/spa-node.c +++ b/src/modules/spa/spa-node.c @@ -163,9 +163,9 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie uint8_t buf[2048]; struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf)); - if ((res = spa_node_enum_params(spa_node, t->param.idProps, &index, NULL, &b)) != SPA_RESULT_OK) { + if ((res = spa_node_enum_params(spa_node, t->param.idProps, &index, NULL, &b)) <= 0) { pw_log_debug("spa_node_get_props failed: %d", res); - return SPA_RESULT_ERROR; + return res; } props = spa_pod_builder_deref(&b, 0); @@ -218,11 +218,11 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie } } - if ((res = spa_node_set_param(spa_node, t->param.idProps, 0, props)) != SPA_RESULT_OK) { + if ((res = spa_node_set_param(spa_node, t->param.idProps, 0, props)) < 0) { pw_log_debug("spa_node_set_props failed: %d", res); - return SPA_RESULT_ERROR; + return res; } - return SPA_RESULT_OK; + return 0; } @@ -266,10 +266,10 @@ struct pw_node *pw_spa_node_load(struct pw_core *core, goto no_symbol; } - for (index = 0;; index++) { - if ((res = enum_func(&factory, index)) < 0) { - if (res != SPA_RESULT_ENUM_END) - pw_log_error("can't enumerate factories: %d", res); + for (index = 0;;) { + if ((res = enum_func(&factory, &index)) <= 0) { + if (res != 0) + pw_log_error("can't enumerate factories: %s", spa_strerror(res)); goto enum_failed; } if (strcmp(factory->name, factory_name) == 0) @@ -294,7 +294,7 @@ struct pw_node *pw_spa_node_load(struct pw_core *core, spa_node = iface; if (properties != NULL) { - if (setup_props(core, spa_node, properties) != SPA_RESULT_OK) { + if (setup_props(core, spa_node, properties) < 0) { pw_log_debug("Unrecognized properties"); } } diff --git a/src/pipewire/client.c b/src/pipewire/client.c index 05faf30eb..d5ff20cef 100644 --- a/src/pipewire/client.c +++ b/src/pipewire/client.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include "pipewire/pipewire.h" @@ -72,12 +73,12 @@ client_bind_func(struct pw_global *global, pw_client_resource_info(resource, &this->info); this->info.change_mask = 0; - return SPA_RESULT_OK; + return 0; no_mem: pw_log_error("can't create client resource"); - pw_resource_error(client->core_resource, SPA_RESULT_NO_MEMORY, "no memory"); - return SPA_RESULT_NO_MEMORY; + pw_resource_error(client->core_resource, -ENOMEM, "no memory"); + return -ENOMEM; } /** Make a new client object diff --git a/src/pipewire/core.c b/src/pipewire/core.c index 7ab214ecf..9567348a1 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -16,6 +16,7 @@ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -158,7 +159,7 @@ static void core_get_registry(void *object, uint32_t version, uint32_t new_id) no_mem: pw_log_error("can't create registry resource"); pw_core_resource_error(client->core_resource, - resource->id, SPA_RESULT_NO_MEMORY, "no memory"); + resource->id, -ENOMEM, "no memory"); } static void @@ -205,20 +206,20 @@ core_create_object(void *object, no_factory: pw_log_error("can't find node factory %s", factory_name); pw_core_resource_error(client->core_resource, - resource->id, SPA_RESULT_INVALID_ARGUMENTS, "unknown factory name %s", factory_name); + resource->id, -EINVAL, "unknown factory name %s", factory_name); goto done; wrong_version: wrong_type: pw_log_error("invalid resource type/version"); pw_core_resource_error(client->core_resource, - resource->id, SPA_RESULT_INCOMPATIBLE_VERSION, "wrong resource type/version"); + resource->id, -EINVAL, "wrong resource type/version"); goto done; no_properties: pw_log_error("can't create properties"); goto no_mem; no_mem: pw_core_resource_error(client->core_resource, - resource->id, SPA_RESULT_NO_MEMORY, "no memory"); + resource->id, -ENOMEM, "no memory"); goto done; } @@ -283,23 +284,23 @@ core_create_link(void *object, no_output: pw_core_resource_error(client->core_resource, - resource->id, SPA_RESULT_INVALID_ARGUMENTS, "unknown output node"); + resource->id, -EINVAL, "unknown output node"); goto done; no_input: pw_core_resource_error(client->core_resource, - resource->id, SPA_RESULT_INVALID_ARGUMENTS, "unknown input node"); + resource->id, -EINVAL, "unknown input node"); goto done; no_output_port: pw_core_resource_error(client->core_resource, - resource->id, SPA_RESULT_INVALID_ARGUMENTS, "unknown output port"); + resource->id, -EINVAL, "unknown output port"); goto done; no_input_port: pw_core_resource_error(client->core_resource, - resource->id, SPA_RESULT_INVALID_ARGUMENTS, "unknown input port"); + resource->id, -EINVAL, "unknown input port"); goto done; no_link: pw_core_resource_error(client->core_resource, - resource->id, SPA_RESULT_ERROR, "can't create link: %s, error"); + resource->id, -ENOMEM, "can't create link: %s, error"); free(error); goto done; no_bind: @@ -375,11 +376,11 @@ core_bind_func(struct pw_global *global, this->info.change_mask = PW_CORE_CHANGE_MASK_ALL; pw_core_resource_info(resource, &this->info); - return SPA_RESULT_OK; + return 0; no_mem: pw_log_error("can't create core resource"); - return SPA_RESULT_NO_MEMORY; + return -ENOMEM; } /** Create a new core object @@ -738,8 +739,10 @@ int pw_core_find_format(struct pw_core *core, if ((res = spa_node_port_enum_params(output->node->node, output->direction, output->port_id, t->param.idFormat, &oidx, - NULL, builder)) < 0) { - asprintf(error, "error get output format: %d", res); + NULL, builder)) <= 0) { + if (res == 0) + res = -EBADF; + asprintf(error, "error get output format: %s", spa_strerror(res)); goto error; } } else if (out_state == PW_PORT_STATE_CONFIGURE && in_state > PW_PORT_STATE_CONFIGURE) { @@ -747,8 +750,10 @@ int pw_core_find_format(struct pw_core *core, if ((res = spa_node_port_enum_params(input->node->node, input->direction, input->port_id, t->param.idFormat, &iidx, - NULL, builder)) < 0) { - asprintf(error, "error get input format: %d", res); + NULL, builder)) <= 0) { + if (res == 0) + res = -EBADF; + asprintf(error, "error get input format: %s", spa_strerror(res)); goto error; } } else if (in_state == PW_PORT_STATE_CONFIGURE && out_state == PW_PORT_STATE_CONFIGURE) { @@ -762,9 +767,9 @@ int pw_core_find_format(struct pw_core *core, if ((res = spa_node_port_enum_params(input->node->node, input->direction, input->port_id, t->param.idEnumFormat, &iidx, - NULL, &fb)) < 0) { - if (res == SPA_RESULT_ENUM_END && iidx == 0) { - asprintf(error, "error input enum formats: %d", res); + NULL, &fb)) <= 0) { + if (res == 0 && iidx == 0) { + asprintf(error, "error input enum formats: %s", spa_strerror(res)); goto error; } asprintf(error, "no more input formats"); @@ -778,8 +783,8 @@ int pw_core_find_format(struct pw_core *core, if ((res = spa_node_port_enum_params(output->node->node, output->direction, output->port_id, t->param.idEnumFormat, &oidx, - format, builder)) < 0) { - if (res == SPA_RESULT_ENUM_END) { + format, builder)) <= 0) { + if (res == 0) { oidx = 0; goto again; } @@ -792,13 +797,15 @@ int pw_core_find_format(struct pw_core *core, if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) spa_debug_pod(&format->pod, SPA_DEBUG_FLAG_FORMAT); } else { - res = SPA_RESULT_ERROR; + res = -EBADF; asprintf(error, "error node state"); goto error; } return res; error: + if (res == 0) + res = -EBADF; return res; } diff --git a/src/pipewire/data-loop.c b/src/pipewire/data-loop.c index f8646f31e..2f8d31ceb 100644 --- a/src/pipewire/data-loop.c +++ b/src/pipewire/data-loop.c @@ -174,15 +174,15 @@ int pw_data_loop_start(struct pw_data_loop *loop) if ((err = pthread_create(&loop->thread, NULL, do_loop, loop)) != 0) { pw_log_warn("data-loop %p: can't create thread: %s", loop, strerror(err)); loop->running = false; - return SPA_RESULT_ERROR; + return -err; } } - return SPA_RESULT_OK; + return 0; } /** Stop a data loop * \param loop the data loop to Stop - * \return \ref SPA_RESULT_OK + * \return 0 * * This will stop and join the realtime thread that manages the loop. * @@ -195,7 +195,7 @@ int pw_data_loop_stop(struct pw_data_loop *loop) pthread_join(loop->thread, NULL); } - return SPA_RESULT_OK; + return 0; } /** Check if we are inside the data loop diff --git a/src/pipewire/factory.c b/src/pipewire/factory.c index 47d2466bc..22de78b79 100644 --- a/src/pipewire/factory.c +++ b/src/pipewire/factory.c @@ -17,6 +17,8 @@ * Boston, MA 02110-1301, USA. */ +#include + #include "pipewire/pipewire.h" #include "pipewire/factory.h" #include "pipewire/private.h" @@ -103,13 +105,13 @@ factory_bind_func(struct pw_global *global, pw_factory_resource_info(resource, &this->info); this->info.change_mask = 0; - return SPA_RESULT_OK; + return 0; no_mem: pw_log_error("can't create factory resource"); pw_core_resource_error(client->core_resource, - client->core_resource->id, SPA_RESULT_NO_MEMORY, "no memory"); - return SPA_RESULT_NO_MEMORY; + client->core_resource->id, -ENOMEM, "no memory"); + return -ENOMEM; } void pw_factory_register(struct pw_factory *factory, diff --git a/src/pipewire/global.c b/src/pipewire/global.c index ed84cf046..56d681b06 100644 --- a/src/pipewire/global.c +++ b/src/pipewire/global.c @@ -16,6 +16,8 @@ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301, USA. */ + +#include #include #include #include @@ -179,14 +181,14 @@ pw_global_bind(struct pw_global *global, struct pw_client *client, uint32_t perm return res; wrong_version: - res = SPA_RESULT_INCOMPATIBLE_VERSION; + res = -EINVAL; pw_core_resource_error(client->core_resource, client->core_resource->id, res, "id %d: interface version %d < %d", id, global->version, version); return res; no_bind: - res = SPA_RESULT_NOT_IMPLEMENTED; + res = -ENOTSUP; pw_core_resource_error(client->core_resource, client->core_resource->id, res, "can't bind object id %d to interface", id); diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 95b13354b..a4c71850a 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include @@ -113,7 +114,7 @@ static void complete_streaming(void *obj, void *data, int res, uint32_t id) static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_state) { struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this); - int res = SPA_RESULT_ERROR, res2; + int res = -EIO, res2; struct spa_pod_object *format = NULL, *current; char *error = NULL; struct pw_resource *resource; @@ -125,7 +126,7 @@ static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_st uint32_t index = 0; if (in_state != PW_PORT_STATE_CONFIGURE && out_state != PW_PORT_STATE_CONFIGURE) - return SPA_RESULT_OK; + return 0; pw_link_update_state(this, PW_LINK_STATE_NEGOTIATING, NULL); @@ -142,8 +143,10 @@ static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_st if ((res = spa_node_port_enum_params(output->node->node, output->direction, output->port_id, t->param.idFormat, &index, - NULL, &b)) < 0) { - asprintf(&error, "error get output format: %d", res); + NULL, &b)) <= 0) { + if (res == 0) + res = -EBADF; + asprintf(&error, "error get output format: %s", spa_strerror(res)); goto error; } current = spa_pod_builder_deref(&b, 0); @@ -161,8 +164,10 @@ static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_st if ((res = spa_node_port_enum_params(input->node->node, input->direction, input->port_id, t->param.idFormat, &index, - NULL, &b)) < 0) { - asprintf(&error, "error get input format: %d", res); + NULL, &b)) <= 0) { + if (res == 0) + res = -EBADF; + asprintf(&error, "error get input format: %s", spa_strerror(res)); goto error; } current = spa_pod_builder_deref(&b, 0); @@ -219,7 +224,7 @@ static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_st this->info.change_mask = 0; } - return SPA_RESULT_OK; + return 0; error: pw_link_update_state(this, PW_LINK_STATE_ERROR, error); @@ -407,7 +412,7 @@ param_filter(struct pw_link *this, spa_pod_builder_init(&ib, ibuf, sizeof(ibuf)); pw_log_debug("iparam %d", iidx); if (spa_node_port_enum_params(in_port->node->node, in_port->direction, in_port->port_id, - id, &iidx, NULL, &ib) < 0) + id, &iidx, NULL, &ib) <= 0) break; iparam = spa_pod_builder_deref(&ib, 0); @@ -422,7 +427,7 @@ param_filter(struct pw_link *this, pw_log_debug("oparam %d %d", oidx, offset); if (spa_node_port_enum_params(out_port->node->node, out_port->direction, out_port->port_id, id, &oidx, - iparam, result) < 0) { + iparam, result) <= 0) { break; } oparam = spa_pod_builder_deref(result, offset); @@ -447,7 +452,7 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s struct pw_type *t = &this->core->type; if (in_state != PW_PORT_STATE_READY && out_state != PW_PORT_STATE_READY) - return SPA_RESULT_OK; + return 0; pw_link_update_state(this, PW_LINK_STATE_ALLOCATING, NULL); @@ -495,7 +500,7 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s in_flags = SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS; } else { asprintf(&error, "no common buffer alloc found"); - res = SPA_RESULT_ERROR; + res = -EIO; goto error; } } else if (in_state == PW_PORT_STATE_READY && out_state > PW_PORT_STATE_READY) { @@ -506,7 +511,7 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s out_flags &= ~SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS; } else { pw_log_debug("link %p: delay allocation, state %d %d", this, in_state, out_state); - return SPA_RESULT_OK; + return 0; } if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) { @@ -667,7 +672,7 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s goto error; } - return SPA_RESULT_OK; + return 0; error: output->buffers = NULL; @@ -686,7 +691,7 @@ do_activate_link(struct spa_loop *loop, { struct pw_link *this = user_data; spa_graph_port_link(&this->rt.out_port, &this->rt.in_port); - return SPA_RESULT_OK; + return 0; } static int do_start(struct pw_link *this, uint32_t in_state, uint32_t out_state) @@ -697,7 +702,7 @@ static int do_start(struct pw_link *this, uint32_t in_state, uint32_t out_state) struct pw_port *input, *output; if (in_state < PW_PORT_STATE_PAUSED || out_state < PW_PORT_STATE_PAUSED) - return SPA_RESULT_OK; + return 0; pw_link_update_state(this, PW_LINK_STATE_PAUSED, NULL); @@ -729,7 +734,7 @@ static int do_start(struct pw_link *this, uint32_t in_state, uint32_t out_state) else complete_streaming(output->node, output, res, 0); } - return SPA_RESULT_OK; + return 0; error: pw_link_update_state(this, PW_LINK_STATE_ERROR, error); @@ -743,17 +748,17 @@ static int check_states(struct pw_link *this, void *user_data, int res) struct pw_port *input, *output; if (this->state == PW_LINK_STATE_ERROR) - return SPA_RESULT_ERROR; + return -EIO; input = this->input; output = this->output; if (input == NULL || output == NULL) - return SPA_RESULT_OK; + return 0; if (input->node->info.state == PW_NODE_STATE_ERROR || output->node->info.state == PW_NODE_STATE_ERROR) - return SPA_RESULT_ERROR; + return -EIO; in_state = input->state; out_state = output->state; @@ -762,21 +767,21 @@ static int check_states(struct pw_link *this, void *user_data, int res) if (in_state == PW_PORT_STATE_ERROR || out_state == PW_PORT_STATE_ERROR) { pw_link_update_state(this, PW_LINK_STATE_ERROR, NULL); - return SPA_RESULT_ERROR; + return -EIO; } if (in_state == PW_PORT_STATE_STREAMING && out_state == PW_PORT_STATE_STREAMING) { pw_link_update_state(this, PW_LINK_STATE_RUNNING, NULL); - return SPA_RESULT_OK; + return 0; } - if ((res = do_negotiate(this, in_state, out_state)) != SPA_RESULT_OK) + if ((res = do_negotiate(this, in_state, out_state)) != 0) goto exit; - if ((res = do_allocation(this, in_state, out_state)) != SPA_RESULT_OK) + if ((res = do_allocation(this, in_state, out_state)) != 0) goto exit; - if ((res = do_start(this, in_state, out_state)) != SPA_RESULT_OK) + if ((res = do_start(this, in_state, out_state)) != 0) goto exit; exit: @@ -786,7 +791,7 @@ static int check_states(struct pw_link *this, void *user_data, int res) } pw_work_queue_add(impl->work, - this, SPA_RESULT_WAIT_SYNC, (pw_work_func_t) check_states, this); + this, -EBUSY, (pw_work_func_t) check_states, this); return res; } @@ -822,7 +827,7 @@ do_remove_input(struct spa_loop *loop, { struct pw_link *this = user_data; spa_graph_port_remove(&this->rt.in_port); - return SPA_RESULT_OK; + return 0; } static void input_remove(struct pw_link *this, struct pw_port *port) @@ -845,7 +850,7 @@ do_remove_output(struct spa_loop *loop, { struct pw_link *this = user_data; spa_graph_port_remove(&this->rt.out_port); - return SPA_RESULT_OK; + return 0; } static void output_remove(struct pw_link *this, struct pw_port *port) @@ -916,7 +921,7 @@ bool pw_link_activate(struct pw_link *this) this->input->node->n_used_input_links++; pw_work_queue_add(impl->work, - this, SPA_RESULT_WAIT_SYNC, (pw_work_func_t) check_states, this); + this, -EBUSY, (pw_work_func_t) check_states, this); return true; } @@ -927,7 +932,7 @@ do_deactivate_link(struct spa_loop *loop, { struct pw_link *this = user_data; spa_graph_port_unlink(&this->rt.out_port); - return SPA_RESULT_OK; + return 0; } bool pw_link_deactivate(struct pw_link *this) @@ -1011,13 +1016,13 @@ link_bind_func(struct pw_global *global, pw_link_resource_info(resource, &this->info); this->info.change_mask = 0; - return SPA_RESULT_OK; + return 0; no_mem: pw_log_error("can't create link resource"); pw_core_resource_error(client->core_resource, - client->core_resource->id, SPA_RESULT_NO_MEMORY, "no memory"); - return SPA_RESULT_NO_MEMORY; + client->core_resource->id, -ENOMEM, "no memory"); + return -ENOMEM; } static int @@ -1033,7 +1038,7 @@ do_add_link(struct spa_loop *loop, spa_graph_port_add(&port->rt.mix_node, &this->rt.in_port); } - return SPA_RESULT_OK; + return 0; } static const struct pw_port_events input_port_events = { diff --git a/src/pipewire/mem.c b/src/pipewire/mem.c index 0851435b0..dcd1fe4b0 100644 --- a/src/pipewire/mem.c +++ b/src/pipewire/mem.c @@ -84,7 +84,7 @@ static inline int memfd_create(const char *name, unsigned int flags) int pw_memblock_map(struct pw_memblock *mem) { if (mem->ptr != NULL) - return SPA_RESULT_OK; + return 0; if (mem->flags & PW_MEMBLOCK_FLAG_MAP_READWRITE) { int prot = 0; @@ -101,14 +101,14 @@ int pw_memblock_map(struct pw_memblock *mem) mmap(NULL, mem->size << 1, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (mem->ptr == MAP_FAILED) - return SPA_RESULT_NO_MEMORY; + return -errno; ptr = mmap(mem->ptr, mem->size, prot, MAP_FIXED | MAP_SHARED, mem->fd, mem->offset); if (ptr != mem->ptr) { munmap(mem->ptr, mem->size << 1); - return SPA_RESULT_NO_MEMORY; + return -ENOMEM; } ptr = @@ -116,17 +116,17 @@ int pw_memblock_map(struct pw_memblock *mem) mem->fd, mem->offset); if (ptr != mem->ptr + mem->size) { munmap(mem->ptr, mem->size << 1); - return SPA_RESULT_NO_MEMORY; + return -ENOMEM; } } else { mem->ptr = mmap(NULL, mem->size, prot, MAP_SHARED, mem->fd, 0); if (mem->ptr == MAP_FAILED) - return SPA_RESULT_NO_MEMORY; + return -ENOMEM; } } else { mem->ptr = NULL; } - return SPA_RESULT_OK; + return 0; } /** Create a new memblock @@ -141,7 +141,7 @@ int pw_memblock_alloc(enum pw_memblock_flags flags, size_t size, struct pw_membl bool use_fd; if (mem == NULL || size == 0) - return SPA_RESULT_INVALID_ARGUMENTS; + return -EINVAL; mem->offset = 0; mem->flags = flags; @@ -155,14 +155,14 @@ int pw_memblock_alloc(enum pw_memblock_flags flags, size_t size, struct pw_membl mem->fd = memfd_create("pipewire-memfd", MFD_CLOEXEC | MFD_ALLOW_SEALING); if (mem->fd == -1) { pw_log_error("Failed to create memfd: %s\n", strerror(errno)); - return SPA_RESULT_ERRNO; + return -errno; } #else char filename[] = "/dev/shm/pipewire-tmpfile.XXXXXX"; mem->fd = mkostemp(filename, O_CLOEXEC); if (mem->fd == -1) { pw_log_error("Failed to create temporary file: %s\n", strerror(errno)); - return SPA_RESULT_ERRNO; + return -errno; } unlink(filename); #endif @@ -170,7 +170,7 @@ int pw_memblock_alloc(enum pw_memblock_flags flags, size_t size, struct pw_membl if (ftruncate(mem->fd, size) < 0) { pw_log_warn("Failed to truncate temporary file: %s", strerror(errno)); close(mem->fd); - return SPA_RESULT_ERRNO; + return -errno; } #ifdef USE_MEMFD if (flags & PW_MEMBLOCK_FLAG_SEAL) { @@ -180,23 +180,23 @@ int pw_memblock_alloc(enum pw_memblock_flags flags, size_t size, struct pw_membl } } #endif - if (pw_memblock_map(mem) != SPA_RESULT_OK) + if (pw_memblock_map(mem) != 0) goto mmap_failed; } else { mem->ptr = malloc(size); if (mem->ptr == NULL) - return SPA_RESULT_NO_MEMORY; + return -ENOMEM; mem->fd = -1; } if (!(flags & PW_MEMBLOCK_FLAG_WITH_FD) && mem->fd != -1) { close(mem->fd); mem->fd = -1; } - return SPA_RESULT_OK; + return 0; mmap_failed: close(mem->fd); - return SPA_RESULT_NO_MEMORY; + return -ENOMEM; } /** Free a memblock diff --git a/src/pipewire/module.c b/src/pipewire/module.c index fb65d4cf9..0859b88b5 100644 --- a/src/pipewire/module.c +++ b/src/pipewire/module.c @@ -129,13 +129,13 @@ module_bind_func(struct pw_global *global, pw_module_resource_info(resource, &this->info); this->info.change_mask = 0; - return SPA_RESULT_OK; + return 0; no_mem: pw_log_error("can't create module resource"); pw_core_resource_error(client->core_resource, - client->core_resource->id, SPA_RESULT_NO_MEMORY, "no memory"); - return SPA_RESULT_NO_MEMORY; + client->core_resource->id, -ENOMEM, "no memory"); + return -ENOMEM; } struct pw_module * pw_core_find_module(struct pw_core *core, const char *filename) diff --git a/src/pipewire/node.c b/src/pipewire/node.c index 33356334a..f5647f5f6 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -48,10 +48,10 @@ struct resource_data { static int pause_node(struct pw_node *this) { - int res = SPA_RESULT_OK; + int res = 0; if (this->info.state <= PW_NODE_STATE_IDLE) - return SPA_RESULT_OK; + return 0; pw_log_debug("node %p: pause node", this); res = spa_node_send_command(this->node, @@ -64,7 +64,7 @@ static int pause_node(struct pw_node *this) static int start_node(struct pw_node *this) { - int res = SPA_RESULT_OK; + int res = 0; pw_log_debug("node %p: start node", this); res = spa_node_send_command(this->node, @@ -77,7 +77,7 @@ static int start_node(struct pw_node *this) static int suspend_node(struct pw_node *this) { - int res = SPA_RESULT_OK; + int res = 0; struct pw_port *p; pw_log_debug("node %p: suspend node", this); @@ -216,7 +216,7 @@ static int update_port_ids(struct pw_node *node) update_port_map(node, PW_DIRECTION_INPUT, &node->input_port_map, input_port_ids, n_input_ports); update_port_map(node, PW_DIRECTION_OUTPUT, &node->output_port_map, output_port_ids, n_output_ports); - return SPA_RESULT_OK; + return 0; } static void @@ -237,7 +237,7 @@ update_info(struct pw_node *this) if (spa_node_port_enum_params(port->node->node, port->direction, port->port_id, this->core->type.param.idEnumFormat, &state, - NULL, &b) < 0) + NULL, &b) <= 0) break; fmt = spa_pod_builder_deref(&b, 0); @@ -260,7 +260,7 @@ update_info(struct pw_node *this) if (spa_node_port_enum_params(port->node->node, port->direction, port->port_id, this->core->type.param.idEnumFormat, &state, - NULL, &b) < 0) + NULL, &b) <= 0) break; fmt = spa_pod_builder_deref(&b, 0); @@ -322,13 +322,13 @@ node_bind_func(struct pw_global *global, pw_node_resource_info(resource, &this->info); this->info.change_mask = 0; - return SPA_RESULT_OK; + return 0; no_mem: pw_log_error("can't create node resource"); pw_core_resource_error(client->core_resource, - client->core_resource->id, SPA_RESULT_NO_MEMORY, "no memory"); - return SPA_RESULT_NO_MEMORY; + client->core_resource->id, -ENOMEM, "no memory"); + return -ENOMEM; } static int @@ -339,7 +339,7 @@ do_node_add(struct spa_loop *loop, spa_graph_node_add(this->rt.graph, &this->rt.node); - return SPA_RESULT_OK; + return 0; } @@ -562,7 +562,7 @@ do_node_remove(struct spa_loop *loop, spa_graph_node_remove(&this->rt.node); - return SPA_RESULT_OK; + return 0; } /** Destroy a node @@ -784,7 +784,7 @@ static void node_activate(struct pw_node *this) */ int pw_node_set_state(struct pw_node *node, enum pw_node_state state) { - int res = SPA_RESULT_OK; + int res = 0; struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this); spa_hook_list_call(&node->listener_list, struct pw_node_events, state_request, state); @@ -793,7 +793,7 @@ int pw_node_set_state(struct pw_node *node, enum pw_node_state state) switch (state) { case PW_NODE_STATE_CREATING: - return SPA_RESULT_ERROR; + return -EIO; case PW_NODE_STATE_SUSPENDED: res = suspend_node(node); diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index 21a0372b6..003719d35 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -161,10 +161,10 @@ const struct spa_handle_factory *pw_get_support_factory(const char *factory_name uint32_t index; const struct spa_handle_factory *factory; - for (index = 0;; index++) { - if ((res = support_info.enum_func(&factory, index)) < 0) { - if (res != SPA_RESULT_ENUM_END) - fprintf(stderr, "can't enumerate factories: %d\n", res); + for (index = 0;;) { + if ((res = support_info.enum_func(&factory, &index)) <= 0) { + if (res != 0) + fprintf(stderr, "can't enumerate factories: %s\n", spa_strerror(res)); break; } if (strcmp(factory->name, factory_name) == 0) diff --git a/src/pipewire/port.c b/src/pipewire/port.c index e3fc2eabf..a5cc65a95 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -58,7 +58,7 @@ static int schedule_tee_input(struct spa_node *data) io->buffer_id = SPA_ID_INVALID; } else - io->status = SPA_RESULT_NEED_BUFFER; + io->status = SPA_STATUS_NEED_BUFFER; return io->status; } @@ -86,7 +86,7 @@ static int schedule_tee_reuse_buffer(struct spa_node *data, uint32_t port_id, ui pw_log_trace("tee reuse buffer %d %d", port_id, buffer_id); spa_node_port_reuse_buffer(pp->node->implementation, port_id, buffer_id); } - return SPA_RESULT_OK; + return 0; } static const struct spa_node schedule_tee_node = { @@ -142,7 +142,7 @@ static int schedule_mix_reuse_buffer(struct spa_node *data, uint32_t port_id, ui spa_node_port_reuse_buffer(pp->node->implementation, port_id, buffer_id); } } - return SPA_RESULT_OK; + return 0; } static const struct spa_node schedule_mix_node = { @@ -264,7 +264,7 @@ static int do_add_port(struct spa_loop *loop, spa_graph_port_add(&this->rt.mix_node, &this->rt.mix_port); spa_graph_port_link(&this->rt.port, &this->rt.mix_port); - return SPA_RESULT_OK; + return 0; } bool pw_port_add(struct pw_port *port, struct pw_node *node) @@ -314,7 +314,7 @@ static int do_remove_port(struct spa_loop *loop, spa_graph_port_remove(&this->rt.mix_port); spa_graph_node_remove(&this->rt.mix_node); - return SPA_RESULT_OK; + return 0; } void pw_port_destroy(struct pw_port *port) @@ -395,10 +395,10 @@ int pw_port_use_buffers(struct pw_port *port, struct spa_buffer **buffers, uint3 int res; if (n_buffers == 0 && port->state <= PW_PORT_STATE_READY) - return SPA_RESULT_OK; + return 0; if (n_buffers > 0 && port->state < PW_PORT_STATE_READY) - return SPA_RESULT_NO_FORMAT; + return -EIO; if (port->state > PW_PORT_STATE_PAUSED) { pw_loop_invoke(port->node->data_loop, @@ -432,7 +432,7 @@ int pw_port_alloc_buffers(struct pw_port *port, int res; if (port->state < PW_PORT_STATE_READY) - return SPA_RESULT_NO_FORMAT; + return -EIO; if (port->state > PW_PORT_STATE_PAUSED) { pw_loop_invoke(port->node->data_loop, diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c index 2d1c85edf..441a82895 100644 --- a/src/pipewire/remote.c +++ b/src/pipewire/remote.c @@ -436,7 +436,7 @@ do_remove_source(struct spa_loop *loop, pw_loop_destroy_source(d->core->data_loop, d->rtsocket_source); d->rtsocket_source = NULL; } - return SPA_RESULT_OK; + return 0; } @@ -504,7 +504,7 @@ on_rtsocket_condition(void *user_data, int fd, enum spa_io mask) pw_log_warn("proxy %p: %ld messages", proxy, cmd); - while (pw_client_node_transport_next_message(data->trans, &message) == SPA_RESULT_OK) { + while (pw_client_node_transport_next_message(data->trans, &message) == 1) { struct pw_client_node_message *msg = alloca(SPA_POD_SIZE(&message)); pw_client_node_transport_parse_message(data->trans, msg); handle_rtnode_message(proxy, msg); @@ -657,7 +657,7 @@ static void add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32 if (spa_node_port_enum_params(port->node->node, port->direction, port->port_id, data->t->param.idList, &idx1, - NULL, &b) < 0) + NULL, &b) <= 0) break; param = spa_pod_builder_deref(&b, 0); @@ -669,7 +669,7 @@ static void add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32 if (spa_node_port_enum_params(port->node->node, port->direction, port->port_id, id, &idx2, - NULL, &b) < 0) + NULL, &b) <= 0) break; param = spa_pod_builder_deref(&b, 0); @@ -763,7 +763,7 @@ static void client_node_command(void *object, uint32_t seq, const struct spa_com /* FIXME we should call process_output on the node and see what its * status is */ for (i = 0; i < data->trans->area->max_input_ports; i++) - data->trans->inputs[i].status = SPA_RESULT_NEED_BUFFER; + data->trans->inputs[i].status = SPA_STATUS_NEED_BUFFER; node_need_input(data); pw_client_node_proxy_done(data->node_proxy, seq, res); @@ -785,7 +785,7 @@ static void client_node_command(void *object, uint32_t seq, const struct spa_com } else { pw_log_warn("unhandled node command %d", SPA_COMMAND_TYPE(command)); - pw_client_node_proxy_done(data->node_proxy, seq, SPA_RESULT_NOT_IMPLEMENTED); + pw_client_node_proxy_done(data->node_proxy, seq, -ENOTSUP); } } @@ -815,12 +815,12 @@ client_node_port_set_param(void *object, port = find_port(data, direction, port_id); if (port == NULL || port->port == NULL) { - res = SPA_RESULT_INVALID_PORT; + res = -EINVAL; goto done; } res = pw_port_set_param(port->port, id, flags, param); - if (res != SPA_RESULT_OK) + if (res < 0) goto done; add_port_update(proxy, port->port, @@ -925,7 +925,7 @@ client_node_port_use_buffers(void *object, port = find_port(data, direction, port_id); if (port == NULL) { - res = SPA_RESULT_INVALID_PORT; + res = -EINVAL; goto done; } @@ -1011,7 +1011,7 @@ client_node_port_use_buffers(void *object, map = mmap(NULL, d->maxsize + d->mapoffset, prot, MAP_SHARED, d->fd, 0); if (map == MAP_FAILED) { pw_log_error("data %d failed to mmap memory %m", j); - res = SPA_RESULT_ERROR; + res = errno; goto done; } d->data = SPA_MEMBER(map, d->mapoffset, uint8_t); @@ -1083,7 +1083,7 @@ static void do_node_init(struct pw_proxy *proxy) PW_CLIENT_NODE_PORT_UPDATE_PARAMS | PW_CLIENT_NODE_PORT_UPDATE_INFO); } - pw_client_node_proxy_done(data->node_proxy, 0, SPA_RESULT_OK); + pw_client_node_proxy_done(data->node_proxy, 0, 0); } static void node_destroy(void *data) @@ -1135,7 +1135,7 @@ static const struct pw_proxy_events proxy_events = { static int impl_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { pw_log_trace("node %p: reuse buffer %d %d", node, port_id, buffer_id); - return SPA_RESULT_OK; + return 0; } static int impl_process_input(struct spa_node *node) @@ -1143,7 +1143,7 @@ static int impl_process_input(struct spa_node *node) struct node_data *data = SPA_CONTAINER_OF(node, struct node_data, out_node_impl); pw_log_trace("node %p: process input", node); node_have_output(data); - return SPA_RESULT_OK; + return 0; } static int impl_process_output(struct spa_node *node) @@ -1151,7 +1151,7 @@ static int impl_process_output(struct spa_node *node) struct node_data *data = SPA_CONTAINER_OF(node, struct node_data, in_node_impl); pw_log_trace("node %p: process output", node); node_need_input(data); - return SPA_RESULT_OK; + return 0; } static const struct spa_node node_impl = { diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index 25ee5a0f2..e08838602 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -295,7 +295,7 @@ do_remove_sources(struct spa_loop *loop, close(impl->rtwritefd); impl->rtwritefd = -1; } - return SPA_RESULT_OK; + return 0; } static void unhandle_socket(struct pw_stream *stream) @@ -492,7 +492,7 @@ static void do_node_init(struct pw_stream *stream) add_port_update(stream, PW_CLIENT_NODE_PORT_UPDATE_PARAMS | PW_CLIENT_NODE_PORT_UPDATE_INFO); - add_async_complete(stream, 0, SPA_RESULT_OK); + add_async_complete(stream, 0, 0); if (!(impl->flags & PW_STREAM_FLAG_INACTIVE)) pw_client_node_proxy_set_active(impl->node_proxy, true); } @@ -570,7 +570,7 @@ static void handle_rtnode_message(struct pw_stream *stream, struct pw_client_nod if (impl->client_reuse) input->buffer_id = SPA_ID_INVALID; - if (input->status == SPA_RESULT_HAVE_BUFFER) { + if (input->status == SPA_STATUS_HAVE_BUFFER) { bid->used = true; impl->in_new_buffer = true; spa_hook_list_call(&stream->listener_list, struct pw_stream_events, @@ -578,7 +578,7 @@ static void handle_rtnode_message(struct pw_stream *stream, struct pw_client_nod impl->in_new_buffer = false; } - input->status = SPA_RESULT_NEED_BUFFER; + input->status = SPA_STATUS_NEED_BUFFER; } send_need_input(stream); } else if (PW_CLIENT_NODE_MESSAGE_TYPE(message) == PW_CLIENT_NODE_MESSAGE_PROCESS_OUTPUT) { @@ -631,7 +631,7 @@ on_rtsocket_condition(void *data, int fd, enum spa_io mask) if (read(fd, &cmd, sizeof(uint64_t)) != sizeof(uint64_t)) pw_log_warn("stream %p: read failed %m", impl); - while (pw_client_node_transport_next_message(impl->trans, &message) == SPA_RESULT_OK) { + while (pw_client_node_transport_next_message(impl->trans, &message) == 1) { struct pw_client_node_message *msg = alloca(SPA_POD_SIZE(&message)); pw_client_node_transport_parse_message(impl->trans, msg); handle_rtnode_message(stream, msg); @@ -676,7 +676,7 @@ static void client_node_command(void *data, uint32_t seq, const struct spa_comma struct pw_remote *remote = stream->remote; if (SPA_COMMAND_TYPE(command) == remote->core->type.command_node.Pause) { - add_async_complete(stream, seq, SPA_RESULT_OK); + add_async_complete(stream, seq, 0); if (stream->state == PW_STREAM_STATE_STREAMING) { pw_log_debug("stream %p: pause %d", stream, seq); @@ -687,7 +687,7 @@ static void client_node_command(void *data, uint32_t seq, const struct spa_comma stream_set_state(stream, PW_STREAM_STATE_PAUSED, NULL); } } else if (SPA_COMMAND_TYPE(command) == remote->core->type.command_node.Start) { - add_async_complete(stream, seq, SPA_RESULT_OK); + add_async_complete(stream, seq, 0); if (stream->state == PW_STREAM_STATE_PAUSED) { int i; @@ -700,7 +700,7 @@ static void client_node_command(void *data, uint32_t seq, const struct spa_comma if (impl->direction == SPA_DIRECTION_INPUT) { for (i = 0; i < impl->trans->area->max_input_ports; i++) - impl->trans->inputs[i].status = SPA_RESULT_NEED_BUFFER; + impl->trans->inputs[i].status = SPA_STATUS_NEED_BUFFER; send_need_input(stream); } else { @@ -725,7 +725,7 @@ static void client_node_command(void *data, uint32_t seq, const struct spa_comma impl->last_monotonic = cu->body.monotonic_time.value; } else { pw_log_warn("unhandled node command %d", SPA_COMMAND_TYPE(command)); - add_async_complete(stream, seq, SPA_RESULT_NOT_IMPLEMENTED); + add_async_complete(stream, seq, -ENOTSUP); } } @@ -912,7 +912,7 @@ client_node_port_use_buffers(void *data, spa_hook_list_call(&stream->listener_list, struct pw_stream_events, add_buffer, bid->id); } - add_async_complete(stream, seq, SPA_RESULT_OK); + add_async_complete(stream, seq, 0); if (n_buffers) stream_set_state(stream, PW_STREAM_STATE_PAUSED, NULL); @@ -1158,7 +1158,7 @@ bool pw_stream_send_buffer(struct pw_stream *stream, uint32_t id) bid->used = true; spa_list_remove(&bid->link); impl->trans->outputs[0].buffer_id = id; - impl->trans->outputs[0].status = SPA_RESULT_HAVE_BUFFER; + impl->trans->outputs[0].status = SPA_STATUS_HAVE_BUFFER; pw_log_trace("stream %p: send buffer %d", stream, id); if (!impl->in_need_buffer) send_have_output(stream); diff --git a/src/pipewire/thread-loop.c b/src/pipewire/thread-loop.c index 4e05cfa22..aa6368598 100644 --- a/src/pipewire/thread-loop.c +++ b/src/pipewire/thread-loop.c @@ -168,7 +168,7 @@ static void *do_loop(void *user_data) /** Start the thread to handle \a loop * * \param loop a \ref pw_thread_loop - * \return \ref SPA_RESULT_OK on success + * \return 0 on success * * \memberof pw_thread_loop */ @@ -182,10 +182,10 @@ int pw_thread_loop_start(struct pw_thread_loop *loop) pw_log_warn("thread-loop %p: can't create thread: %s", loop, strerror(err)); loop->running = false; - return SPA_RESULT_ERROR; + return -err; } } - return SPA_RESULT_OK; + return 0; } /** Quit the loop and stop its thread diff --git a/src/pipewire/work-queue.c b/src/pipewire/work-queue.c index df31e1365..773f43094 100644 --- a/src/pipewire/work-queue.c +++ b/src/pipewire/work-queue.c @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include @@ -58,7 +59,7 @@ static void process_work_queue(void *data, uint64_t count) continue; } - if (item->res == SPA_RESULT_WAIT_SYNC && + if (item->res == -EBUSY && item != spa_list_first(&this->work_list, struct work_item, link)) { pw_log_debug("work-queue %p: %d sync item %p not head", this, this->n_queued, item->obj); @@ -158,7 +159,7 @@ pw_work_queue_add(struct pw_work_queue *queue, void *obj, int res, pw_work_func_ item->seq = SPA_RESULT_ASYNC_SEQ(res); item->res = res; pw_log_debug("work-queue %p: defer async %d for object %p", queue, item->seq, obj); - } else if (res == SPA_RESULT_WAIT_SYNC) { + } else if (res == -EBUSY) { pw_log_debug("work-queue %p: wait sync object %p", queue, obj); item->seq = SPA_ID_INVALID; item->res = res;