summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2019-05-14 12:59:18 +0200
committerWim Taymans <wtaymans@redhat.com>2019-05-14 12:59:18 +0200
commit29164a0f54e0fbbeb5faad1d0557f99e32e86fae (patch)
tree360fa646488dc7ed1ba65d1b487ddedeeb3debb3 /src
parent2889db8efbb79423983a121b26baaff9f248eb26 (diff)
link: remove error from method
We return a reason in errno
Diffstat (limited to 'src')
-rw-r--r--src/examples/local-v4l2.c1
-rw-r--r--src/modules/module-link-factory.c8
-rw-r--r--src/pipewire/link.c18
-rw-r--r--src/pipewire/link.h1
4 files changed, 15 insertions, 13 deletions
diff --git a/src/examples/local-v4l2.c b/src/examples/local-v4l2.c
index 4cd5de85..6d5e3f93 100644
--- a/src/examples/local-v4l2.c
+++ b/src/examples/local-v4l2.c
@@ -357,7 +357,6 @@ static void make_nodes(struct data *data)
pw_node_find_port(data->node, PW_DIRECTION_INPUT, 0),
NULL,
NULL,
- NULL,
0);
pw_link_register(data->link, NULL, NULL, NULL);
diff --git a/src/modules/module-link-factory.c b/src/modules/module-link-factory.c
index d40315df..1498fc8c 100644
--- a/src/modules/module-link-factory.c
+++ b/src/modules/module-link-factory.c
@@ -143,7 +143,6 @@ static void *create_object(void *_data,
uint32_t output_node_id, input_node_id;
uint32_t output_port_id, input_port_id;
struct link_data *ld;
- char *error;
const char *str;
int res;
bool linger;
@@ -210,7 +209,7 @@ static void *create_object(void *_data,
str = pw_properties_get(properties, "object.linger");
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)
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);
goto done;
no_mem:
- pw_log_error("can't create link: %s", error);
- pw_resource_error(resource, -ENOMEM, "can't create link: %s", error);
+ res = -errno;
+ 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;
no_bind:
pw_resource_error(resource, res, "can't bind link");
diff --git a/src/pipewire/link.c b/src/pipewire/link.c
index 2e48d978..eecfbe1a 100644
--- a/src/pipewire/link.c
+++ b/src/pipewire/link.c
@@ -1241,7 +1241,6 @@ struct pw_link *pw_link_new(struct pw_core *core,
struct pw_port *input,
struct spa_pod *format_filter,
struct pw_properties *properties,
- char **error,
size_t user_data_size)
{
struct impl *impl;
@@ -1349,22 +1348,27 @@ struct pw_link *pw_link_new(struct pw_core *core,
return this;
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;
same_ports:
- asprintf(error, "can't link the same ports");
+ pw_log_error("can't link the same ports");
+ errno = EINVAL;
return NULL;
wrong_direction:
- asprintf(error, "ports have wrong direction");
+ pw_log_error("ports have wrong direction");
+ errno = EINVAL;
return NULL;
link_exists:
- asprintf(error, "link already exists");
+ pw_log_error("link already exists");
+ errno = EEXIST;
return NULL;
link_not_allowed:
- asprintf(error, "link not allowed");
+ pw_log_error("link not allowed");
+ errno = EPERM;
return NULL;
no_mem:
- asprintf(error, "no memory");
+ pw_log_error("no memory");
return NULL;
}
diff --git a/src/pipewire/link.h b/src/pipewire/link.h
index 45f3d4ea..764d2ebd 100644
--- a/src/pipewire/link.h
+++ b/src/pipewire/link.h
@@ -85,7 +85,6 @@ pw_link_new(struct pw_core *core, /**< the core object */
struct pw_port *input, /**< an input port */
struct spa_pod *format_filter, /**< an optional format filter */
struct pw_properties *properties /**< extra properties */,
- char **error, /**< error string when result is NULL */
size_t user_data_size /**< extra user data size */);
/** Destroy a link \memberof pw_link */