mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-24 09:05:54 -04:00
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:
parent
dda28b1589
commit
6fb0f580ea
86 changed files with 2019 additions and 1988 deletions
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
|
@ -137,8 +138,8 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
uint32_t offset;
|
||||
struct spa_pod *param;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -148,7 +149,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
next:
|
||||
if (id == t->param.idList) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param.List,
|
||||
|
|
@ -156,14 +157,14 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
}
|
||||
else if (id == t->param.idProps) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->props,
|
||||
":", t->prop_live, "b", this->props.live);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -171,7 +172,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
|
|
@ -180,7 +181,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
|
@ -188,7 +189,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
if (id == t->param.idProps) {
|
||||
if (param == NULL) {
|
||||
reset_props(this, &this->props);
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
spa_pod_object_parse(param,
|
||||
":", t->prop_live, "?b", &this->props.live, NULL);
|
||||
|
|
@ -199,9 +200,9 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
this->info.flags &= ~SPA_PORT_INFO_FLAG_LIVE;
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
|
|
@ -247,13 +248,13 @@ static int consume_buffer(struct impl *this)
|
|||
read_timer(this);
|
||||
|
||||
if (spa_list_is_empty(&this->ready)) {
|
||||
io->status = SPA_RESULT_NEED_BUFFER;
|
||||
io->status = SPA_STATUS_NEED_BUFFER;
|
||||
if (this->callbacks->need_input)
|
||||
this->callbacks->need_input(this->callbacks_data);
|
||||
}
|
||||
if (spa_list_is_empty(&this->ready)) {
|
||||
spa_log_error(this->log, NAME " %p: no buffers", this);
|
||||
return SPA_RESULT_NEED_BUFFER;
|
||||
return -EPIPE;
|
||||
}
|
||||
|
||||
b = spa_list_first(&this->ready, struct buffer, link);
|
||||
|
|
@ -280,10 +281,10 @@ static int consume_buffer(struct impl *this)
|
|||
set_timer(this, true);
|
||||
|
||||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_NEED_BUFFER;
|
||||
io->status = SPA_STATUS_NEED_BUFFER;
|
||||
b->outstanding = true;
|
||||
|
||||
return SPA_RESULT_NEED_BUFFER;
|
||||
return SPA_STATUS_NEED_BUFFER;
|
||||
}
|
||||
|
||||
static void on_input(struct spa_source *source)
|
||||
|
|
@ -297,8 +298,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(command != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -306,13 +307,12 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
struct timespec now;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if (this->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
if (this->props.live)
|
||||
|
|
@ -326,20 +326,19 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
set_timer(this, true);
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return -EIO;
|
||||
|
||||
if (!this->started)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
this->started = false;
|
||||
set_timer(this, false);
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -349,18 +348,18 @@ impl_node_set_callbacks(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks != NULL && callbacks->need_input != NULL) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
this->callbacks = callbacks;
|
||||
this->callbacks_data = data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -370,7 +369,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
|
|
@ -381,7 +380,7 @@ impl_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -391,23 +390,23 @@ impl_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
if (n_input_ports > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -418,16 +417,16 @@ impl_node_port_get_info(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
*info = &this->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
|
|
@ -437,7 +436,7 @@ static int port_enum_formats(struct spa_node *node,
|
|||
struct spa_pod_builder *builder,
|
||||
struct spa_pod **param)
|
||||
{
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
|
|
@ -450,14 +449,14 @@ static int port_get_format(struct spa_node *node,
|
|||
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = SPA_MEMBER(this->format_buffer, 0, struct spa_pod);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -473,14 +472,14 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
struct spa_pod *param;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(builder != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
offset = builder->offset;
|
||||
|
||||
|
|
@ -495,19 +494,19 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
param = spa_pod_builder_object(builder, id, t->param.List,
|
||||
":", t->param.listId, "I", list[*index]);
|
||||
else
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
else if (id == t->param.idEnumFormat) {
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) <= 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idBuffers) {
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param_buffers.Buffers,
|
||||
|
|
@ -526,11 +525,11 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
":", t->param_meta.size, "i", sizeof(struct spa_meta_header));
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -538,7 +537,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0)
|
||||
goto next;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int clear_buffers(struct impl *this)
|
||||
|
|
@ -550,7 +549,7 @@ static int clear_buffers(struct impl *this)
|
|||
this->started = false;
|
||||
set_timer(this, false);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_set_format(struct spa_node *node,
|
||||
|
|
@ -565,11 +564,11 @@ static int port_set_format(struct spa_node *node,
|
|||
clear_buffers(this);
|
||||
} else {
|
||||
if (SPA_POD_SIZE(format) > sizeof(this->format_buffer))
|
||||
return SPA_RESULT_ERROR;
|
||||
return -ENOSPC;
|
||||
memcpy(this->format_buffer, format, SPA_POD_SIZE(format));
|
||||
this->have_format = true;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -581,18 +580,18 @@ impl_node_port_set_param(struct spa_node *node,
|
|||
struct impl *this;
|
||||
struct type *t;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
t = &this->type;
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (id == t->param.idFormat) {
|
||||
return port_set_format(node, direction, port_id, flags, param);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -605,14 +604,14 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
clear_buffers(this);
|
||||
|
||||
|
|
@ -634,7 +633,7 @@ impl_node_port_use_buffers(struct spa_node *node,
|
|||
}
|
||||
this->n_buffers = n_buffers;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -648,16 +647,16 @@ impl_node_port_alloc_buffers(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -668,20 +667,20 @@ impl_node_port_set_io(struct spa_node *node,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
this->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -690,7 +689,7 @@ impl_node_port_send_command(struct spa_node *node,
|
|||
uint32_t port_id,
|
||||
const struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
|
|
@ -698,20 +697,20 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
struct impl *this;
|
||||
struct spa_port_io *input;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
input = this->io;
|
||||
spa_return_val_if_fail(input != NULL, SPA_RESULT_UNEXPECTED);
|
||||
spa_return_val_if_fail(input != NULL, -EIO);
|
||||
|
||||
if (input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id < this->n_buffers) {
|
||||
if (input->status == SPA_STATUS_HAVE_BUFFER && input->buffer_id < this->n_buffers) {
|
||||
struct buffer *b = &this->buffers[input->buffer_id];
|
||||
|
||||
if (!b->outstanding) {
|
||||
spa_log_warn(this->log, NAME " %p: buffer %u in use", this,
|
||||
input->buffer_id);
|
||||
input->status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
return SPA_RESULT_ERROR;
|
||||
input->status = -EINVAL;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
spa_log_trace(this->log, NAME " %p: queue buffer %u", this, input->buffer_id);
|
||||
|
|
@ -720,17 +719,17 @@ static int impl_node_process_input(struct spa_node *node)
|
|||
b->outstanding = false;
|
||||
|
||||
input->buffer_id = SPA_ID_INVALID;
|
||||
input->status = SPA_RESULT_OK;
|
||||
input->status = SPA_STATUS_OK;
|
||||
}
|
||||
if (this->callbacks == NULL || this->callbacks->need_input == NULL)
|
||||
return consume_buffer(this);
|
||||
else
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_STATUS_OK;
|
||||
}
|
||||
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static const struct spa_node impl_node = {
|
||||
|
|
@ -759,13 +758,13 @@ static const struct spa_node impl_node = {
|
|||
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_clock_set_param(struct spa_clock *clock, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -777,7 +776,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
struct timespec now;
|
||||
uint64_t tnow;
|
||||
|
||||
spa_return_val_if_fail(clock != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(clock != NULL, -EINVAL);
|
||||
|
||||
if (rate)
|
||||
*rate = SPA_NSEC_PER_SEC;
|
||||
|
|
@ -790,7 +789,7 @@ impl_clock_get_time(struct spa_clock *clock,
|
|||
if (monotonic_time)
|
||||
*monotonic_time = tnow;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_clock impl_clock = {
|
||||
|
|
@ -806,8 +805,8 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(interface != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -816,16 +815,16 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
else if (interface_id == this->type.clock)
|
||||
*interface = &this->clock;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
|
|
@ -833,7 +832,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
spa_loop_remove_source(this->data_loop, &this->timer_source);
|
||||
close(this->timer_source.fd);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -846,8 +845,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -864,7 +863,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
|
|
@ -893,7 +892,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
spa_log_info(this->log, NAME " %p: initialized", this);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -904,19 +903,21 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
switch (index) {
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*info = &impl_interfaces[index];
|
||||
*info = &impl_interfaces[*index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
(*index)++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_fakesink_factory = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue