Use errno for result errors

Make new enumeration for data transport status and use errno
style error numbers for errors.
This commit is contained in:
Wim Taymans 2017-11-13 09:41:41 +01:00
parent dda28b1589
commit 6fb0f580ea
86 changed files with 2019 additions and 1988 deletions

View file

@ -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)