mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05: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 <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -88,14 +89,14 @@ static int spa_ffmpeg_dec_node_enum_params(struct spa_node *node,
|
|||
const struct spa_pod_object *filter,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_set_param(struct spa_node *node,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
|
|
@ -103,7 +104,7 @@ static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, const struct
|
|||
struct impl *this;
|
||||
|
||||
if (node == NULL || command == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -112,9 +113,9 @@ static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, const struct
|
|||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
this->started = false;
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -125,14 +126,14 @@ spa_ffmpeg_dec_node_set_callbacks(struct spa_node *node,
|
|||
struct impl *this;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -143,7 +144,7 @@ spa_ffmpeg_dec_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *max_output_ports)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
|
|
@ -154,7 +155,7 @@ spa_ffmpeg_dec_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -165,21 +166,21 @@ spa_ffmpeg_dec_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t *output_ids)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ports > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -187,7 +188,7 @@ spa_ffmpeg_dec_node_remove_port(struct spa_node *node,
|
|||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -200,18 +201,18 @@ spa_ffmpeg_dec_node_port_get_info(struct spa_node *node,
|
|||
struct port *port;
|
||||
|
||||
if (node == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
*info = &port->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
|
|
@ -224,23 +225,21 @@ static int port_enum_formats(struct spa_node *node,
|
|||
//struct impl *this;
|
||||
|
||||
if (node == NULL || index == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
//this = SPA_CONTAINER_OF (node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
*param = NULL;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
|
|
@ -257,14 +256,14 @@ static int port_get_format(struct spa_node *node,
|
|||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = NULL;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -291,18 +290,18 @@ spa_ffmpeg_dec_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
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -310,7 +309,7 @@ spa_ffmpeg_dec_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 port_set_format(struct spa_node *node,
|
||||
|
|
@ -322,19 +321,19 @@ static int port_set_format(struct spa_node *node,
|
|||
struct port *port;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (format == NULL) {
|
||||
port->have_format = false;
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
} else {
|
||||
struct spa_video_info info = { 0 };
|
||||
|
||||
|
|
@ -344,17 +343,17 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (info.media_type != this->type.media_type.video &&
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (!(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
|
||||
port->current_format = info;
|
||||
port->have_format = true;
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -370,7 +369,7 @@ spa_ffmpeg_dec_node_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
|
||||
|
|
@ -381,12 +380,12 @@ spa_ffmpeg_dec_node_port_use_buffers(struct spa_node *node,
|
|||
uint32_t n_buffers)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (!IS_VALID_PORT(node, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -398,7 +397,7 @@ spa_ffmpeg_dec_node_port_alloc_buffers(struct spa_node *node,
|
|||
struct spa_buffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -411,23 +410,23 @@ spa_ffmpeg_dec_node_port_set_io(struct spa_node *node,
|
|||
struct port *port;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_dec_node_process_output(struct spa_node *node)
|
||||
|
|
@ -437,34 +436,34 @@ static int spa_ffmpeg_dec_node_process_output(struct spa_node *node)
|
|||
struct spa_port_io *output;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
port = &this->out_ports[0];
|
||||
|
||||
if ((output = port->io) == NULL)
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EIO;
|
||||
|
||||
if (!port->have_format) {
|
||||
output->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
output->status = -EIO;
|
||||
return -EIO;
|
||||
}
|
||||
output->status = SPA_RESULT_OK;
|
||||
output->status = SPA_STATUS_OK;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -473,7 +472,7 @@ spa_ffmpeg_dec_node_port_send_command(struct spa_node *node,
|
|||
uint32_t port_id,
|
||||
const struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -506,16 +505,16 @@ spa_ffmpeg_dec_get_interface(struct spa_handle *handle, uint32_t interface_id, v
|
|||
struct impl *this;
|
||||
|
||||
if (handle == NULL || interface == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -539,7 +538,7 @@ spa_ffmpeg_dec_init(struct spa_handle *handle,
|
|||
}
|
||||
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);
|
||||
|
||||
|
|
@ -548,5 +547,5 @@ spa_ffmpeg_dec_init(struct spa_handle *handle,
|
|||
this->in_ports[0].info.flags = 0;
|
||||
this->out_ports[0].info.flags = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -92,13 +93,13 @@ static int spa_ffmpeg_enc_node_enum_params(struct spa_node *node,
|
|||
const struct spa_pod_object *filter,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
|
|
@ -106,7 +107,7 @@ static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, const struct
|
|||
struct impl *this;
|
||||
|
||||
if (node == NULL || command == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
|
|
@ -115,9 +116,9 @@ static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, const struct
|
|||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
this->started = false;
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -128,14 +129,14 @@ spa_ffmpeg_enc_node_set_callbacks(struct spa_node *node,
|
|||
struct impl *this;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
this->callbacks = callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -146,7 +147,7 @@ spa_ffmpeg_enc_node_get_n_ports(struct spa_node *node,
|
|||
uint32_t *max_output_ports)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
|
|
@ -157,7 +158,7 @@ spa_ffmpeg_enc_node_get_n_ports(struct spa_node *node,
|
|||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -168,28 +169,28 @@ spa_ffmpeg_enc_node_get_port_ids(struct spa_node *node,
|
|||
uint32_t *output_ids)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (n_input_ports > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_remove_port(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -201,18 +202,18 @@ spa_ffmpeg_enc_node_port_get_info(struct spa_node *node,
|
|||
struct port *port;
|
||||
|
||||
if (node == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
*info = &port->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int port_enum_formats(struct spa_node *node,
|
||||
|
|
@ -232,9 +233,9 @@ static int port_enum_formats(struct spa_node *node,
|
|||
*param = NULL;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int port_get_format(struct spa_node *node,
|
||||
|
|
@ -251,14 +252,14 @@ static int port_get_format(struct spa_node *node,
|
|||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
return -EIO;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
*param = NULL;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -285,18 +286,18 @@ spa_ffmpeg_enc_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
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
return -ENOENT;
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -304,7 +305,7 @@ spa_ffmpeg_enc_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 port_set_format(struct spa_node *node,
|
||||
|
|
@ -319,7 +320,7 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (format == NULL) {
|
||||
port->have_format = false;
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
} else {
|
||||
struct spa_video_info info = { 0 };
|
||||
|
||||
|
|
@ -329,17 +330,17 @@ static int port_set_format(struct spa_node *node,
|
|||
|
||||
if (info.media_type != this->type.media_type.video &&
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
return -EINVAL;
|
||||
|
||||
if (!(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
|
||||
port->current_format = info;
|
||||
port->have_format = true;
|
||||
}
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -355,7 +356,7 @@ spa_ffmpeg_enc_node_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
|
||||
|
|
@ -365,12 +366,12 @@ spa_ffmpeg_enc_node_port_use_buffers(struct spa_node *node,
|
|||
struct spa_buffer **buffers, uint32_t n_buffers)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (!IS_VALID_PORT(node, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -382,7 +383,7 @@ spa_ffmpeg_enc_node_port_alloc_buffers(struct spa_node *node,
|
|||
struct spa_buffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -394,30 +395,30 @@ spa_ffmpeg_enc_node_port_set_io(struct spa_node *node,
|
|||
struct port *port;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -425,12 +426,12 @@ spa_ffmpeg_enc_node_port_send_command(struct spa_node *node,
|
|||
enum spa_direction direction,
|
||||
uint32_t port_id, const struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int spa_ffmpeg_enc_node_process_output(struct spa_node *node)
|
||||
|
|
@ -440,22 +441,22 @@ static int spa_ffmpeg_enc_node_process_output(struct spa_node *node)
|
|||
struct spa_port_io *output;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if ((output = this->out_ports[0].io) == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
return -EIO;
|
||||
|
||||
port = &this->out_ports[0];
|
||||
|
||||
if (!port->have_format) {
|
||||
output->status = SPA_RESULT_NO_FORMAT;
|
||||
return SPA_RESULT_ERROR;
|
||||
output->status = -EIO;
|
||||
return -EIO;
|
||||
}
|
||||
output->status = SPA_RESULT_OK;
|
||||
output->status = SPA_STATUS_OK;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return SPA_STATUS_OK;
|
||||
}
|
||||
|
||||
static const struct spa_node ffmpeg_enc_node = {
|
||||
|
|
@ -487,16 +488,16 @@ spa_ffmpeg_enc_get_interface(struct spa_handle *handle, uint32_t interface_id, v
|
|||
struct impl *this;
|
||||
|
||||
if (handle == NULL || interface == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -519,7 +520,7 @@ spa_ffmpeg_enc_init(struct spa_handle *handle,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
this->node = ffmpeg_enc_node;
|
||||
|
|
@ -527,5 +528,5 @@ spa_ffmpeg_enc_init(struct spa_handle *handle,
|
|||
this->in_ports[0].info.flags = 0;
|
||||
this->out_ports[0].info.flags = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
|
|
@ -38,7 +39,7 @@ ffmpeg_dec_init(const struct spa_handle_factory *factory,
|
|||
uint32_t n_support)
|
||||
{
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
return spa_ffmpeg_dec_init(handle, info, support, n_support);
|
||||
}
|
||||
|
|
@ -51,7 +52,7 @@ ffmpeg_enc_init(const struct spa_handle_factory *factory,
|
|||
uint32_t n_support)
|
||||
{
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
return -EINVAL;
|
||||
|
||||
return spa_ffmpeg_enc_init(handle, info, support, n_support);
|
||||
}
|
||||
|
|
@ -63,20 +64,20 @@ static const struct spa_interface_info ffmpeg_interfaces[] = {
|
|||
static int
|
||||
ffmpeg_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
if (factory == NULL || info == NULL || index == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
if (*index < SPA_N_ELEMENTS(ffmpeg_interfaces))
|
||||
*info = &ffmpeg_interfaces[(*index)++];
|
||||
else
|
||||
return 0;
|
||||
|
||||
*info = &ffmpeg_interfaces[index];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
|
||||
{
|
||||
static const AVCodec *c = NULL;
|
||||
static int ci = 0;
|
||||
|
|
@ -85,16 +86,16 @@ int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t
|
|||
|
||||
av_register_all();
|
||||
|
||||
if (index == 0) {
|
||||
if (*index == 0) {
|
||||
c = av_codec_next(NULL);
|
||||
ci = 0;
|
||||
}
|
||||
while (index > ci && c) {
|
||||
while (*index > ci && c) {
|
||||
c = av_codec_next(c);
|
||||
ci++;
|
||||
}
|
||||
if (c == NULL)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
if (av_codec_is_encoder(c)) {
|
||||
snprintf(name, 128, "ffenc_%s", c->name);
|
||||
|
|
@ -108,6 +109,7 @@ int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t
|
|||
f.enum_interface_info = ffmpeg_enum_interface_info;
|
||||
|
||||
*factory = &f;
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue