spa: don't use typedef for struct and enum

This commit is contained in:
Wim Taymans 2017-05-25 13:28:15 +02:00
parent 83964cec87
commit 11f23a3ffa
163 changed files with 6510 additions and 8264 deletions

View file

@ -136,13 +136,13 @@ draw_pixel_uyvy (DrawingData *dd, int x, Pixel *color)
}
}
static SpaResult
static int
drawing_data_init (DrawingData *dd,
SpaVideoTestSrc *this,
struct impl *this,
char* data)
{
SpaVideoInfo *format = &this->current_format;
SpaRectangle *size = &format->info.raw.size;
struct spa_video_info *format = &this->current_format;
struct spa_rectangle *size = &format->info.raw.size;
if ((format->media_type != this->type.media_type.video) ||
(format->media_subtype != this->type.media_subtype.raw))
@ -276,11 +276,11 @@ draw_snow (DrawingData *dd)
}
}
static SpaResult
draw (SpaVideoTestSrc *this, char *data)
static int
draw (struct impl *this, char *data)
{
DrawingData dd;
SpaResult res;
int res;
uint32_t pattern;
init_colors ();

View file

@ -20,20 +20,21 @@
#include <spa/plugin.h>
#include <spa/node.h>
extern const SpaHandleFactory spa_videotestsrc_factory;
extern const struct spa_handle_factory spa_videotestsrc_factory;
SpaResult
spa_enum_handle_factory (const SpaHandleFactory **factory,
uint32_t index)
int
spa_handle_factory_enum(const struct spa_handle_factory **factory,
uint32_t index)
{
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(factory != NULL,
SPA_RESULT_INVALID_ARGUMENTS);
switch (index) {
case 0:
*factory = &spa_videotestsrc_factory;
break;
default:
return SPA_RESULT_ENUM_END;
}
return SPA_RESULT_OK;
switch (index) {
case 0:
*factory = &spa_videotestsrc_factory;
break;
default:
return SPA_RESULT_ENUM_END;
}
return SPA_RESULT_OK;
}

View file

@ -35,10 +35,12 @@
#include <spa/format-builder.h>
#include <lib/props.h>
#define NAME "videotestsrc"
#define FRAMES_TO_TIME(this,f) ((this->current_format.info.raw.framerate.denom * (f) * SPA_NSEC_PER_SEC) / \
(this->current_format.info.raw.framerate.num))
typedef struct {
struct type {
uint32_t node;
uint32_t clock;
uint32_t format;
@ -47,20 +49,20 @@ typedef struct {
uint32_t prop_pattern;
uint32_t pattern_smpte_snow;
uint32_t pattern_snow;
SpaTypeMeta meta;
SpaTypeData data;
SpaTypeMediaType media_type;
SpaTypeMediaSubtype media_subtype;
SpaTypeFormatVideo format_video;
SpaTypeVideoFormat video_format;
SpaTypeEventNode event_node;
SpaTypeCommandNode command_node;
SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
} Type;
struct spa_type_meta meta;
struct spa_type_data data;
struct spa_type_media_type media_type;
struct spa_type_media_subtype media_subtype;
struct spa_type_format_video format_video;
struct spa_type_video_format video_format;
struct spa_type_event_node event_node;
struct spa_type_command_node command_node;
struct spa_type_param_alloc_buffers param_alloc_buffers;
struct spa_type_param_alloc_meta_enable param_alloc_meta_enable;
};
static inline void
init_type (Type *type, SpaTypeMap *map)
init_type (struct type *type, struct spa_type_map *map)
{
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock);
@ -82,55 +84,51 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
}
typedef struct _SpaVideoTestSrc SpaVideoTestSrc;
typedef struct {
struct props {
bool live;
uint32_t pattern;
} SpaVideoTestSrcProps;
};
#define MAX_BUFFERS 16
#define MAX_PORTS 1
typedef struct _VTSBuffer VTSBuffer;
struct _VTSBuffer {
SpaBuffer *outbuf;
struct buffer {
struct spa_buffer *outbuf;
bool outstanding;
SpaMetaHeader *h;
SpaList link;
struct spa_meta_header *h;
struct spa_list link;
};
struct _SpaVideoTestSrc {
SpaHandle handle;
SpaNode node;
SpaClock clock;
struct impl {
struct spa_handle handle;
struct spa_node node;
struct spa_clock clock;
Type type;
SpaTypeMap *map;
SpaLog *log;
SpaLoop *data_loop;
struct type type;
struct spa_type_map *map;
struct spa_log *log;
struct spa_loop *data_loop;
uint8_t props_buffer[512];
SpaVideoTestSrcProps props;
struct props props;
SpaNodeCallbacks callbacks;
struct spa_node_callbacks callbacks;
void *user_data;
SpaSource timer_source;
struct spa_source timer_source;
struct itimerspec timerspec;
SpaPortInfo info;
struct spa_port_info info;
uint8_t params_buffer[1024];
SpaPortIO *io;
struct spa_port_io *io;
bool have_format;
SpaVideoInfo current_format;
struct spa_video_info current_format;
uint8_t format_buffer[1024];
size_t bpp;
int stride;
VTSBuffer buffers[MAX_BUFFERS];
struct buffer buffers[MAX_BUFFERS];
uint32_t n_buffers;
bool started;
@ -138,7 +136,7 @@ struct _SpaVideoTestSrc {
uint64_t elapsed_time;
uint64_t frame_count;
SpaList empty;
struct spa_list empty;
};
#define CHECK_PORT_NUM(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < MAX_PORTS)
@ -148,7 +146,7 @@ struct _SpaVideoTestSrc {
#define DEFAULT_PATTERN pattern_smpte_snow
static void
reset_videotestsrc_props (SpaVideoTestSrc *this, SpaVideoTestSrcProps *props)
reset_props (struct impl *this, struct props *props)
{
props->live = DEFAULT_LIVE;
props->pattern = this->type. DEFAULT_PATTERN;
@ -167,18 +165,18 @@ reset_videotestsrc_props (SpaVideoTestSrc *this, SpaVideoTestSrcProps *props)
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
static SpaResult
spa_videotestsrc_node_get_props (SpaNode *node,
SpaProps **props)
static int
impl_node_get_props (struct spa_node *node,
struct spa_props **props)
{
SpaVideoTestSrc *this;
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
spa_pod_builder_props (&b, &f[0], this->type.props,
@ -188,23 +186,23 @@ spa_videotestsrc_node_get_props (SpaNode *node,
this->type.pattern_smpte_snow,
this->type.pattern_snow));
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props);
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_set_props (SpaNode *node,
const SpaProps *props)
static int
impl_node_set_props (struct spa_node *node,
const struct spa_props *props)
{
SpaVideoTestSrc *this;
struct impl *this;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
if (props == NULL) {
reset_videotestsrc_props (this, &this->props);
reset_props (this, &this->props);
} else {
spa_props_query (props,
this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
@ -222,14 +220,14 @@ spa_videotestsrc_node_set_props (SpaNode *node,
#include "draw.c"
static SpaResult
fill_buffer (SpaVideoTestSrc *this, VTSBuffer *b)
static int
fill_buffer (struct impl *this, struct buffer *b)
{
return draw (this, b->outbuf->datas[0].data);
}
static void
set_timer (SpaVideoTestSrc *this, bool enabled)
set_timer (struct impl *this, bool enabled)
{
if (this->callbacks.have_output || this->props.live) {
if (enabled) {
@ -250,7 +248,7 @@ set_timer (SpaVideoTestSrc *this, bool enabled)
}
static void
read_timer (SpaVideoTestSrc *this)
read_timer (struct impl *this)
{
uint64_t expirations;
@ -260,27 +258,27 @@ read_timer (SpaVideoTestSrc *this)
}
}
static SpaResult
videotestsrc_make_buffer (SpaVideoTestSrc *this)
static int
make_buffer (struct impl *this)
{
VTSBuffer *b;
SpaPortIO *io = this->io;
struct buffer *b;
struct spa_port_io *io = this->io;
int n_bytes;
read_timer (this);
if (spa_list_is_empty (&this->empty)) {
set_timer (this, false);
spa_log_error (this->log, "videotestsrc %p: out of buffers", this);
spa_log_error (this->log, NAME " %p: out of buffers", this);
return SPA_RESULT_OUT_OF_BUFFERS;
}
b = spa_list_first (&this->empty, VTSBuffer, link);
b = spa_list_first (&this->empty, struct buffer, link);
spa_list_remove (&b->link);
b->outstanding = true;
n_bytes = b->outbuf->datas[0].maxsize;
spa_log_trace (this->log, "videotestsrc %p: dequeue buffer %d", this, b->outbuf->id);
spa_log_trace (this->log, NAME " %p: dequeue buffer %d", this, b->outbuf->id);
fill_buffer (this, b);
@ -305,27 +303,27 @@ videotestsrc_make_buffer (SpaVideoTestSrc *this)
}
static void
videotestsrc_on_output (SpaSource *source)
impl_on_output (struct spa_source *source)
{
SpaVideoTestSrc *this = source->data;
SpaResult res;
struct impl *this = source->data;
int res;
res = videotestsrc_make_buffer (this);
res = make_buffer (this);
if (res == SPA_RESULT_HAVE_BUFFER)
this->callbacks.have_output (&this->node, this->user_data);
}
static SpaResult
spa_videotestsrc_node_send_command (SpaNode *node,
SpaCommand *command)
static int
impl_node_send_command (struct spa_node *node,
struct spa_command *command)
{
SpaVideoTestSrc *this;
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);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
struct timespec now;
@ -369,17 +367,17 @@ spa_videotestsrc_node_send_command (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_set_callbacks (SpaNode *node,
const SpaNodeCallbacks *callbacks,
static int
impl_node_set_callbacks (struct spa_node *node,
const struct spa_node_callbacks *callbacks,
size_t callbacks_size,
void *user_data)
{
SpaVideoTestSrc *this;
struct impl *this;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
if (this->data_loop == NULL && callbacks->have_output != NULL) {
spa_log_error (this->log, "a data_loop is needed for async operation");
@ -391,8 +389,8 @@ spa_videotestsrc_node_set_callbacks (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_get_n_ports (SpaNode *node,
static int
impl_node_get_n_ports (struct spa_node *node,
uint32_t *n_input_ports,
uint32_t *max_input_ports,
uint32_t *n_output_ports,
@ -412,8 +410,8 @@ spa_videotestsrc_node_get_n_ports (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_get_port_ids (SpaNode *node,
static int
impl_node_get_port_ids (struct spa_node *node,
uint32_t n_input_ports,
uint32_t *input_ids,
uint32_t n_output_ports,
@ -427,42 +425,42 @@ spa_videotestsrc_node_get_port_ids (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_add_port (SpaNode *node,
SpaDirection direction,
static int
impl_node_add_port (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_videotestsrc_node_remove_port (SpaNode *node,
SpaDirection direction,
static int
impl_node_remove_port (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_videotestsrc_node_port_enum_formats (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_enum_formats (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
SpaFormat **format,
const SpaFormat *filter,
struct spa_format **format,
const struct spa_format *filter,
uint32_t index)
{
SpaVideoTestSrc *this;
SpaResult res;
SpaFormat *fmt;
struct impl *this;
int res;
struct spa_format *fmt;
uint8_t buffer[1024];
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
uint32_t count, match;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -491,23 +489,23 @@ next:
default:
return SPA_RESULT_ENUM_END;
}
fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat);
fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format);
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK || match++ != index)
goto next;
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
*format = SPA_POD_BUILDER_DEREF (&b, 0, struct spa_format);
return SPA_RESULT_OK;
}
static SpaResult
clear_buffers (SpaVideoTestSrc *this)
static int
clear_buffers (struct impl *this)
{
if (this->n_buffers > 0) {
spa_log_info (this->log, "videotestsrc %p: clear buffers", this);
spa_log_info (this->log, NAME " %p: clear buffers", this);
this->n_buffers = 0;
spa_list_init (&this->empty);
this->started = false;
@ -516,18 +514,18 @@ clear_buffers (SpaVideoTestSrc *this)
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_port_set_format (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_set_format (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
const SpaFormat *format)
const struct spa_format *format)
{
SpaVideoTestSrc *this;
struct impl *this;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -535,8 +533,8 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
this->have_format = false;
clear_buffers (this);
} else {
SpaVideoInfo info = { SPA_FORMAT_MEDIA_TYPE (format),
SPA_FORMAT_MEDIA_SUBTYPE (format), };
struct spa_video_info info = { SPA_FORMAT_MEDIA_TYPE (format),
SPA_FORMAT_MEDIA_SUBTYPE (format), };
if (info.media_type != this->type.media_type.video &&
info.media_subtype != this->type.media_subtype.raw)
@ -559,27 +557,27 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
}
if (this->have_format) {
SpaVideoInfoRaw *raw_info = &this->current_format.info.raw;
struct spa_video_info_raw *raw_info = &this->current_format.info.raw;
this->stride = SPA_ROUND_UP_N (this->bpp * raw_info->size.width, 4);
}
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_port_get_format (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_get_format (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
const SpaFormat **format)
const struct spa_format **format)
{
SpaVideoTestSrc *this;
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -592,23 +590,23 @@ spa_videotestsrc_node_port_get_format (SpaNode *node,
PROP (&f[1], this->type.format_video.format, SPA_POD_TYPE_ID, this->current_format.info.raw.format),
PROP (&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE, &this->current_format.info.raw.size),
PROP (&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION, &this->current_format.info.raw.framerate));
*format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat);
*format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format);
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_port_get_info (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_get_info (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
const SpaPortInfo **info)
const struct spa_port_info **info)
{
SpaVideoTestSrc *this;
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);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -617,21 +615,21 @@ spa_videotestsrc_node_port_get_info (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_port_enum_params (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_enum_params (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
uint32_t index,
SpaParam **param)
struct spa_param **param)
{
SpaVideoTestSrc *this;
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[2];
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail (param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -640,7 +638,7 @@ spa_videotestsrc_node_port_enum_params (SpaNode *node,
switch (index) {
case 0:
{
SpaVideoInfoRaw *raw_info = &this->current_format.info.raw;
struct spa_video_info_raw *raw_info = &this->current_format.info.raw;
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, this->stride * raw_info->size.height),
@ -652,40 +650,40 @@ spa_videotestsrc_node_port_enum_params (SpaNode *node,
case 1:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header)));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param);
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_port_set_param (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_set_param (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
const SpaParam *param)
const struct spa_param *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_videotestsrc_node_port_use_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaBuffer **buffers,
uint32_t n_buffers)
static int
impl_node_port_use_buffers (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
struct spa_buffer **buffers,
uint32_t n_buffers)
{
SpaVideoTestSrc *this;
struct impl *this;
uint32_t i;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -695,8 +693,8 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
clear_buffers (this);
for (i = 0; i < n_buffers; i++) {
VTSBuffer *b;
SpaData *d = buffers[i]->datas;
struct buffer *b;
struct spa_data *d = buffers[i]->datas;
b = &this->buffers[i];
b->outbuf = buffers[i];
@ -707,7 +705,7 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
d[0].type == this->type.data.MemFd ||
d[0].type == this->type.data.DmaBuf) &&
d[0].data == NULL) {
spa_log_error (this->log, "videotestsrc %p: invalid memory on buffer %p", this, buffers[i]);
spa_log_error (this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]);
}
spa_list_insert (this->empty.prev, &b->link);
}
@ -716,20 +714,20 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaParam **params,
uint32_t n_params,
SpaBuffer **buffers,
uint32_t *n_buffers)
static int
impl_node_port_alloc_buffers (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
struct spa_param **params,
uint32_t n_params,
struct spa_buffer **buffers,
uint32_t *n_buffers)
{
SpaVideoTestSrc *this;
struct impl *this;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -739,17 +737,17 @@ spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_videotestsrc_node_port_set_io (SpaNode *node,
SpaDirection direction,
static int
impl_node_port_set_io (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
SpaPortIO *io)
struct spa_port_io *io)
{
SpaVideoTestSrc *this;
struct impl *this;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
spa_return_val_if_fail (CHECK_PORT_NUM (this, direction, port_id), SPA_RESULT_INVALID_PORT);
@ -759,12 +757,12 @@ spa_videotestsrc_node_port_set_io (SpaNode *node,
}
static inline void
reuse_buffer (SpaVideoTestSrc *this, uint32_t id)
reuse_buffer (struct impl *this, uint32_t id)
{
VTSBuffer *b = &this->buffers[id];
struct buffer *b = &this->buffers[id];
spa_return_if_fail (b->outstanding);
spa_log_trace (this->log, "videotestsrc %p: reuse buffer %d", this, id);
spa_log_trace (this->log, NAME " %p: reuse buffer %d", this, id);
b->outstanding = false;
spa_list_insert (this->empty.prev, &b->link);
@ -773,16 +771,16 @@ reuse_buffer (SpaVideoTestSrc *this, uint32_t id)
set_timer (this, true);
}
static SpaResult
spa_videotestsrc_node_port_reuse_buffer (SpaNode *node,
static int
impl_node_port_reuse_buffer (struct spa_node *node,
uint32_t port_id,
uint32_t buffer_id)
{
SpaVideoTestSrc *this;
struct impl *this;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
spa_return_val_if_fail (port_id == 0, SPA_RESULT_INVALID_PORT);
spa_return_val_if_fail (this->n_buffers > 0, SPA_RESULT_NO_BUFFERS);
@ -793,30 +791,30 @@ spa_videotestsrc_node_port_reuse_buffer (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_port_send_command (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaCommand *command)
static int
impl_node_port_send_command (struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
struct spa_command *command)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_videotestsrc_node_process_input (SpaNode *node)
static int
impl_node_process_input (struct spa_node *node)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_videotestsrc_node_process_output (SpaNode *node)
static int
impl_node_process_output (struct spa_node *node)
{
SpaVideoTestSrc *this;
SpaPortIO *io;
struct impl *this;
struct spa_port_io *io;
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
this = SPA_CONTAINER_OF (node, struct impl, node);
io = this->io;
spa_return_val_if_fail (io != NULL, SPA_RESULT_WRONG_STATE);
@ -829,53 +827,53 @@ spa_videotestsrc_node_process_output (SpaNode *node)
}
if (!this->callbacks.have_output && (io->status == SPA_RESULT_NEED_BUFFER))
return videotestsrc_make_buffer (this);
return make_buffer (this);
else
return SPA_RESULT_OK;
}
static const SpaNode videotestsrc_node = {
sizeof (SpaNode),
static const struct spa_node impl_node = {
sizeof (struct spa_node),
NULL,
spa_videotestsrc_node_get_props,
spa_videotestsrc_node_set_props,
spa_videotestsrc_node_send_command,
spa_videotestsrc_node_set_callbacks,
spa_videotestsrc_node_get_n_ports,
spa_videotestsrc_node_get_port_ids,
spa_videotestsrc_node_add_port,
spa_videotestsrc_node_remove_port,
spa_videotestsrc_node_port_enum_formats,
spa_videotestsrc_node_port_set_format,
spa_videotestsrc_node_port_get_format,
spa_videotestsrc_node_port_get_info,
spa_videotestsrc_node_port_enum_params,
spa_videotestsrc_node_port_set_param,
spa_videotestsrc_node_port_use_buffers,
spa_videotestsrc_node_port_alloc_buffers,
spa_videotestsrc_node_port_set_io,
spa_videotestsrc_node_port_reuse_buffer,
spa_videotestsrc_node_port_send_command,
spa_videotestsrc_node_process_input,
spa_videotestsrc_node_process_output,
impl_node_get_props,
impl_node_set_props,
impl_node_send_command,
impl_node_set_callbacks,
impl_node_get_n_ports,
impl_node_get_port_ids,
impl_node_add_port,
impl_node_remove_port,
impl_node_port_enum_formats,
impl_node_port_set_format,
impl_node_port_get_format,
impl_node_port_get_info,
impl_node_port_enum_params,
impl_node_port_set_param,
impl_node_port_use_buffers,
impl_node_port_alloc_buffers,
impl_node_port_set_io,
impl_node_port_reuse_buffer,
impl_node_port_send_command,
impl_node_process_input,
impl_node_process_output,
};
static SpaResult
spa_videotestsrc_clock_get_props (SpaClock *clock,
SpaProps **props)
static int
impl_clock_get_props (struct spa_clock *clock,
struct spa_props **props)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_videotestsrc_clock_set_props (SpaClock *clock,
const SpaProps *props)
static int
impl_clock_set_props (struct spa_clock *clock,
const struct spa_props *props)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_videotestsrc_clock_get_time (SpaClock *clock,
static int
impl_clock_get_time (struct spa_clock *clock,
int32_t *rate,
int64_t *ticks,
int64_t *monotonic_time)
@ -899,26 +897,26 @@ spa_videotestsrc_clock_get_time (SpaClock *clock,
return SPA_RESULT_OK;
}
static const SpaClock videotestsrc_clock = {
sizeof (SpaClock),
static const struct spa_clock impl_clock = {
sizeof (struct spa_clock),
NULL,
SPA_CLOCK_STATE_STOPPED,
spa_videotestsrc_clock_get_props,
spa_videotestsrc_clock_set_props,
spa_videotestsrc_clock_get_time,
impl_clock_get_props,
impl_clock_set_props,
impl_clock_get_time,
};
static SpaResult
spa_videotestsrc_get_interface (SpaHandle *handle,
static int
impl_get_interface (struct spa_handle *handle,
uint32_t interface_id,
void **interface)
{
SpaVideoTestSrc *this;
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);
this = (SpaVideoTestSrc *) handle;
this = (struct impl *) handle;
if (interface_id == this->type.node)
*interface = &this->node;
@ -930,14 +928,14 @@ spa_videotestsrc_get_interface (SpaHandle *handle,
return SPA_RESULT_OK;
}
static SpaResult
videotestsrc_clear (SpaHandle *handle)
static int
impl_clear (struct spa_handle *handle)
{
SpaVideoTestSrc *this;
struct impl *this;
spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = (SpaVideoTestSrc *) handle;
this = (struct impl *) handle;
if (this->data_loop)
spa_loop_remove_source (this->data_loop, &this->timer_source);
@ -946,23 +944,23 @@ videotestsrc_clear (SpaHandle *handle)
return SPA_RESULT_OK;
}
static SpaResult
videotestsrc_init (const SpaHandleFactory *factory,
SpaHandle *handle,
const SpaDict *info,
const SpaSupport *support,
static int
impl_init (const struct spa_handle_factory *factory,
struct spa_handle *handle,
const struct spa_dict *info,
const struct spa_support *support,
uint32_t n_support)
{
SpaVideoTestSrc *this;
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);
handle->get_interface = spa_videotestsrc_get_interface;
handle->clear = videotestsrc_clear;
handle->get_interface = impl_get_interface;
handle->clear = impl_clear;
this = (SpaVideoTestSrc *) handle;
this = (struct impl *) handle;
for (i = 0; i < n_support; i++) {
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
@ -978,13 +976,13 @@ videotestsrc_init (const SpaHandleFactory *factory,
}
init_type (&this->type, this->map);
this->node = videotestsrc_node;
this->clock = videotestsrc_clock;
reset_videotestsrc_props (this, &this->props);
this->node = impl_node;
this->clock = impl_clock;
reset_props (this, &this->props);
spa_list_init (&this->empty);
this->timer_source.func = videotestsrc_on_output;
this->timer_source.func = impl_on_output;
this->timer_source.data = this;
this->timer_source.fd = timerfd_create (CLOCK_MONOTONIC, TFD_CLOEXEC);
this->timer_source.mask = SPA_IO_IN;
@ -1002,20 +1000,20 @@ videotestsrc_init (const SpaHandleFactory *factory,
if (this->props.live)
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
spa_log_info (this->log, "videotestsrc %p: initialized", this);
spa_log_info (this->log, NAME " %p: initialized", this);
return SPA_RESULT_OK;
}
static const SpaInterfaceInfo videotestsrc_interfaces[] =
static const struct spa_interface_info impl_interfaces[] =
{
{ SPA_TYPE__Node, },
{ SPA_TYPE__Clock, },
};
static SpaResult
videotestsrc_enum_interface_info (const SpaHandleFactory *factory,
const SpaInterfaceInfo **info,
static int
impl_enum_interface_info (const struct spa_handle_factory *factory,
const struct spa_interface_info **info,
uint32_t index)
{
spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
@ -1023,7 +1021,7 @@ videotestsrc_enum_interface_info (const SpaHandleFactory *factory,
switch (index) {
case 0:
*info = &videotestsrc_interfaces[index];
*info = &impl_interfaces[index];
break;
default:
return SPA_RESULT_ENUM_END;
@ -1031,10 +1029,10 @@ videotestsrc_enum_interface_info (const SpaHandleFactory *factory,
return SPA_RESULT_OK;
}
const SpaHandleFactory spa_videotestsrc_factory =
{ "videotestsrc",
const struct spa_handle_factory spa_videotestsrc_factory =
{ NAME,
NULL,
sizeof (SpaVideoTestSrc),
videotestsrc_init,
videotestsrc_enum_interface_info,
sizeof (struct impl),
impl_init,
impl_enum_interface_info,
};