avoid error(), it's not defined on musl

This commit is contained in:
Wim Taymans 2019-06-21 16:33:49 +02:00
parent 37e66c9e55
commit 0720e375a1
4 changed files with 51 additions and 36 deletions

View file

@ -18,7 +18,6 @@
*/
#include <math.h>
#include <error.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@ -45,6 +44,12 @@
static struct spa_log *logger;
#define spa_error(ret,res,msg) \
({ \
fprintf(stderr, "%s: %s", msg, spa_strerror(res)); \
return(ret); \
})
#define spa_debug(f,...) spa_log_trace(logger, f, __VA_ARGS__)
#include <spa/graph/graph.h>
@ -212,10 +217,11 @@ int main(int argc, char *argv[])
if ((res = get_handle(&data, &handle,
"build/spa/plugins/support/libspa-support.so",
"mapper")) < 0) {
error(-1, res, "can't create mapper");
spa_error(-1, res, "can't create mapper");
}
if ((res = spa_handle_get_interface(handle, 0, &iface)) < 0) {
spa_error(-1, res, "can't get mapper interface");
}
if ((res = spa_handle_get_interface(handle, 0, &iface)) < 0)
error(-1, res, "can't get mapper interface");
data.map = iface;
data.support[0].type = SPA_TYPE__TypeMap;
@ -226,13 +232,13 @@ int main(int argc, char *argv[])
if ((res = get_handle(&data, &handle,
"build/spa/plugins/support/libspa-support.so",
"logger")) < 0) {
error(-1, res, "can't create logger");
spa_error(-1, res, "can't create logger");
}
if ((res = spa_handle_get_interface(handle,
spa_type_map_get_id(data.map, SPA_TYPE__Log),
&iface)) < 0)
error(-1, res, "can't get log interface");
spa_error(-1, res, "can't get log interface");
data.log = iface;
data.support[1].type = SPA_TYPE__Log;
@ -245,24 +251,24 @@ int main(int argc, char *argv[])
if ((res = get_handle(&data, &handle,
"build/spa/plugins/support/libspa-support.so",
"loop")) < 0) {
error(-1, res, "can't create loop");
spa_error(-1, res, "can't create loop");
}
if ((res = spa_handle_get_interface(handle,
spa_type_map_get_id(data.map, SPA_TYPE__Loop),
&iface)) < 0)
error(-1, res, "can't get loop interface");
spa_error(-1, res, "can't get loop interface");
data.loop = iface;
if ((res = spa_handle_get_interface(handle,
spa_type_map_get_id(data.map, SPA_TYPE__LoopControl),
&iface)) < 0)
error(-1, res, "can't get loopcontrol interface");
spa_error(-1, res, "can't get loopcontrol interface");
data.loop_control = iface;
if ((res = spa_handle_get_interface(handle,
spa_type_map_get_id(data.map, SPA_TYPE__LoopUtils),
&iface)) < 0)
error(-1, res, "can't get looputils interface");
spa_error(-1, res, "can't get looputils interface");
data.loop_utils = iface;
data.support[2].type = SPA_TYPE_LOOP__DataLoop;
@ -278,13 +284,13 @@ int main(int argc, char *argv[])
if ((res = get_handle(&data, &handle,
"build/spa/plugins/support/libspa-dbus.so",
"dbus")) < 0) {
error(-1, res, "can't create dbus");
spa_error(-1, res, "can't create dbus");
}
if ((res = spa_handle_get_interface(handle,
spa_type_map_get_id(data.map, SPA_TYPE__DBus),
&iface)) < 0)
error(-1, res, "can't get dbus interface");
spa_error(-1, res, "can't get dbus interface");
data.dbus = iface;
data.support[6].type = SPA_TYPE__DBus;
@ -294,13 +300,13 @@ int main(int argc, char *argv[])
if ((res = get_handle(&data, &handle,
"build/spa/plugins/bluez5/libspa-bluez5.so",
"bluez5-monitor")) < 0) {
error(-1, res, "can't create bluez5-monitor");
spa_error(-1, res, "can't create bluez5-monitor");
}
if ((res = spa_handle_get_interface(handle,
spa_type_map_get_id(data.map, SPA_TYPE__Monitor),
&iface)) < 0)
error(-1, res, "can't get monitor interface");
spa_error(-1, res, "can't get monitor interface");
data.monitor = iface;

View file

@ -18,7 +18,6 @@
*/
#include <math.h>
#include <error.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@ -44,6 +43,12 @@
static SPA_TYPE_MAP_IMPL(default_map, 4096);
static SPA_LOG_IMPL(default_log);
#define spa_error(ret,res,msg) \
({ \
fprintf(stderr, "%s: %s", msg, spa_strerror(res)); \
return(ret); \
})
#define spa_debug(f,...) spa_log_trace(&default_log.log, f, __VA_ARGS__)
#include <spa/graph/graph.h>
@ -359,7 +364,7 @@ static int make_nodes(struct data *data, const char *device)
if ((res = spa_node_port_enum_params(data->source, SPA_DIRECTION_OUTPUT, 0,
data->type.param_io.idPropsIn, &idx, NULL, &param, &b)) < 1) {
if (res < 0)
error(0, -res, "port_enum_params");
spa_error(0, -res, "port_enum_params");
break;
}
@ -373,7 +378,7 @@ static int make_nodes(struct data *data, const char *device)
SPA_DIRECTION_OUTPUT, 0,
id,
&data->ctrl_source_freq, sizeof(data->ctrl_source_freq))) < 0)
error(0, -res, "set_io freq");
spa_error(0, -res, "set_io freq");
}
else if (propId == data->type.props_volume) {
@ -381,7 +386,7 @@ static int make_nodes(struct data *data, const char *device)
SPA_DIRECTION_OUTPUT, 0,
id,
&data->ctrl_source_volume, sizeof(data->ctrl_source_volume))) < 0)
error(0, -res, "set_io volume");
spa_error(0, -res, "set_io volume");
}
}

View file

@ -18,7 +18,6 @@
*/
#include <math.h>
#include <error.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@ -47,6 +46,12 @@
static SPA_TYPE_MAP_IMPL(default_map, 4096);
static SPA_LOG_IMPL(default_log);
#define spa_error(ret,res,msg) \
({ \
fprintf(stderr, "%s: %s", msg, spa_strerror(res)); \
return(ret); \
})
#define spa_debug(...) spa_log_trace(&default_log.log,__VA_ARGS__)
#include <spa/graph/graph.h>
@ -370,7 +375,7 @@ static int make_nodes(struct data *data, const char *device)
":", data->type.props_min_latency, "i", MIN_LATENCY);
if ((res = spa_node_set_param(data->sink, data->type.param.idProps, 0, props)) < 0)
error(0, -res, "set_param props");
spa_error(0, -res, "set_param props");
if ((res = make_node(data, &data->mix,
"build/spa/plugins/audiomixer/libspa-audiomixer.so",
@ -457,13 +462,13 @@ static int make_nodes(struct data *data, const char *device)
SPA_DIRECTION_INPUT, data->mix_ports[0],
data->type.io_inprop_volume,
&data->ctrl_volume[0], sizeof(data->ctrl_volume[0]))) < 0)
error(0, -res, "set_io volume 0");
spa_error(0, -res, "set_io volume 0");
if ((res = spa_node_port_set_io(data->mix,
SPA_DIRECTION_INPUT, data->mix_ports[1],
data->type.io_inprop_volume,
&data->ctrl_volume[1], sizeof(data->ctrl_volume[1]))) < 0)
error(0, -res, "set_io volume 1");
spa_error(0, -res, "set_io volume 1");
#ifdef USE_GRAPH

View file

@ -17,7 +17,6 @@
* Boston, MA 02110-1301, USA.
*/
#include <error.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@ -73,7 +72,7 @@ inspect_node_params(struct data *data, struct spa_node *node)
data->type.param.idList, &idx1,
NULL, &param, &b)) <= 0) {
if (res != 0)
error(0, -res, "enum_params");
printf("error enum_params: %s", spa_strerror(res));
break;
}
@ -88,7 +87,7 @@ inspect_node_params(struct data *data, struct spa_node *node)
id, &idx2,
NULL, &param, &b)) <= 0) {
if (res != 0)
error(0, -res, "enum_params %d", id);
printf("error enum_params %d: %s", id, spa_strerror(res));
break;
}
spa_debug_pod(0, data->map, param);
@ -115,7 +114,7 @@ inspect_port_params(struct data *data, struct spa_node *node,
data->type.param.idList, &idx1,
NULL, &param, &b)) <= 0) {
if (res != 0)
error(0, -res, "port_enum_params");
printf("error port_enum_params: %s", spa_strerror(res));
break;
}
spa_pod_object_parse(param,
@ -130,7 +129,7 @@ inspect_port_params(struct data *data, struct spa_node *node,
id, &idx2,
NULL, &param, &b)) <= 0) {
if (res != 0)
error(0, -res, "port_enum_params");
printf("error port_enum_params %d: %s", id, spa_strerror(res));
break;
}
@ -200,10 +199,10 @@ static void inspect_factory(struct data *data, const struct spa_handle_factory *
printf("factory interfaces:\n");
for (index = 0;;) {
if ((res = spa_handle_factory_enum_interface_info(factory, &info, &index)) <= 0) {
if (res == 0)
break;
else
error(0, -res, "spa_handle_factory_enum_interface_info");
if (res != 0)
printf("error spa_handle_factory_enum_interface_info: %s",
spa_strerror(res));
break;
}
printf(" interface: '%s'\n", info->type);
}
@ -221,10 +220,10 @@ static void inspect_factory(struct data *data, const struct spa_handle_factory *
uint32_t interface_id;
if ((res = spa_handle_factory_enum_interface_info(factory, &info, &index)) <= 0) {
if (res == 0)
break;
else
error(0, -res, "spa_handle_factory_enum_interface_info");
if (res != 0)
printf("error spa_handle_factory_enum_interface_info: %s",
spa_strerror(res));
break;
}
printf(" interface: '%s'\n", info->type);
@ -314,7 +313,7 @@ int main(int argc, char *argv[])
if ((res = enum_func(&factory, &index)) <= 0) {
if (res != 0)
error(0, -res, "enum_func");
printf("error enum_func: %s", spa_strerror(res));
break;
}
inspect_factory(&data, factory);