link: remove error from method

We return a reason in errno
This commit is contained in:
Wim Taymans 2019-05-14 12:59:18 +02:00
parent 2889db8efb
commit 29164a0f54
4 changed files with 15 additions and 13 deletions

View file

@ -357,7 +357,6 @@ static void make_nodes(struct data *data)
pw_node_find_port(data->node, PW_DIRECTION_INPUT, 0), pw_node_find_port(data->node, PW_DIRECTION_INPUT, 0),
NULL, NULL,
NULL, NULL,
NULL,
0); 0);
pw_link_register(data->link, NULL, NULL, NULL); pw_link_register(data->link, NULL, NULL, NULL);

View file

@ -143,7 +143,6 @@ static void *create_object(void *_data,
uint32_t output_node_id, input_node_id; uint32_t output_node_id, input_node_id;
uint32_t output_port_id, input_port_id; uint32_t output_port_id, input_port_id;
struct link_data *ld; struct link_data *ld;
char *error;
const char *str; const char *str;
int res; int res;
bool linger; bool linger;
@ -210,7 +209,7 @@ static void *create_object(void *_data,
str = pw_properties_get(properties, "object.linger"); str = pw_properties_get(properties, "object.linger");
linger = str ? pw_properties_parse_bool(str) : false; linger = str ? pw_properties_parse_bool(str) : false;
link = pw_link_new(core, outport, inport, NULL, properties, &error, sizeof(struct link_data)); link = pw_link_new(core, outport, inport, NULL, properties, sizeof(struct link_data));
if (link == NULL) if (link == NULL)
goto no_mem; goto no_mem;
@ -265,8 +264,9 @@ static void *create_object(void *_data,
pw_resource_error(resource, -EINVAL, "unknown input port %u", input_port_id); pw_resource_error(resource, -EINVAL, "unknown input port %u", input_port_id);
goto done; goto done;
no_mem: no_mem:
pw_log_error("can't create link: %s", error); res = -errno;
pw_resource_error(resource, -ENOMEM, "can't create link: %s", error); pw_log_error("can't create link: %s", spa_strerror(res));
pw_resource_error(resource, res, "can't create link: %s", spa_strerror(res));
goto done; goto done;
no_bind: no_bind:
pw_resource_error(resource, res, "can't bind link"); pw_resource_error(resource, res, "can't bind link");

View file

@ -1241,7 +1241,6 @@ struct pw_link *pw_link_new(struct pw_core *core,
struct pw_port *input, struct pw_port *input,
struct spa_pod *format_filter, struct spa_pod *format_filter,
struct pw_properties *properties, struct pw_properties *properties,
char **error,
size_t user_data_size) size_t user_data_size)
{ {
struct impl *impl; struct impl *impl;
@ -1349,22 +1348,27 @@ struct pw_link *pw_link_new(struct pw_core *core,
return this; return this;
no_io: no_io:
asprintf(error, "can't set io %d (%s)", res, spa_strerror(res)); pw_log_error("can't set io %d (%s)", res, spa_strerror(res));
errno = -res;
return NULL; return NULL;
same_ports: same_ports:
asprintf(error, "can't link the same ports"); pw_log_error("can't link the same ports");
errno = EINVAL;
return NULL; return NULL;
wrong_direction: wrong_direction:
asprintf(error, "ports have wrong direction"); pw_log_error("ports have wrong direction");
errno = EINVAL;
return NULL; return NULL;
link_exists: link_exists:
asprintf(error, "link already exists"); pw_log_error("link already exists");
errno = EEXIST;
return NULL; return NULL;
link_not_allowed: link_not_allowed:
asprintf(error, "link not allowed"); pw_log_error("link not allowed");
errno = EPERM;
return NULL; return NULL;
no_mem: no_mem:
asprintf(error, "no memory"); pw_log_error("no memory");
return NULL; return NULL;
} }

View file

@ -85,7 +85,6 @@ pw_link_new(struct pw_core *core, /**< the core object */
struct pw_port *input, /**< an input port */ struct pw_port *input, /**< an input port */
struct spa_pod *format_filter, /**< an optional format filter */ struct spa_pod *format_filter, /**< an optional format filter */
struct pw_properties *properties /**< extra properties */, struct pw_properties *properties /**< extra properties */,
char **error, /**< error string when result is NULL */
size_t user_data_size /**< extra user data size */); size_t user_data_size /**< extra user data size */);
/** Destroy a link \memberof pw_link */ /** Destroy a link \memberof pw_link */