From e4cac644d20e75e8c1b706e42172613d112d8b73 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 6 Feb 2019 11:35:36 +0100 Subject: [PATCH] fix some compiler warnings with clang --- spa/include/spa/utils/defs.h | 2 ++ spa/include/spa/utils/hook.h | 2 +- spa/plugins/bluez5/bluez5-monitor.c | 2 +- spa/plugins/support/dbus.c | 2 +- spa/tests/test-v4l2.c | 4 +++- spa/tools/spa-inspect.c | 4 +++- spa/tools/spa-monitor.c | 4 +++- src/examples/export-sink.c | 4 +++- src/examples/export-source.c | 4 +++- src/examples/local-v4l2.c | 4 +++- src/examples/video-play.c | 4 +++- src/examples/video-src.c | 4 +++- src/modules/module-link-factory.c | 4 ++-- src/pipewire/control.c | 8 ++++---- src/pipewire/core.c | 12 +++++------- src/pipewire/link.c | 16 ++++++++-------- src/pipewire/node.c | 5 ++++- src/pipewire/port.c | 19 ++++++++++--------- src/pipewire/private.h | 1 + src/pipewire/remote.c | 8 ++++---- 20 files changed, 67 insertions(+), 46 deletions(-) diff --git a/spa/include/spa/utils/defs.h b/spa/include/spa/utils/defs.h index 86ad04e7e..8d2bbc6d9 100644 --- a/spa/include/spa/utils/defs.h +++ b/spa/include/spa/utils/defs.h @@ -51,6 +51,8 @@ enum spa_direction { SPA_DIRECTION_OUTPUT = 1, }; +#define SPA_DIRECTION_REVERSE(d) ((d) ^ 1) + #define SPA_RECTANGLE(width,height) (struct spa_rectangle){ width, height } struct spa_rectangle { uint32_t width; diff --git a/spa/include/spa/utils/hook.h b/spa/include/spa/utils/hook.h index dd04af9af..7685631af 100644 --- a/spa/include/spa/utils/hook.h +++ b/spa/include/spa/utils/hook.h @@ -101,7 +101,7 @@ static inline void spa_hook_remove(struct spa_hook *hook) ({ \ struct spa_hook_list *list = l; \ struct spa_list *s = start ? (struct spa_list *)start : &list->list; \ - struct spa_hook cursor = { 0 }, *ci; \ + struct spa_hook cursor = { { 0} }, *ci; \ int count = 0; \ spa_list_cursor_start(cursor, s, link); \ spa_list_for_each_cursor(ci, cursor, &list->list, link) { \ diff --git a/spa/plugins/bluez5/bluez5-monitor.c b/spa/plugins/bluez5/bluez5-monitor.c index 939aa70ed..140efa4d7 100644 --- a/spa/plugins/bluez5/bluez5-monitor.c +++ b/spa/plugins/bluez5/bluez5-monitor.c @@ -1215,7 +1215,7 @@ impl_init(const struct spa_handle_factory *factory, } init_type(&this->type, this->map); - this->dbus_connection = spa_dbus_get_connection(this->dbus, DBUS_BUS_SYSTEM); + this->dbus_connection = spa_dbus_get_connection(this->dbus, SPA_DBUS_TYPE_SYSTEM); if (this->dbus_connection == NULL) { spa_log_error(this->log, "no dbus connection"); return -EIO; diff --git a/spa/plugins/support/dbus.c b/spa/plugins/support/dbus.c index 8f9787352..ee4ed67bd 100644 --- a/spa/plugins/support/dbus.c +++ b/spa/plugins/support/dbus.c @@ -299,7 +299,7 @@ impl_get_connection(struct spa_dbus *dbus, conn = calloc(1, sizeof(struct connection)); conn->this = impl_connection; conn->impl = impl; - conn->conn = dbus_bus_get_private(type, &error); + conn->conn = dbus_bus_get_private((DBusBusType)type, &error); if (conn->conn == NULL) goto error; diff --git a/spa/tests/test-v4l2.c b/spa/tests/test-v4l2.c index 98ba7f5ac..ef3b06119 100644 --- a/spa/tests/test-v4l2.c +++ b/spa/tests/test-v4l2.c @@ -566,10 +566,12 @@ static void run_async_source(struct data *data) int main(int argc, char *argv[]) { - struct data data = { 0 }; + struct data data; int res; const char *str; + spa_zero(data); + data.use_buffer = true; data.map = &default_map.map; diff --git a/spa/tools/spa-inspect.c b/spa/tools/spa-inspect.c index 12b5cbb92..da41a82f0 100644 --- a/spa/tools/spa-inspect.c +++ b/spa/tools/spa-inspect.c @@ -261,13 +261,15 @@ static void do_remove_source(struct spa_source *source) int main(int argc, char *argv[]) { - struct data data = { 0 }; + struct data data; int res; void *handle; spa_handle_factory_enum_func_t enum_func; uint32_t index; const char *str; + spa_zero(data); + if (argc < 2) { printf("usage: %s \n", argv[0]); return -1; diff --git a/spa/tools/spa-monitor.c b/spa/tools/spa-monitor.c index 39e5c3831..9fb0049a0 100644 --- a/spa/tools/spa-monitor.c +++ b/spa/tools/spa-monitor.c @@ -163,12 +163,14 @@ static void handle_monitor(struct data *data, struct spa_monitor *monitor) int main(int argc, char *argv[]) { - struct data data = { 0 }; + struct data data; int res; void *handle; spa_handle_factory_enum_func_t enum_func; uint32_t fidx; + spa_zero(data); + data.map = &default_map.map; data.log = &default_log.log; data.main_loop.version = SPA_VERSION_LOOP; diff --git a/src/examples/export-sink.c b/src/examples/export-sink.c index 0aa916324..d34d3055f 100644 --- a/src/examples/export-sink.c +++ b/src/examples/export-sink.c @@ -643,7 +643,9 @@ static const struct pw_remote_events remote_events = { int main(int argc, char *argv[]) { - struct data data = { 0, }; + struct data data; + + spa_zero(data); pw_init(&argc, &argv); diff --git a/src/examples/export-source.c b/src/examples/export-source.c index d137d7c3d..e26722779 100644 --- a/src/examples/export-source.c +++ b/src/examples/export-source.c @@ -579,7 +579,9 @@ static const struct pw_remote_events remote_events = { int main(int argc, char *argv[]) { - struct data data = { 0, }; + struct data data; + + spa_zero(data); pw_init(&argc, &argv); diff --git a/src/examples/local-v4l2.c b/src/examples/local-v4l2.c index f5915a71d..d22d4dd8a 100644 --- a/src/examples/local-v4l2.c +++ b/src/examples/local-v4l2.c @@ -499,7 +499,9 @@ static void make_nodes(struct data *data) int main(int argc, char *argv[]) { - struct data data = { 0, }; + struct data data; + + spa_zero(data); pw_init(&argc, &argv); diff --git a/src/examples/video-play.c b/src/examples/video-play.c index 7ba9034ee..22312fad7 100644 --- a/src/examples/video-play.c +++ b/src/examples/video-play.c @@ -494,7 +494,9 @@ static int get_fd(struct data *data) int main(int argc, char *argv[]) { - struct data data = { 0, }; + struct data data; + + spa_zero(data); pw_init(&argc, &argv); diff --git a/src/examples/video-src.c b/src/examples/video-src.c index dbc639fde..acefe1d41 100644 --- a/src/examples/video-src.c +++ b/src/examples/video-src.c @@ -323,7 +323,9 @@ static const struct pw_remote_events remote_events = { int main(int argc, char *argv[]) { - struct data data = { 0, }; + struct data data; + + spa_zero(data); pw_init(&argc, &argv); diff --git a/src/modules/module-link-factory.c b/src/modules/module-link-factory.c index d9eeed6cf..15069084b 100644 --- a/src/modules/module-link-factory.c +++ b/src/modules/module-link-factory.c @@ -96,7 +96,7 @@ static void *create_object(void *_data, input_node = pw_global_get_object(global); if (output_port_id == -1) - outport = pw_node_get_free_port(output_node, SPA_DIRECTION_OUTPUT); + outport = pw_node_get_free_port(output_node, PW_DIRECTION_OUTPUT); else { global = pw_core_find_global(core, output_port_id); if (global == NULL || pw_global_get_type(global) != t->port) @@ -108,7 +108,7 @@ static void *create_object(void *_data, goto no_output_port; if (input_port_id == -1) - inport = pw_node_get_free_port(input_node, SPA_DIRECTION_INPUT); + inport = pw_node_get_free_port(input_node, PW_DIRECTION_INPUT); else { global = pw_core_find_global(core, input_port_id); if (global == NULL || pw_global_get_type(global) != t->port) diff --git a/src/pipewire/control.c b/src/pipewire/control.c index 747fa1ac9..e09cf233f 100644 --- a/src/pipewire/control.c +++ b/src/pipewire/control.c @@ -169,7 +169,7 @@ int pw_control_link(struct pw_control *control, struct pw_control *other) if (other->port) { struct pw_port *port = other->port; if ((res = spa_node_port_set_io(port->node->node, - port->direction, port->port_id, + port->spa_direction, port->port_id, other->id, impl->mem->ptr, control->size)) < 0) { goto exit; @@ -180,7 +180,7 @@ int pw_control_link(struct pw_control *control, struct pw_control *other) if (control->port) { struct pw_port *port = control->port; if ((res = spa_node_port_set_io(port->node->node, - port->direction, port->port_id, + port->spa_direction, port->port_id, control->id, impl->mem->ptr, control->size)) < 0) { goto exit; @@ -222,7 +222,7 @@ int pw_control_unlink(struct pw_control *control, struct pw_control *other) if (spa_list_is_empty(&control->inputs)) { struct pw_port *port = control->port; if ((res = spa_node_port_set_io(port->node->node, - port->direction, port->port_id, + port->spa_direction, port->port_id, control->id, NULL, 0)) < 0) { pw_log_warn("control %p: can't unset port control io", control); } @@ -231,7 +231,7 @@ int pw_control_unlink(struct pw_control *control, struct pw_control *other) if (other->port) { struct pw_port *port = other->port; if ((res = spa_node_port_set_io(port->node->node, - port->direction, port->port_id, + port->spa_direction, port->port_id, other->id, NULL, 0)) < 0) { pw_log_warn("control %p: can't unset port control io", control); } diff --git a/src/pipewire/core.c b/src/pipewire/core.c index 3d989e347..07c6581a7 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -662,9 +662,7 @@ struct pw_port *pw_core_find_port(struct pw_core *core, pw_log_debug("id \"%u\" matches node %p", id, n); best = - pw_node_get_free_port(n, - pw_direction_reverse(other_port-> - direction)); + pw_node_get_free_port(n, pw_direction_reverse(other_port->direction)); if (best) break; } @@ -752,7 +750,7 @@ int pw_core_find_format(struct pw_core *core, if (in_state == PW_PORT_STATE_CONFIGURE && out_state > PW_PORT_STATE_CONFIGURE) { /* only input needs format */ if ((res = spa_node_port_enum_params(output->node->node, - output->direction, output->port_id, + output->spa_direction, output->port_id, t->param.idFormat, &oidx, NULL, format, builder)) <= 0) { if (res == 0) @@ -763,7 +761,7 @@ int pw_core_find_format(struct pw_core *core, } else if (out_state == PW_PORT_STATE_CONFIGURE && in_state > PW_PORT_STATE_CONFIGURE) { /* only output needs format */ if ((res = spa_node_port_enum_params(input->node->node, - input->direction, input->port_id, + input->spa_direction, input->port_id, t->param.idFormat, &iidx, NULL, format, builder)) <= 0) { if (res == 0) @@ -780,7 +778,7 @@ int pw_core_find_format(struct pw_core *core, pw_log_debug("core %p: do enum input %d", core, iidx); spa_pod_builder_init(&fb, fbuf, sizeof(fbuf)); if ((res = spa_node_port_enum_params(input->node->node, - input->direction, input->port_id, + input->spa_direction, input->port_id, t->param.idEnumFormat, &iidx, NULL, &filter, &fb)) <= 0) { if (res == 0 && iidx == 0) { @@ -795,7 +793,7 @@ int pw_core_find_format(struct pw_core *core, spa_debug_format(2, core->type.map, filter); if ((res = spa_node_port_enum_params(output->node->node, - output->direction, output->port_id, + output->spa_direction, output->port_id, t->param.idEnumFormat, &oidx, filter, format, builder)) <= 0) { if (res == 0) { diff --git a/src/pipewire/link.c b/src/pipewire/link.c index ab35f05b5..b0b78bfd5 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -146,7 +146,7 @@ static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_st if (out_state > PW_PORT_STATE_CONFIGURE && output->node->info.state == PW_NODE_STATE_IDLE) { if ((res = spa_node_port_enum_params(output->node->node, - output->direction, output->port_id, + output->spa_direction, output->port_id, t->param.idFormat, &index, NULL, ¤t, &b)) <= 0) { if (res == 0) @@ -167,7 +167,7 @@ static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_st } if (in_state > PW_PORT_STATE_CONFIGURE && input->node->info.state == PW_NODE_STATE_IDLE) { if ((res = spa_node_port_enum_params(input->node->node, - input->direction, input->port_id, + input->spa_direction, input->port_id, t->param.idFormat, &index, NULL, ¤t, &b)) <= 0) { if (res == 0) @@ -447,7 +447,7 @@ param_filter(struct pw_link *this, spa_pod_builder_init(&ib, ibuf, sizeof(ibuf)); pw_log_debug("iparam %d", iidx); if ((res = spa_node_port_enum_params(in_port->node->node, - in_port->direction, in_port->port_id, + in_port->spa_direction, in_port->port_id, id, &iidx, NULL, &iparam, &ib)) < 0) break; @@ -462,7 +462,7 @@ param_filter(struct pw_link *this, for (oidx = 0;;) { pw_log_debug("oparam %d", oidx); - if (spa_node_port_enum_params(out_port->node->node, out_port->direction, + if (spa_node_port_enum_params(out_port->node->node, out_port->spa_direction, out_port->port_id, id, &oidx, iparam, &oparam, result) <= 0) { break; @@ -500,12 +500,12 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s pw_log_debug("link %p: doing alloc buffers %p %p", this, output->node, input->node); /* find out what's possible */ - if ((res = spa_node_port_get_info(output->node->node, output->direction, output->port_id, + if ((res = spa_node_port_get_info(output->node->node, output->spa_direction, output->port_id, &oinfo)) < 0) { asprintf(&error, "error get output port info: %d", res); goto error; } - if ((res = spa_node_port_get_info(input->node->node, input->direction, input->port_id, + if ((res = spa_node_port_get_info(input->node->node, input->spa_direction, input->port_id, &iinfo)) < 0) { asprintf(&error, "error get input port info: %d", res); goto error; @@ -1170,12 +1170,12 @@ struct pw_link *pw_link_new(struct pw_core *core, input_node, input->port_id, this->rt.in_port.port_id); spa_graph_port_init(&this->rt.out_port, - PW_DIRECTION_OUTPUT, + SPA_DIRECTION_OUTPUT, this->rt.out_port.port_id, SPA_GRAPH_PORT_FLAG_DISABLED, &this->io); spa_graph_port_init(&this->rt.in_port, - PW_DIRECTION_INPUT, + SPA_DIRECTION_INPUT, this->rt.in_port.port_id, SPA_GRAPH_PORT_FLAG_DISABLED, &this->io); diff --git a/src/pipewire/node.c b/src/pipewire/node.c index 38f4c8a9d..e5a1fc110 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -783,7 +783,10 @@ struct pw_port *pw_node_get_free_port(struct pw_node *node, enum pw_direction di pw_log_debug("node %p: creating port direction %d %u", node, direction, port_id); - if ((res = spa_node_add_port(node->node, direction, port_id)) < 0) { + if ((res = spa_node_add_port(node->node, + direction == PW_DIRECTION_INPUT ? + SPA_DIRECTION_INPUT : SPA_DIRECTION_OUTPUT, + port_id)) < 0) { pw_log_error("node %p: could not add port %d %s", node, port_id, spa_strerror(res)); goto no_mem; } diff --git a/src/pipewire/port.c b/src/pipewire/port.c index e3db4e0eb..da5065b86 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -182,6 +182,7 @@ struct pw_port *pw_port_new(enum pw_direction direction, goto no_mem; this->direction = direction; + this->spa_direction = direction == PW_DIRECTION_INPUT ? SPA_DIRECTION_INPUT : SPA_DIRECTION_OUTPUT; this->port_id = port_id; this->properties = properties; this->state = PW_PORT_STATE_INIT; @@ -201,7 +202,7 @@ struct pw_port *pw_port_new(enum pw_direction direction, spa_hook_list_init(&this->listener_list); spa_graph_port_init(&this->rt.port, - this->direction, + this->spa_direction, this->port_id, 0, &this->io); @@ -214,7 +215,7 @@ struct pw_port *pw_port_new(enum pw_direction direction, pw_map_init(&this->mix_port_map, 64, 64); spa_graph_port_init(&this->rt.mix_port, - pw_direction_reverse(this->direction), + SPA_DIRECTION_REVERSE(this->spa_direction), 0, 0, &this->io); @@ -422,7 +423,7 @@ int pw_port_add(struct pw_port *port, struct pw_node *node) port->node = node; spa_node_port_get_info(node->node, - port->direction, port_id, + port->spa_direction, port_id, &port->spa_info); if (port->spa_info->props) @@ -459,7 +460,7 @@ int pw_port_add(struct pw_port *port, struct pw_node *node) pw_log_debug("port %p: setting node io", port); spa_node_port_set_io(node->node, - port->direction, port_id, + port->spa_direction, port_id, t->io.Buffers, port->rt.port.io, sizeof(*port->rt.port.io)); @@ -575,7 +576,7 @@ do_port_command(struct spa_loop *loop, { struct pw_port *port = user_data; struct pw_node *node = port->node; - return spa_node_port_send_command(node->node, port->direction, port->port_id, data); + return spa_node_port_send_command(node->node, port->spa_direction, port->port_id, data); } int pw_port_send_command(struct pw_port *port, bool block, const struct spa_command *command) @@ -607,7 +608,7 @@ int pw_port_for_each_param(struct pw_port *port, spa_pod_builder_init(&b, buf, sizeof(buf)); idx = index; if ((res = spa_node_port_enum_params(node->node, - port->direction, port->port_id, + port->spa_direction, port->port_id, param_id, &index, filter, ¶m, &b)) <= 0) break; @@ -664,7 +665,7 @@ int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags, struct pw_core *core = node->core; struct pw_type *t = &core->type; - res = spa_node_port_set_param(node->node, port->direction, port->port_id, id, flags, param); + res = spa_node_port_set_param(node->node, port->spa_direction, port->port_id, id, flags, param); pw_log_debug("port %p: set param %s: %d (%s)", port, spa_type_map_get_type(t->map, id), res, spa_strerror(res)); @@ -692,7 +693,7 @@ int pw_port_use_buffers(struct pw_port *port, struct spa_buffer **buffers, uint3 if (n_buffers > 0 && port->state < PW_PORT_STATE_READY) return -EIO; - res = spa_node_port_use_buffers(node->node, port->direction, port->port_id, buffers, n_buffers); + res = spa_node_port_use_buffers(node->node, port->spa_direction, port->port_id, buffers, n_buffers); pw_log_debug("port %p: use %d buffers: %d (%s)", port, n_buffers, res, spa_strerror(res)); port->allocated = false; @@ -722,7 +723,7 @@ int pw_port_alloc_buffers(struct pw_port *port, if (port->state < PW_PORT_STATE_READY) return -EIO; - res = spa_node_port_alloc_buffers(node->node, port->direction, port->port_id, + res = spa_node_port_alloc_buffers(node->node, port->spa_direction, port->port_id, params, n_params, buffers, n_buffers); pw_log_debug("port %p: alloc %d buffers: %d (%s)", port, *n_buffers, res, spa_strerror(res)); diff --git a/src/pipewire/private.h b/src/pipewire/private.h index a9b189af6..17e8884bf 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -383,6 +383,7 @@ struct pw_port { bool registered; enum pw_direction direction; /**< port direction */ + enum spa_direction spa_direction;/**< port direction */ uint32_t port_id; /**< port id */ const struct spa_port_info *spa_info; diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c index c19f3512d..6b93d841e 100644 --- a/src/pipewire/remote.c +++ b/src/pipewire/remote.c @@ -784,7 +784,7 @@ static void add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32 spa_pod_builder_init(&b, buf, sizeof(buf)); if (spa_node_port_enum_params(port->node->node, - port->direction, port->port_id, + port->spa_direction, port->port_id, data->t->param.idList, &idx1, NULL, ¶m, &b) <= 0) break; @@ -795,7 +795,7 @@ static void add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32 for (idx2 = 0;; n_params++) { spa_pod_builder_init(&b, buf, sizeof(buf)); if (spa_node_port_enum_params(port->node->node, - port->direction, port->port_id, + port->spa_direction, port->port_id, id, &idx2, NULL, ¶m, &b) <= 0) break; @@ -806,13 +806,13 @@ static void add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32 } } if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_INFO) { - spa_node_port_get_info(port->node->node, port->direction, port->port_id, &port_info); + spa_node_port_get_info(port->node->node, port->spa_direction, port->port_id, &port_info); pi = * port_info; pi.flags &= ~SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS; } pw_client_node_proxy_port_update(data->node_proxy, - port->direction, + port->spa_direction, port->port_id, change_mask, n_params,