summaryrefslogtreecommitdiff
path: root/spa/plugins/test/fakesrc.c
diff options
context:
space:
mode:
Diffstat (limited to 'spa/plugins/test/fakesrc.c')
-rw-r--r--spa/plugins/test/fakesrc.c113
1 files changed, 45 insertions, 68 deletions
diff --git a/spa/plugins/test/fakesrc.c b/spa/plugins/test/fakesrc.c
index d7560cb4..666dfa09 100644
--- a/spa/plugins/test/fakesrc.c
+++ b/spa/plugins/test/fakesrc.c
@@ -113,22 +113,20 @@ static void reset_props(struct impl *this, struct props *props)
props->pattern = DEFAULT_PATTERN;
}
-static int impl_node_enum_params(struct spa_node *node, int seq,
+static int impl_node_enum_params(void *object, int seq,
uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter)
{
- struct impl *this;
+ struct impl *this = object;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
struct spa_pod *param;
struct spa_result_node_params result;
uint32_t count = 0;
- spa_return_val_if_fail(node != NULL, -EINVAL);
+ spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(num != 0, -EINVAL);
- this = SPA_CONTAINER_OF(node, struct impl, node);
-
result.id = id;
result.next = start;
next:
@@ -165,19 +163,17 @@ static int impl_node_enum_params(struct spa_node *node, int seq,
return 0;
}
-static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size_t size)
+static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
{
return -ENOTSUP;
}
-static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
+static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
- struct impl *this;
-
- spa_return_val_if_fail(node != NULL, -EINVAL);
+ struct impl *this = object;
- this = SPA_CONTAINER_OF(node, struct impl, node);
+ spa_return_val_if_fail(this != NULL, -EINVAL);
switch (id) {
case SPA_PARAM_Props:
@@ -296,15 +292,14 @@ static void on_output(struct spa_source *source)
spa_node_call_ready(&this->callbacks, res);
}
-static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
+static int impl_node_send_command(void *object, const struct spa_command *command)
{
- struct impl *this;
+ struct impl *this = object;
struct port *port;
- spa_return_val_if_fail(node != NULL, -EINVAL);
+ spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(command != NULL, -EINVAL);
- this = SPA_CONTAINER_OF(node, struct impl, node);
port = &this->port;
switch (SPA_NODE_COMMAND_ID(command)) {
@@ -372,17 +367,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
}
-static int impl_node_add_listener(struct spa_node *node,
+static int impl_node_add_listener(void *object,
struct spa_hook *listener,
const struct spa_node_events *events,
void *data)
{
- struct impl *this;
+ struct impl *this = object;
struct spa_hook_list save;
- spa_return_val_if_fail(node != NULL, -EINVAL);
+ spa_return_val_if_fail(this != NULL, -EINVAL);
- this = SPA_CONTAINER_OF(node, struct impl, node);
spa_hook_list_isolate(&this->hooks, &save, listener, events, data);
emit_node_info(this, true);
@@ -394,15 +388,13 @@ static int impl_node_add_listener(struct spa_node *node,
}
static int
-impl_node_set_callbacks(struct spa_node *node,
+impl_node_set_callbacks(void *object,
const struct spa_node_callbacks *callbacks,
void *data)
{
- struct impl *this;
+ struct impl *this = object;
- spa_return_val_if_fail(node != NULL, -EINVAL);
-
- this = SPA_CONTAINER_OF(node, struct impl, node);
+ spa_return_val_if_fail(this != NULL, -EINVAL);
if (this->data_loop == NULL && callbacks != NULL) {
spa_log_error(this->log, "a data_loop is needed for async operation");
@@ -413,14 +405,14 @@ impl_node_set_callbacks(struct spa_node *node,
return 0;
}
-static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
+static int impl_node_add_port(void *object, enum spa_direction direction, uint32_t port_id,
const struct spa_dict *props)
{
return -ENOTSUP;
}
static int
-impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
+impl_node_remove_port(void *object, enum spa_direction direction, uint32_t port_id)
{
return -ENOTSUP;
}
@@ -451,12 +443,12 @@ static int port_get_format(struct impl *this, struct port *port,
}
static int
-impl_node_port_enum_params(struct spa_node *node, int seq,
+impl_node_port_enum_params(void *object, int seq,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter)
{
- struct impl *this;
+ struct impl *this = object;
struct port *port;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
@@ -465,11 +457,8 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
uint32_t count = 0;
int res;
- spa_return_val_if_fail(node != NULL, -EINVAL);
+ spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(num != 0, -EINVAL);
-
- this = SPA_CONTAINER_OF(node, struct impl, node);
-
spa_return_val_if_fail(CHECK_PORT(node, direction, port_id), -EINVAL);
port = &this->port;
@@ -562,17 +551,15 @@ static int port_set_format(struct impl *this, struct port *port,
}
static int
-impl_node_port_set_param(struct spa_node *node,
+impl_node_port_set_param(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
- struct impl *this;
+ struct impl *this = object;
struct port *port;
- spa_return_val_if_fail(node != NULL, -EINVAL);
- this = SPA_CONTAINER_OF(node, struct impl, node);
-
+ spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(node, direction, port_id), -EINVAL);
port = &this->port;
@@ -584,20 +571,17 @@ impl_node_port_set_param(struct spa_node *node,
}
static int
-impl_node_port_use_buffers(struct spa_node *node,
+impl_node_port_use_buffers(void *object,
enum spa_direction direction,
uint32_t port_id,
struct spa_buffer **buffers,
uint32_t n_buffers)
{
- struct impl *this;
+ struct impl *this = object;
struct port *port;
uint32_t i;
- spa_return_val_if_fail(node != NULL, -EINVAL);
-
- this = SPA_CONTAINER_OF(node, struct impl, node);
-
+ spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
port = &this->port;
@@ -631,7 +615,7 @@ impl_node_port_use_buffers(struct spa_node *node,
}
static int
-impl_node_port_alloc_buffers(struct spa_node *node,
+impl_node_port_alloc_buffers(void *object,
enum spa_direction direction,
uint32_t port_id,
struct spa_pod **params,
@@ -639,13 +623,10 @@ impl_node_port_alloc_buffers(struct spa_node *node,
struct spa_buffer **buffers,
uint32_t *n_buffers)
{
- struct impl *this;
+ struct impl *this = object;
struct port *port;
- spa_return_val_if_fail(node != NULL, -EINVAL);
-
- this = SPA_CONTAINER_OF(node, struct impl, node);
-
+ spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
port = &this->port;
@@ -656,19 +637,16 @@ impl_node_port_alloc_buffers(struct spa_node *node,
}
static int
-impl_node_port_set_io(struct spa_node *node,
+impl_node_port_set_io(void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t id,
void *data, size_t size)
{
- struct impl *this;
+ struct impl *this = object;
struct port *port;
- spa_return_val_if_fail(node != NULL, -EINVAL);
-
- this = SPA_CONTAINER_OF(node, struct impl, node);
-
+ spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
port = &this->port;
@@ -696,15 +674,12 @@ static inline void reuse_buffer(struct impl *this, struct port *port, uint32_t i
}
}
-static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
+static int impl_node_port_reuse_buffer(void *object, uint32_t port_id, uint32_t buffer_id)
{
- struct impl *this;
+ struct impl *this = object;
struct port *port;
- spa_return_val_if_fail(node != NULL, -EINVAL);
-
- this = SPA_CONTAINER_OF(node, struct impl, node);
-
+ spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(port_id == 0, -EINVAL);
port = &this->port;
@@ -715,15 +690,14 @@ static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id,
return 0;
}
-static int impl_node_process(struct spa_node *node)
+static int impl_node_process(void *object)
{
- struct impl *this;
+ struct impl *this = object;
struct port *port;
struct spa_io_buffers *io;
- spa_return_val_if_fail(node != NULL, -EINVAL);
+ spa_return_val_if_fail(this != NULL, -EINVAL);
- this = SPA_CONTAINER_OF(node, struct impl, node);
port = &this->port;
io = port->io;
spa_return_val_if_fail(io != NULL, -EIO);
@@ -743,8 +717,8 @@ static int impl_node_process(struct spa_node *node)
return SPA_STATUS_OK;
}
-static const struct spa_node impl_node = {
- SPA_VERSION_NODE,
+static const struct spa_node_methods impl_node = {
+ SPA_VERSION_NODE_METHODS,
.add_listener = impl_node_add_listener,
.set_callbacks = impl_node_set_callbacks,
.enum_params = impl_node_enum_params,
@@ -829,7 +803,10 @@ impl_init(const struct spa_handle_factory *factory,
spa_hook_list_init(&this->hooks);
- this->node = impl_node;
+ this->node.iface = SPA_INTERFACE_INIT(
+ SPA_TYPE_INTERFACE_Node,
+ SPA_VERSION_NODE,
+ &impl_node, this);
this->info_all = SPA_NODE_CHANGE_MASK_FLAGS |
SPA_NODE_CHANGE_MASK_PARAMS;
this->info = SPA_NODE_INFO_INIT();