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

@ -175,7 +175,7 @@ static Uint32 id_to_sdl_format(struct data *data, uint32_t id)
static int impl_send_command(struct spa_node *node, const struct spa_command *command)
{
return SPA_RESULT_OK;
return 0;
}
static int impl_set_callbacks(struct spa_node *node,
@ -184,7 +184,7 @@ static int impl_set_callbacks(struct spa_node *node,
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
d->callbacks = callbacks;
d->callbacks_data = data;
return SPA_RESULT_OK;
return 0;
}
static int impl_get_n_ports(struct spa_node *node,
@ -195,7 +195,7 @@ static int impl_get_n_ports(struct spa_node *node,
{
*n_input_ports = *max_input_ports = 1;
*n_output_ports = *max_output_ports = 0;
return SPA_RESULT_OK;
return 0;
}
static int impl_get_port_ids(struct spa_node *node,
@ -206,7 +206,7 @@ static int impl_get_port_ids(struct spa_node *node,
{
if (n_input_ports > 0)
input_ids[0] = 0;
return SPA_RESULT_OK;
return 0;
}
static int impl_port_set_io(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
@ -214,7 +214,7 @@ static int impl_port_set_io(struct spa_node *node, enum spa_direction direction,
{
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
d->io = io;
return SPA_RESULT_OK;
return 0;
}
static int impl_port_get_info(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
@ -228,7 +228,7 @@ static int impl_port_get_info(struct spa_node *node, enum spa_direction directio
*info = &d->port_info;
return SPA_RESULT_OK;
return 0;
}
static int port_enum_formats(struct spa_node *node,
@ -242,7 +242,7 @@ static int port_enum_formats(struct spa_node *node,
int i, c;
if (*index != 0)
return SPA_RESULT_ENUM_END;
return 0;
SDL_GetRendererInfo(d->renderer, &info);
@ -284,7 +284,7 @@ static int port_enum_formats(struct spa_node *node,
(*index)++;
return SPA_RESULT_OK;
return 1;
}
static int impl_port_enum_params(struct spa_node *node,
@ -301,7 +301,7 @@ static int impl_port_enum_params(struct spa_node *node,
}
else if (id == t->param.idBuffers) {
if (*index > 0)
return SPA_RESULT_ENUM_END;
return 0;
spa_pod_builder_object(builder,
id, t->param_buffers.Buffers,
@ -313,7 +313,7 @@ static int impl_port_enum_params(struct spa_node *node,
}
else if (id == t->param.idMeta) {
if (*index > 0)
return SPA_RESULT_ENUM_END;
return 0;
spa_pod_builder_object(builder,
id, t->param_meta.Meta,
@ -321,10 +321,10 @@ static int impl_port_enum_params(struct spa_node *node,
":", t->param_meta.size, "i", sizeof(struct spa_meta_header));
}
else
return SPA_RESULT_UNKNOWN_PARAM;
return -ENOENT;
(*index)++;
return SPA_RESULT_OK;
return 1;
}
static int port_set_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
@ -335,7 +335,7 @@ static int port_set_format(struct spa_node *node, enum spa_direction direction,
void *dest;
if (format == NULL)
return SPA_RESULT_OK;
return 0;
spa_debug_pod(&format->pod, SPA_DEBUG_FLAG_FORMAT);
@ -343,7 +343,7 @@ static int port_set_format(struct spa_node *node, enum spa_direction direction,
sdl_format = id_to_sdl_format(d, d->format.format);
if (sdl_format == SDL_PIXELFORMAT_UNKNOWN)
return SPA_RESULT_ERROR;
return -EINVAL;
d->texture = SDL_CreateTexture(d->renderer,
sdl_format,
@ -353,7 +353,7 @@ static int port_set_format(struct spa_node *node, enum spa_direction direction,
SDL_LockTexture(d->texture, NULL, &dest, &d->stride);
SDL_UnlockTexture(d->texture);
return SPA_RESULT_OK;
return 0;
}
static int impl_port_set_param(struct spa_node *node,
@ -368,7 +368,7 @@ static int impl_port_set_param(struct spa_node *node,
return port_set_format(node, direction, port_id, flags, param);
}
else
return SPA_RESULT_UNKNOWN_PARAM;
return -ENOENT;
}
static int impl_port_use_buffers(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
@ -379,7 +379,7 @@ static int impl_port_use_buffers(struct spa_node *node, enum spa_direction direc
for (i = 0; i < n_buffers; i++)
d->buffers[i] = buffers[i];
d->n_buffers = n_buffers;
return SPA_RESULT_OK;
return 0;
}
static int impl_node_process_input(struct spa_node *node)
@ -403,11 +403,11 @@ static int impl_node_process_input(struct spa_node *node)
map = NULL;
sdata = buf->datas[0].data;
} else
return SPA_RESULT_ERROR;
return -EINVAL;
if (SDL_LockTexture(d->texture, NULL, &ddata, &dstride) < 0) {
fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError());
return SPA_RESULT_ERROR;
return -EIO;
}
sstride = buf->datas[0].chunk->stride;
ostride = SPA_MIN(sstride, dstride);
@ -430,9 +430,9 @@ static int impl_node_process_input(struct spa_node *node)
handle_events(d);
d->io->status = SPA_RESULT_NEED_BUFFER;
d->io->status = SPA_STATUS_NEED_BUFFER;
return SPA_RESULT_NEED_BUFFER;
return SPA_STATUS_NEED_BUFFER;
}
static const struct spa_node impl_node = {