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

@ -83,7 +83,7 @@ static void *create_object(void *_data,
no_properties:
pw_log_error("needed properties: spa.library.name=<library-name> spa.factory.name=<factory-name>");
if (resource) {
pw_resource_error(resource, SPA_RESULT_INVALID_ARGUMENTS,
pw_resource_error(resource, -EINVAL,
"needed properties: "
"spa.library.name=<library-name> "
"spa.factory.name=<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;
}

View file

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

View file

@ -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");
}
}