interface: add an interface struct

The interface struct has the type,version and methods of the
interface.
Make spa interfaces extend from spa_interface and make a
separate structure for the methods.
Pass a generic void* as the first argument of methods, like
we don in PipeWire.
Bundle the methods + implementation in a versioned inteface
and use that to invoke methods. This way we can do version
checks on the methods.
Make resource and proxy interfaces that we can can call. We
can then make the core interfaces independent on proxy/resource and
hide them in the lower layers.
Add add_listener method to methods of core interfaces, just
like SPA.
This commit is contained in:
Wim Taymans 2019-05-20 16:11:23 +02:00
parent eb6481efb3
commit ff946e3d4b
85 changed files with 3051 additions and 3000 deletions

View file

@ -256,18 +256,17 @@ static int emit_info(struct impl *this, bool full)
return err;
}
static int impl_add_listener(struct spa_device *device,
static int impl_add_listener(void *object,
struct spa_hook *listener,
const struct spa_device_events *events,
void *data)
{
struct impl *this;
struct impl *this = object;
struct spa_hook_list save;
spa_return_val_if_fail(device != NULL, -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(events != NULL, -EINVAL);
this = SPA_CONTAINER_OF(device, struct impl, device);
spa_hook_list_isolate(&this->hooks, &save, listener, events, data);
if (events->info || events->object_info)
@ -279,22 +278,20 @@ static int impl_add_listener(struct spa_device *device,
}
static int impl_enum_params(struct spa_device *device, int seq,
static int impl_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 *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
struct spa_result_device_params result;
uint32_t count = 0;
spa_return_val_if_fail(device != NULL, -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(num != 0, -EINVAL);
this = SPA_CONTAINER_OF(device, struct impl, device);
result.id = id;
result.next = start;
next:
@ -351,16 +348,14 @@ static int impl_enum_params(struct spa_device *device, int seq,
return 0;
}
static int impl_set_param(struct spa_device *device,
static int impl_set_param(void *object,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
struct impl *this;
struct impl *this = object;
int res;
spa_return_val_if_fail(device != NULL, -EINVAL);
this = SPA_CONTAINER_OF(device, struct impl, device);
spa_return_val_if_fail(this != NULL, -EINVAL);
switch (id) {
case SPA_PARAM_Profile:
@ -384,11 +379,11 @@ static int impl_set_param(struct spa_device *device,
return 0;
}
static const struct spa_device impl_device = {
SPA_VERSION_DEVICE,
impl_add_listener,
impl_enum_params,
impl_set_param,
static const struct spa_device_methods impl_device = {
SPA_VERSION_DEVICE_METHODS,
.add_listener = impl_add_listener,
.enum_params = impl_enum_params,
.set_param = impl_set_param,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
@ -450,7 +445,10 @@ impl_init(const struct spa_handle_factory *factory,
return -EINVAL;
}
this->device = impl_device;
this->device.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Device,
SPA_VERSION_DEVICE,
&impl_device, this);
spa_hook_list_init(&this->hooks);
reset_props(&this->props);

View file

@ -367,16 +367,14 @@ static int enum_devices(struct impl *this)
}
static int
impl_monitor_set_callbacks(struct spa_monitor *monitor,
impl_monitor_set_callbacks(void *object,
const struct spa_monitor_callbacks *callbacks,
void *data)
{
int res;
struct impl *this;
struct impl *this = object;
spa_return_val_if_fail(monitor != NULL, -EINVAL);
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
spa_return_val_if_fail(this != NULL, -EINVAL);
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
@ -397,9 +395,9 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
return 0;
}
static const struct spa_monitor impl_monitor = {
SPA_VERSION_MONITOR,
impl_monitor_set_callbacks,
static const struct spa_monitor_methods impl_monitor = {
SPA_VERSION_MONITOR_METHODS,
.set_callbacks = impl_monitor_set_callbacks,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
@ -422,7 +420,7 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **i
static int impl_clear(struct spa_handle *handle)
{
struct impl *this = (struct impl *) handle;
impl_monitor_set_callbacks(&this->monitor, NULL, NULL);
impl_monitor_set_callbacks(this, NULL, NULL);
return 0;
}
@ -462,7 +460,10 @@ impl_init(const struct spa_handle_factory *factory,
return -EINVAL;
}
this->monitor = impl_monitor;
this->monitor.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Monitor,
SPA_VERSION_MONITOR,
&impl_monitor, this);
return 0;
}

View file

@ -49,22 +49,20 @@ static void reset_props(struct props *props)
props->max_latency = default_max_latency;
}
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 state *this;
struct state *this = object;
struct spa_pod *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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 state, node);
result.id = id;
result.next = start;
next:
@ -152,13 +150,11 @@ 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)
{
struct state *this;
struct state *this = object;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
switch (id) {
case SPA_IO_Clock:
@ -175,14 +171,12 @@ static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size
return 0;
}
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 state *this;
struct state *this = object;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
if (id == SPA_PARAM_Props) {
struct props *p = &this->props;
@ -203,16 +197,14 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
return 0;
}
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 state *this;
struct state *this = object;
int res;
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 state, node);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
if (!this->have_format)
@ -261,17 +253,16 @@ static void emit_port_info(struct state *this, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
impl_node_add_listener(void *object,
struct spa_hook *listener,
const struct spa_node_events *events,
void *data)
{
struct state *this;
struct state *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 state, node);
spa_hook_list_isolate(&this->hooks, &save, listener, events, data);
emit_node_info(this, true);
@ -283,51 +274,47 @@ 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 state *this;
struct state *this = object;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
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)
static int impl_node_remove_port(void *object, enum spa_direction direction, uint32_t port_id)
{
return -ENOTSUP;
}
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 state *this;
struct state *this = object;
struct spa_pod *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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 state, node);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
result.id = id;
@ -430,12 +417,12 @@ static int clear_buffers(struct state *this)
return 0;
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t flags,
const struct spa_pod *format)
{
struct state *this = SPA_CONTAINER_OF(node, struct state, node);
struct state *this = object;
int err;
if (format == NULL) {
@ -483,33 +470,33 @@ static int port_set_format(struct spa_node *node,
}
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)
{
spa_return_val_if_fail(node != NULL, -EINVAL);
struct state *this = object;
spa_return_val_if_fail(CHECK_PORT(node, direction, port_id), -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
if (id == SPA_PARAM_Format) {
return port_set_format(node, direction, port_id, flags, param);
return port_set_format(this, direction, port_id, flags, param);
}
else
return -ENOENT;
}
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 state *this;
struct state *this = object;
uint32_t i;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
@ -550,7 +537,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,
@ -558,13 +545,11 @@ impl_node_port_alloc_buffers(struct spa_node *node,
struct spa_buffer **buffers,
uint32_t *n_buffers)
{
struct state *this;
struct state *this = object;
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(buffers != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
if (!this->have_format)
@ -574,17 +559,15 @@ 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 state *this;
struct state *this = object;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
@ -604,19 +587,18 @@ impl_node_port_set_io(struct spa_node *node,
return 0;
}
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)
{
return -ENOTSUP;
}
static int impl_node_process(struct spa_node *node)
static int impl_node_process(void *object)
{
struct state *this;
struct state *this = object;
struct spa_io_buffers *input;
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
input = this->io;
spa_return_val_if_fail(input != NULL, -EIO);
@ -646,8 +628,8 @@ static int impl_node_process(struct spa_node *node)
return SPA_STATUS_HAVE_BUFFER;
}
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,
@ -725,7 +707,11 @@ impl_init(const struct spa_handle_factory *factory,
return -EINVAL;
}
this->node = impl_node;
this->node.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Node,
SPA_VERSION_NODE,
&impl_node, this);
spa_hook_list_init(&this->hooks);
this->stream = SND_PCM_STREAM_PLAYBACK;

View file

@ -49,11 +49,11 @@ static void reset_props(struct props *props)
props->max_latency = default_max_latency;
}
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 state *this;
struct state *this = object;
struct spa_pod *param;
uint8_t buffer[1024];
struct spa_pod_builder b = { 0 };
@ -61,10 +61,9 @@ static int impl_node_enum_params(struct spa_node *node, int seq,
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 state, node);
p = &this->props;
result.id = id;
@ -148,13 +147,11 @@ 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)
{
struct state *this;
struct state *this = object;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
switch (id) {
case SPA_IO_Clock:
@ -170,14 +167,12 @@ static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size
return 0;
}
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 state *this;
struct state *this = object;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
switch (id) {
case SPA_PARAM_Props:
@ -202,16 +197,14 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
return 0;
}
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 state *this;
struct state *this = object;
int res;
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 state, node);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
if (!this->have_format)
@ -260,17 +253,16 @@ static void emit_port_info(struct state *this, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
impl_node_add_listener(void *object,
struct spa_hook *listener,
const struct spa_node_events *events,
void *data)
{
struct state *this;
struct state *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 state, node);
spa_hook_list_isolate(&this->hooks, &save, listener, events, data);
emit_node_info(this, true);
@ -282,28 +274,26 @@ 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 state *this;
struct state *this = object;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
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)
static int impl_node_remove_port(void *object, enum spa_direction direction, uint32_t port_id)
{
return -ENOTSUP;
}
@ -320,23 +310,21 @@ static void recycle_buffer(struct state *this, uint32_t buffer_id)
}
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 state *this;
struct state *this = object;
struct spa_pod *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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 state, node);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
result.id = id;
@ -434,11 +422,11 @@ static int clear_buffers(struct state *this)
return 0;
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t flags, const struct spa_pod *format)
{
struct state *this = SPA_CONTAINER_OF(node, struct state, node);
struct state *this = object;
int err;
if (format == NULL) {
@ -485,20 +473,21 @@ static int port_set_format(struct spa_node *node,
}
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 state *this = object;
int res;
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(node, direction, port_id), -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
switch (id) {
case SPA_PARAM_Format:
res = port_set_format(node, direction, port_id, flags, param);
res = port_set_format(this, direction, port_id, flags, param);
break;
default:
@ -509,17 +498,15 @@ 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 state *this;
struct state *this = object;
int res;
uint32_t i;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
@ -555,7 +542,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,
@ -563,13 +550,11 @@ impl_node_port_alloc_buffers(struct spa_node *node,
struct spa_buffer **buffers,
uint32_t *n_buffers)
{
struct state *this;
struct state *this = object;
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(buffers != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
if (this->n_buffers == 0)
@ -579,17 +564,15 @@ 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 state *this;
struct state *this = object;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
@ -606,13 +589,11 @@ impl_node_port_set_io(struct spa_node *node,
return 0;
}
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 state *this;
struct state *this = object;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(port_id == 0, -EINVAL);
@ -627,15 +608,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 state *this;
struct state *this = object;
struct spa_io_buffers *io;
struct buffer *b;
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct state, node);
io = this->io;
spa_return_val_if_fail(io != NULL, -EIO);
@ -664,8 +644,8 @@ static int impl_node_process(struct spa_node *node)
return SPA_STATUS_HAVE_BUFFER;
}
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,
@ -747,7 +727,8 @@ impl_init(const struct spa_handle_factory *factory,
return -EINVAL;
}
this->node = impl_node;
this->node.iface = SPA_INTERFACE_INIT(SPA_TYPE_INTERFACE_Node, SPA_VERSION_NODE, &impl_node, this);
spa_hook_list_init(&this->hooks);
this->stream = SND_PCM_STREAM_CAPTURE;

View file

@ -393,22 +393,20 @@ static int setup_buffers(struct impl *this, enum spa_direction direction)
return 0;
}
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 *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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:
@ -455,14 +453,12 @@ 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)
{
struct impl *this;
struct impl *this = object;
int res;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
switch (id) {
case SPA_IO_Position:
@ -475,15 +471,13 @@ static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size
return res;
}
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)
{
int res = 0;
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);
switch (id) {
case SPA_PARAM_Profile:
@ -547,15 +541,13 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
return 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;
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);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
@ -615,18 +607,17 @@ static struct spa_node_events node_events = {
};
static int
impl_node_add_listener(struct spa_node *node,
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;
struct spa_hook l[4];
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);
spa_log_debug(this->log, "%p: add listener %p", this, listener);
@ -652,55 +643,49 @@ 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 *user_data)
{
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)
{
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);
return spa_node_add_port(this->fmt[direction], direction, port_id, props);
}
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)
{
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);
return spa_node_remove_port(this->fmt[direction], direction, port_id);
}
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 spa_pod *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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:
@ -766,18 +751,16 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
}
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;
int res;
struct spa_node *target;
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->mode == MODE_MERGE && port_id > 0 && direction == SPA_DIRECTION_OUTPUT)
target = this->fmt[SPA_DIRECTION_INPUT];
@ -801,19 +784,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;
int res;
struct spa_node *target;
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->mode == MODE_MERGE && port_id > 0 && direction == SPA_DIRECTION_OUTPUT)
target = this->fmt[SPA_DIRECTION_INPUT];
@ -833,7 +814,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,
@ -841,12 +822,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 spa_node *target;
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->mode == MODE_MERGE && port_id > 0 && direction == SPA_DIRECTION_OUTPUT)
target = this->fmt[SPA_DIRECTION_INPUT];
@ -858,17 +837,15 @@ 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 spa_node *target;
int res;
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_log_debug(this->log, "set io %d %d %d", id, direction, port_id);
@ -889,14 +866,12 @@ impl_node_port_set_io(struct spa_node *node,
return res;
}
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 spa_node *target;
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->mode == MODE_MERGE && port_id > 0)
target = this->fmt[SPA_DIRECTION_INPUT];
@ -906,15 +881,13 @@ static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id,
return spa_node_port_reuse_buffer(target, port_id, buffer_id);
}
static int impl_node_process(struct spa_node *node)
static int impl_node_process(void *object)
{
struct impl *this;
struct impl *this = object;
int r, i, res = SPA_STATUS_OK;
int ready;
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_log_trace_fp(this->log, NAME " %p: process %d", this, this->n_links);
@ -947,8 +920,8 @@ static int impl_node_process(struct spa_node *node)
return res;
}
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,
@ -1051,7 +1024,10 @@ impl_init(const struct spa_handle_factory *factory,
if (support[i].type == SPA_TYPE_INTERFACE_Log)
this->log = support[i].data;
}
this->node = impl_node;
this->node.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Node,
SPA_VERSION_NODE,
&impl_node, this);
spa_hook_list_init(&this->hooks);
if (info == NULL || (str = spa_dict_lookup(info, "factory.mode")) == NULL)

View file

@ -225,22 +225,20 @@ static int setup_convert(struct impl *this,
return 0;
}
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 *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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:
@ -331,7 +329,7 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
return changed;
}
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;
}
@ -346,14 +344,12 @@ static void emit_info(struct impl *this, bool full)
}
}
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;
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);
switch (id) {
case SPA_PARAM_Props:
@ -369,15 +365,13 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
return 0;
}
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;
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);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
@ -403,17 +397,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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_info(this, true);
@ -426,33 +419,33 @@ 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 *user_data)
{
return 0;
}
static int impl_node_add_port(struct spa_node *node,
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,
static int impl_node_remove_port(void *object,
enum spa_direction direction, uint32_t port_id)
{
return -ENOTSUP;
}
static int port_enum_formats(struct spa_node *node,
static int port_enum_formats(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *other;
other = GET_PORT(this, SPA_DIRECTION_REVERSE(direction), 0);
@ -484,12 +477,12 @@ static int port_enum_formats(struct spa_node *node,
}
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, *other;
struct spa_pod *param;
struct spa_pod_builder b = { 0 };
@ -498,11 +491,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(this, direction, port_id), -EINVAL);
port = GET_PORT(this, direction, port_id);
@ -517,7 +507,7 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
switch (id) {
case SPA_PARAM_EnumFormat:
if ((res = port_enum_formats(node, direction, port_id,
if ((res = port_enum_formats(this, direction, port_id,
result.index, &param, &b)) <= 0)
return res;
break;
@ -616,13 +606,13 @@ static int clear_buffers(struct impl *this, struct port *port)
return 0;
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
const struct spa_pod *format)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port, *other;
int res = 0;
@ -679,37 +669,34 @@ static int port_set_format(struct spa_node *node,
}
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)
{
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(object != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(node, direction, port_id), -EINVAL);
spa_return_val_if_fail(CHECK_PORT(object, direction, port_id), -EINVAL);
if (id == SPA_PARAM_Format) {
return port_set_format(node, direction, port_id, flags, param);
return port_set_format(object, direction, port_id, flags, param);
}
else
return -ENOENT;
}
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, j, size = SPA_ID_INVALID;
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 = GET_PORT(this, direction, port_id);
@ -765,7 +752,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,
@ -777,17 +764,14 @@ 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 = GET_PORT(this, direction, port_id);
@ -832,14 +816,11 @@ static struct buffer *dequeue_buffer(struct impl *this, struct port *port)
}
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;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id), -EINVAL);
recycle_buffer(this, buffer_id);
@ -863,16 +844,14 @@ static int process_control(struct impl *this, struct port *port, struct spa_pod_
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 *outport, *inport;
struct spa_io_buffers *outio, *inio;
struct buffer *sbuf, *dbuf;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
outport = GET_OUT_PORT(this, 0);
inport = GET_IN_PORT(this, 0);
@ -945,8 +924,8 @@ static int impl_node_process(struct spa_node *node)
return SPA_STATUS_HAVE_BUFFER | SPA_STATUS_NEED_BUFFER;
}
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,
@ -1028,7 +1007,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();

View file

@ -195,33 +195,31 @@ static int setup_convert(struct impl *this)
return 0;
}
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)
{
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)
{
return -ENOTSUP;
}
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_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;
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);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
@ -257,17 +255,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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_info(this, true);
@ -280,21 +277,21 @@ 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 *user_data)
{
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;
}
@ -304,13 +301,13 @@ static int int32_cmp(const void *v1, const void *v2)
return *(int32_t*)v1 - *(int32_t*)v2;
}
static int port_enum_formats(struct spa_node *node,
static int port_enum_formats(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port, *other;
port = GET_PORT(this, direction, port_id);
@ -404,12 +401,12 @@ static int port_enum_formats(struct spa_node *node,
}
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, *other;
struct spa_pod *param;
struct spa_pod_builder b = { 0 };
@ -418,11 +415,9 @@ 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(this, direction, port_id), -EINVAL);
port = GET_PORT(this, direction, port_id);
@ -437,7 +432,7 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
switch (id) {
case SPA_PARAM_EnumFormat:
if ((res = port_enum_formats(node, direction, port_id,
if ((res = port_enum_formats(this, direction, port_id,
result.index, &param, &b)) <= 0)
return res;
break;
@ -551,13 +546,13 @@ static int clear_buffers(struct impl *this, struct port *port)
}
return 0;
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
const struct spa_pod *format)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port, *other;
int res = 0;
@ -622,37 +617,35 @@ static int port_set_format(struct spa_node *node,
}
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)
{
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(object != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(node, direction, port_id), -EINVAL);
spa_return_val_if_fail(CHECK_PORT(object, direction, port_id), -EINVAL);
switch (id) {
case SPA_PARAM_Format:
return port_set_format(node, direction, port_id, flags, param);
return port_set_format(object, direction, port_id, flags, param);
default:
return -ENOENT;
}
}
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, size = SPA_ID_INVALID, j;
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);
@ -721,7 +714,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,
@ -733,17 +726,14 @@ 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 = GET_PORT(this, direction, port_id);
@ -784,15 +774,12 @@ static inline struct buffer *dequeue_buffer(struct impl *this, struct port *port
return b;
}
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(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id), -EINVAL);
port = GET_OUT_PORT(this, port_id);
@ -802,9 +789,9 @@ 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 *inport, *outport;
struct spa_io_buffers *inio, *outio;
struct buffer *inbuf, *outbuf;
@ -815,9 +802,7 @@ static int impl_node_process(struct spa_node *node)
int res = 0;
uint32_t n_samples, size, maxsize, offs;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
outport = GET_OUT_PORT(this, 0);
inport = GET_IN_PORT(this, 0);
@ -893,8 +878,8 @@ static int impl_node_process(struct spa_node *node)
return res;
}
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,
@ -995,7 +980,10 @@ impl_init(const struct spa_handle_factory *factory,
break;
}
}
this->node = impl_node;
this->node.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Node,
SPA_VERSION_NODE,
&impl_node, this);
spa_hook_list_init(&this->hooks);
if (this->cpu)

View file

@ -193,20 +193,19 @@ static int init_port(struct impl *this, enum spa_direction direction, uint32_t p
return 0;
}
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 *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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;
@ -233,20 +232,18 @@ 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;
struct impl *this = object;
int res;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
switch (id) {
case SPA_PARAM_Profile:
@ -310,15 +307,13 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
return 0;
}
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;
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);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
@ -333,20 +328,18 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
}
static int
impl_node_add_listener(struct spa_node *node,
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;
uint32_t i;
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_log_debug(this->log, NAME" %p: add listener %p", node, listener);
spa_log_debug(this->log, NAME" %p: add listener %p", this, listener);
spa_hook_list_isolate(&this->hooks, &save, listener, events, data);
emit_node_info(this, true);
@ -360,34 +353,32 @@ 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 *user_data)
{
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)
{
spa_return_val_if_fail(node != NULL, -EINVAL);
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)
{
spa_return_val_if_fail(node != NULL, -EINVAL);
return -ENOTSUP;
}
static int port_enum_formats(struct spa_node *node,
static int port_enum_formats(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port = GET_PORT(this, direction, port_id);
switch (index) {
@ -428,12 +419,12 @@ static int port_enum_formats(struct spa_node *node,
}
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 *param;
struct spa_pod_builder b = { 0 };
@ -442,11 +433,9 @@ 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_log_debug(this->log, "%p: enum params %d %d %u %u", this, seq, direction, port_id, id);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
@ -462,7 +451,7 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
switch (id) {
case SPA_PARAM_EnumFormat:
if ((res = port_enum_formats(node, direction, port_id, result.index, &param, &b)) <= 0)
if ((res = port_enum_formats(object, direction, port_id, result.index, &param, &b)) <= 0)
return res;
break;
case SPA_PARAM_Format:
@ -594,13 +583,13 @@ static int calc_width(struct spa_audio_info *info)
}
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
const struct spa_pod *format)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port;
int res;
@ -694,22 +683,20 @@ static int port_set_format(struct spa_node *node,
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;
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);
switch (id) {
case SPA_PARAM_Format:
return port_set_format(node, direction, port_id, flags, param);
return port_set_format(this, direction, port_id, flags, param);
default:
return -ENOENT;
}
@ -745,19 +732,17 @@ static struct buffer *dequeue_buffer(struct impl *this, struct port *port)
}
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, j;
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);
@ -813,7 +798,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,
@ -825,16 +810,14 @@ 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);
@ -850,14 +833,12 @@ impl_node_port_set_io(struct spa_node *node,
return 0;
}
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(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id), -EINVAL);
@ -924,9 +905,9 @@ static inline int handle_monitor(struct impl *this, const void *data, int n_samp
return res;
}
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 *outport;
struct spa_io_buffers *outio;
uint32_t i, maxsize, n_samples;
@ -937,9 +918,7 @@ static int impl_node_process(struct spa_node *node)
void **dst_datas;
int res = 0;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
outport = GET_OUT_PORT(this, 0);
outio = outport->io;
@ -1000,8 +979,8 @@ static int impl_node_process(struct spa_node *node)
return res | SPA_STATUS_HAVE_BUFFER;
}
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,
@ -1085,7 +1064,10 @@ impl_init(const struct spa_handle_factory *factory,
if (info != NULL && (str = spa_dict_lookup(info, "merger.monitor")) != NULL)
this->monitor = atoi(str);
this->node = impl_node;
this->node.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Node,
SPA_VERSION_NODE,
&impl_node, this);
spa_hook_list_init(&this->hooks);
this->info_all = SPA_NODE_CHANGE_MASK_FLAGS |

View file

@ -170,7 +170,7 @@ static int setup_convert(struct impl *this,
return err;
}
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)
{
@ -197,15 +197,13 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
return 0;
}
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;
struct impl *this = object;
int res = 0;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
switch (id) {
case SPA_PARAM_Props:
@ -218,13 +216,11 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
return res;
}
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)
{
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);
switch (id) {
case SPA_IO_Position:
@ -236,15 +232,13 @@ static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size
return 0;
}
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;
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);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
@ -281,17 +275,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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);
@ -304,32 +297,32 @@ 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 *user_data)
{
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;
}
static int port_enum_formats(struct spa_node *node,
static int port_enum_formats(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *other;
struct spa_pod_frame f;
@ -369,12 +362,12 @@ static int port_enum_formats(struct spa_node *node,
}
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, *other;
struct spa_pod *param;
struct spa_pod_builder b = { 0 };
@ -383,11 +376,9 @@ 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(this, direction, port_id), -EINVAL);
port = GET_PORT(this, direction, port_id);
@ -402,7 +393,7 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
switch (id) {
case SPA_PARAM_EnumFormat:
if ((res = port_enum_formats(node, direction, port_id,
if ((res = port_enum_formats(this, direction, port_id,
result.index, &param, &b)) <= 0)
return res;
break;
@ -493,13 +484,13 @@ static int clear_buffers(struct impl *this, struct port *port)
return 0;
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
const struct spa_pod *format)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port, *other;
int res = 0;
@ -554,36 +545,34 @@ static int port_set_format(struct spa_node *node,
}
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)
{
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(object != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(node, direction, port_id), -EINVAL);
spa_return_val_if_fail(CHECK_PORT(object, direction, port_id), -EINVAL);
if (id == SPA_PARAM_Format) {
return port_set_format(node, direction, port_id, flags, param);
return port_set_format(object, direction, port_id, flags, param);
}
else
return -ENOENT;
}
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, j, size = SPA_ID_INVALID;
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);
@ -635,7 +624,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,
@ -647,16 +636,14 @@ 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);
@ -706,13 +693,11 @@ static void dequeue_buffer(struct impl *this, struct buffer *b)
SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUT);
}
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;
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, SPA_DIRECTION_OUTPUT, port_id), -EINVAL);
@ -737,9 +722,9 @@ static int process_control(struct impl *this, struct port *port, struct spa_pod_
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 *outport, *inport;
struct spa_io_buffers *outio, *inio;
struct buffer *sbuf, *dbuf;
@ -750,9 +735,7 @@ static int impl_node_process(struct spa_node *node)
void **dst_datas;
bool flush_out = false;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
outport = GET_OUT_PORT(this, 0);
inport = GET_IN_PORT(this, 0);
@ -853,8 +836,8 @@ static int impl_node_process(struct spa_node *node)
return res;
}
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,
@ -957,7 +940,10 @@ impl_init(const struct spa_handle_factory *factory,
}
spa_log_debug(this->log, "mode:%d", this->mode);
this->node = impl_node;
this->node.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Node,
SPA_VERSION_NODE,
&impl_node, this);
spa_hook_list_init(&this->hooks);

View file

@ -189,22 +189,20 @@ static int init_port(struct impl *this, enum spa_direction direction,
return 0;
}
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 *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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:
@ -228,20 +226,18 @@ 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;
struct impl *this = object;
int res;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
switch (id) {
case SPA_PARAM_Profile:
@ -297,15 +293,13 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
return 0;
}
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;
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);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
@ -320,18 +314,17 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
}
static int
impl_node_add_listener(struct spa_node *node,
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;
uint32_t i;
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);
@ -345,34 +338,32 @@ 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 *user_data)
{
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)
{
spa_return_val_if_fail(node != NULL, -EINVAL);
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)
{
spa_return_val_if_fail(node != NULL, -EINVAL);
return -ENOTSUP;
}
static int port_enum_formats(struct spa_node *node,
static int port_enum_formats(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port = GET_PORT(this, direction, port_id);
switch (index) {
@ -418,12 +409,12 @@ static int port_enum_formats(struct spa_node *node,
}
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 *param;
struct spa_pod_builder b = { 0 };
@ -432,11 +423,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(this, direction, port_id), -EINVAL);
port = GET_PORT(this, direction, port_id);
@ -452,7 +440,7 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
switch (id) {
case SPA_PARAM_EnumFormat:
if ((res = port_enum_formats(node, direction, port_id,
if ((res = port_enum_formats(this, direction, port_id,
result.index, &param, &b)) <= 0)
return res;
break;
@ -587,13 +575,13 @@ static int calc_width(struct spa_audio_info *info)
}
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
const struct spa_pod *format)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port;
int res;
@ -666,22 +654,19 @@ static int port_set_format(struct spa_node *node,
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;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
switch (id) {
case SPA_PARAM_Format:
return port_set_format(node, direction, port_id, flags, param);
return port_set_format(this, direction, port_id, flags, param);
default:
return -ENOENT;
}
@ -717,20 +702,17 @@ static struct buffer *dequeue_buffer(struct impl *this, struct port *port)
}
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, j;
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 = GET_PORT(this, direction, port_id);
@ -777,7 +759,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,
@ -789,17 +771,14 @@ 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 = GET_PORT(this, direction, port_id);
@ -814,15 +793,12 @@ impl_node_port_set_io(struct spa_node *node,
return 0;
}
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(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id), -EINVAL);
port = GET_OUT_PORT(this, port_id);
@ -831,9 +807,9 @@ 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 *inport;
struct spa_io_buffers *inio;
uint32_t i, j, maxsize, n_samples;
@ -844,9 +820,7 @@ static int impl_node_process(struct spa_node *node)
void **dst_datas;
int res = 0;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
inport = GET_IN_PORT(this, 0);
inio = inport->io;
@ -936,8 +910,8 @@ static int impl_node_process(struct spa_node *node)
return res;
}
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,
@ -1018,7 +992,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();

View file

@ -131,33 +131,31 @@ struct impl {
#define GET_OUT_PORT(this,p) (&this->out_ports[p])
#define GET_PORT(this,d,p) (d == SPA_DIRECTION_INPUT ? GET_IN_PORT(this,p) : GET_OUT_PORT(this,p))
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)
{
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)
{
return -ENOTSUP;
}
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_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;
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);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
@ -192,18 +190,17 @@ 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;
uint32_t i;
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);
@ -219,23 +216,20 @@ 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 *user_data)
{
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)
{
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_FREE_IN_PORT(this, direction, port_id), -EINVAL);
port = GET_IN_PORT(this, port_id);
@ -274,15 +268,12 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio
}
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)
{
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_IN_PORT(this, direction, port_id), -EINVAL);
port = GET_IN_PORT(this, port_id);
@ -309,13 +300,13 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
return 0;
}
static int port_enum_formats(struct spa_node *node,
static int port_enum_formats(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
switch (index) {
case 0:
@ -347,12 +338,12 @@ static int port_enum_formats(struct spa_node *node,
}
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 *param;
struct spa_pod_builder b = { 0 };
@ -361,11 +352,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(this, direction, port_id), -EINVAL);
port = GET_PORT(this, direction, port_id);
@ -379,7 +367,7 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
switch (id) {
case SPA_PARAM_EnumFormat:
if ((res = port_enum_formats(node, direction, port_id,
if ((res = port_enum_formats(this, direction, port_id,
result.index, &param, &b)) <= 0)
return res;
break;
@ -463,13 +451,13 @@ static int clear_buffers(struct impl *this, struct port *port)
return 0;
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
const struct spa_pod *format)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port;
int res;
@ -542,41 +530,35 @@ static int port_set_format(struct spa_node *node,
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;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
if (id == SPA_PARAM_Format) {
return port_set_format(node, direction, port_id, flags, param);
return port_set_format(this, direction, port_id, flags, param);
}
else
return -ENOENT;
}
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 = GET_PORT(this, direction, port_id);
@ -617,7 +599,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,
@ -629,17 +611,14 @@ 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 = GET_PORT(this, direction, port_id);
@ -667,14 +646,11 @@ static void recycle_buffer(struct impl *this, uint32_t id)
spa_log_trace(this->log, NAME " %p: recycle buffer %d", this, id);
}
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;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id), -EINVAL);
recycle_buffer(this, buffer_id);
@ -808,17 +784,15 @@ static int mix_output(struct impl *this, size_t n_bytes)
return SPA_STATUS_HAVE_BUFFER;
}
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 *outport;
struct spa_io_buffers *outio;
uint32_t i;
size_t min_queued = SIZE_MAX;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
outport = GET_OUT_PORT(this, 0);
outio = outport->io;
@ -869,8 +843,8 @@ static int impl_node_process(struct spa_node *node)
return outio->status;
}
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,
@ -943,7 +917,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 = SPA_NODE_INFO_INIT();
this->info.max_input_ports = MAX_PORTS;
this->info.max_output_ports = 1;

View file

@ -136,22 +136,20 @@ struct impl {
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < MAX_PORTS)
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 *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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:
@ -241,14 +239,12 @@ static int impl_node_enum_params(struct spa_node *node, int seq,
return 0;
}
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;
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 (id == SPA_PARAM_Props) {
struct props *p = &this->props;
@ -275,7 +271,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
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;
}
@ -390,15 +386,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)) {
@ -472,17 +467,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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);
@ -494,29 +488,27 @@ 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);
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
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;
}
@ -550,12 +542,12 @@ port_enum_formats(struct impl *this,
}
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];
@ -564,11 +556,9 @@ 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(this, direction, port_id), -EINVAL);
port = &this->port;
@ -737,16 +727,14 @@ port_set_format(struct impl *this,
}
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;
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);
@ -757,19 +745,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);
@ -805,7 +791,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,
@ -813,12 +799,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);
@ -831,18 +815,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);
@ -875,14 +857,12 @@ static inline void reuse_buffer(struct impl *this, struct port *port, uint32_t i
set_timer(this, true);
}
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;
@ -915,15 +895,14 @@ static int process_control(struct impl *this, struct spa_pod_sequence *sequence)
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;
@ -946,8 +925,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,
@ -1032,7 +1011,11 @@ 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_PROPS |
SPA_NODE_CHANGE_MASK_PARAMS;

View file

@ -156,22 +156,20 @@ static void reset_props(struct props *props)
props->max_latency = default_max_latency;
}
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 *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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:
@ -272,14 +270,12 @@ static inline bool is_slaved(struct impl *this)
return this->position && this->clock && this->position->clock.id != this->clock->id;
}
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)
{
struct impl *this;
struct impl *this = object;
bool slaved;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
switch (id) {
case SPA_IO_Clock:
@ -301,14 +297,12 @@ static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size
return 0;
}
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;
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);
switch (id) {
case SPA_PARAM_Props:
@ -878,16 +872,15 @@ static int do_stop(struct impl *this)
return 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;
int res;
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)) {
@ -938,17 +931,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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);
@ -960,40 +952,38 @@ 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);
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
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)
static int impl_node_remove_port(void *object, enum spa_direction direction, uint32_t port_id)
{
return -ENOTSUP;
}
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 *param;
struct spa_pod_builder b = { 0 };
@ -1001,11 +991,9 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
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);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
port = &this->port;
@ -1173,18 +1161,16 @@ 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;
int res;
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;
@ -1200,17 +1186,15 @@ 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;
@ -1246,7 +1230,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,
@ -1254,14 +1238,11 @@ 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);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(buffers != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
port = &this->port;
@ -1272,18 +1253,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;
@ -1298,21 +1277,20 @@ impl_node_port_set_io(struct spa_node *node,
return 0;
}
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)
{
return -ENOTSUP;
}
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;
uint64_t now_time;
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);
@ -1348,8 +1326,8 @@ static int impl_node_process(struct spa_node *node)
return SPA_STATUS_HAVE_BUFFER;
}
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,
@ -1444,7 +1422,10 @@ impl_init(const struct spa_handle_factory *factory,
return -EINVAL;
}
this->node = impl_node;
this->node.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Node,
SPA_VERSION_NODE,
&impl_node, this);
spa_hook_list_init(&this->hooks);
reset_props(&this->props);

View file

@ -132,22 +132,20 @@ static void reset_props(struct props *props)
props->max_latency = default_max_latency;
}
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 *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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:
@ -226,14 +224,12 @@ static inline bool is_slaved(struct impl *this)
return this->position && this->clock && this->position->clock.id != this->clock->id;
}
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)
{
struct impl *this;
struct impl *this = object;
bool slaved;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
switch (id) {
case SPA_IO_Clock:
@ -255,14 +251,12 @@ static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size
return 0;
}
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;
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);
switch (id) {
case SPA_PARAM_Props:
@ -531,16 +525,15 @@ static int do_stop(struct impl *this)
return 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;
int res;
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)) {
@ -591,17 +584,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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);
@ -613,40 +605,38 @@ 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);
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
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)
static int impl_node_remove_port(void *object, enum spa_direction direction, uint32_t port_id)
{
return -ENOTSUP;
}
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 *param;
struct spa_pod_builder b = { 0 };
@ -654,11 +644,9 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
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);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
port = &this->port;
@ -828,17 +816,16 @@ 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;
int res;
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;
@ -855,17 +842,15 @@ 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;
@ -901,7 +886,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,
@ -909,14 +894,12 @@ 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);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(buffers != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
port = &this->port;
@ -927,18 +910,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;
@ -964,14 +945,12 @@ static void recycle_buffer(struct impl *this, struct port *port, uint32_t buffer
}
}
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;
@ -987,17 +966,16 @@ 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;
struct buffer *b;
/* get 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);
@ -1029,8 +1007,8 @@ static int impl_node_process(struct spa_node *node)
return SPA_STATUS_HAVE_BUFFER;
}
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,
@ -1136,7 +1114,10 @@ impl_init(const struct spa_handle_factory *factory,
return -EINVAL;
}
this->node = impl_node;
this->node.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Node,
SPA_VERSION_NODE,
&impl_node, this);
spa_hook_list_init(&this->hooks);
reset_props(&this->props);

View file

@ -184,18 +184,17 @@ static const struct spa_dict_item info_items[] = {
{ "media.class", "Audio/Device" },
};
static int impl_add_listener(struct spa_device *device,
static int impl_add_listener(void *object,
struct spa_hook *listener,
const struct spa_device_events *events,
void *data)
{
struct impl *this;
struct impl *this = object;
struct spa_hook_list save;
spa_return_val_if_fail(device != NULL, -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(events != NULL, -EINVAL);
this = SPA_CONTAINER_OF(device, struct impl, device);
spa_hook_list_isolate(&this->hooks, &save, listener, events, data);
if (events->info) {
@ -222,25 +221,25 @@ static int impl_add_listener(struct spa_device *device,
}
static int impl_enum_params(struct spa_device *device, int seq,
static int impl_enum_params(void *object, int seq,
uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter)
{
return -ENOTSUP;
}
static int impl_set_param(struct spa_device *device,
static int impl_set_param(void *object,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return -ENOTSUP;
}
static const struct spa_device impl_device = {
SPA_VERSION_DEVICE,
impl_add_listener,
impl_enum_params,
impl_set_param,
static const struct spa_device_methods impl_device = {
SPA_VERSION_DEVICE_METHODS,
.add_listener = impl_add_listener,
.enum_params = impl_enum_params,
.set_param = impl_set_param,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
@ -309,7 +308,10 @@ impl_init(const struct spa_handle_factory *factory,
spa_log_error(this->log, "a device is needed");
return -EINVAL;
}
this->device = impl_device;
this->device.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Device,
SPA_VERSION_DEVICE,
&impl_device, this);
spa_hook_list_init(&this->hooks);

View file

@ -2184,15 +2184,13 @@ fail:
}
static int
impl_monitor_set_callbacks(struct spa_monitor *monitor,
impl_monitor_set_callbacks(void *object,
const struct spa_monitor_callbacks *callbacks,
void *data)
{
struct spa_bt_monitor *this;
struct spa_bt_monitor *this = object;
spa_return_val_if_fail(monitor != NULL, -EINVAL);
this = SPA_CONTAINER_OF(monitor, struct spa_bt_monitor, monitor);
spa_return_val_if_fail(this != NULL, -EINVAL);
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
@ -2204,9 +2202,9 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
return 0;
}
static const struct spa_monitor impl_monitor = {
SPA_VERSION_MONITOR,
impl_monitor_set_callbacks,
static const struct spa_monitor_methods impl_monitor = {
SPA_VERSION_MONITOR_METHODS,
.set_callbacks = impl_monitor_set_callbacks,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
@ -2281,7 +2279,10 @@ impl_init(const struct spa_handle_factory *factory,
}
this->conn = spa_dbus_connection_get(this->dbus_connection);
this->monitor = impl_monitor;
this->monitor.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Monitor,
SPA_VERSION_MONITOR,
&impl_monitor, this);
spa_list_init(&this->adapter_list);
spa_list_init(&this->device_list);
@ -2312,7 +2313,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
}
const struct spa_handle_factory spa_bluez5_monitor_factory = {
SPA_VERSION_MONITOR,
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
impl_get_size,

View file

@ -88,34 +88,32 @@ struct impl {
bool started;
};
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)
{
return -ENOTSUP;
}
static int impl_node_set_param(struct spa_node *node,
static int impl_node_set_param(void *object,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return -ENOTSUP;
}
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_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;
if (node == NULL || command == NULL)
if (this == NULL || command == NULL)
return -EINVAL;
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
@ -151,17 +149,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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);
@ -174,7 +171,7 @@ 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 *user_data)
{
@ -182,32 +179,28 @@ impl_node_set_callbacks(struct spa_node *node,
}
static int
impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
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,
impl_node_remove_port(void *object,
enum spa_direction direction,
uint32_t port_id)
{
return -ENOTSUP;
}
static int port_enum_formats(struct spa_node *node,
static int port_enum_formats(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
const struct spa_pod *filter,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
//struct impl *this;
//this = SPA_CONTAINER_OF (node, struct impl, node);
if (!IS_VALID_PORT(this, direction, port_id))
if (!IS_VALID_PORT(object, direction, port_id))
return -EINVAL;
switch (index) {
@ -220,14 +213,14 @@ static int port_enum_formats(struct spa_node *node,
return 1;
}
static int port_get_format(struct spa_node *node,
static int port_get_format(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
const struct spa_pod *filter,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port;
port = GET_PORT(this, direction, port_id);
@ -244,12 +237,12 @@ static int port_get_format(struct spa_node *node,
}
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 = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
struct spa_pod *param;
@ -266,13 +259,13 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
switch (id) {
case SPA_PARAM_EnumFormat:
if ((res = port_enum_formats(node, direction, port_id,
if ((res = port_enum_formats(this, direction, port_id,
result.index, filter, &param, &b)) <= 0)
return res;
break;
case SPA_PARAM_Format:
if ((res = port_get_format(node, direction, port_id,
if ((res = port_get_format(this, direction, port_id,
result.index, filter, &param, &b)) <= 0)
return res;
break;
@ -292,20 +285,18 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
return 0;
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t flags,
const struct spa_pod *format)
{
struct impl *this;
struct impl *this = object;
struct port *port;
int res;
if (node == NULL || format == NULL)
if (this == NULL || format == NULL)
return -EINVAL;
this = SPA_CONTAINER_OF(node, struct impl, node);
if (!IS_VALID_PORT(this, direction, port_id))
return -EINVAL;
@ -335,36 +326,36 @@ static int port_set_format(struct spa_node *node,
}
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)
{
if (id == SPA_PARAM_Format) {
return port_set_format(node, direction, port_id, flags, param);
return port_set_format(object, direction, port_id, flags, param);
}
else
return -ENOENT;
}
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)
{
if (node == NULL)
if (object == NULL)
return -EINVAL;
if (!IS_VALID_PORT(node, direction, port_id))
if (!IS_VALID_PORT(object, direction, port_id))
return -EINVAL;
return -ENOTSUP;
}
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,
@ -376,20 +367,18 @@ 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;
if (node == NULL)
if (this == NULL)
return -EINVAL;
this = SPA_CONTAINER_OF(node, struct impl, node);
if (!IS_VALID_PORT(this, direction, port_id))
return -EINVAL;
@ -403,17 +392,15 @@ impl_node_port_set_io(struct spa_node *node,
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 *output;
if (node == NULL)
if (this == NULL)
return -EINVAL;
this = SPA_CONTAINER_OF(node, struct impl, node);
port = &this->out_ports[0];
if ((output = port->io) == NULL)
@ -429,9 +416,9 @@ static int impl_node_process(struct spa_node *node)
}
static int
impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
impl_node_port_reuse_buffer(void *object, uint32_t port_id, uint32_t buffer_id)
{
if (node == NULL)
if (object == NULL)
return -EINVAL;
if (port_id != 0)
@ -440,8 +427,8 @@ impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t bu
return -ENOTSUP;
}
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,
@ -498,7 +485,10 @@ spa_ffmpeg_dec_init(struct spa_handle *handle,
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;
this->info = SPA_NODE_INFO_INIT();
this->info.max_input_ports = 1;

View file

@ -87,33 +87,31 @@ struct impl {
bool started;
};
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)
{
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)
{
return -ENOTSUP;
}
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_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;
if (node == NULL || command == NULL)
if (this == NULL || command == NULL)
return -EINVAL;
this = SPA_CONTAINER_OF(node, struct impl, node);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
@ -149,17 +147,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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);
@ -172,7 +169,7 @@ 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 *user_data)
{
@ -180,20 +177,20 @@ impl_node_set_callbacks(struct spa_node *node,
}
static int
impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
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,
impl_node_remove_port(void *object,
enum spa_direction direction, uint32_t port_id)
{
return -ENOTSUP;
}
static int port_enum_formats(struct spa_node *node,
static int port_enum_formats(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
const struct spa_pod *filter,
@ -203,14 +200,14 @@ static int port_enum_formats(struct spa_node *node,
return -ENOTSUP;
}
static int port_get_format(struct spa_node *node,
static int port_get_format(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
const struct spa_pod *filter,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port;
port = GET_PORT(this, direction, port_id);
@ -227,12 +224,12 @@ static int port_get_format(struct spa_node *node,
}
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 spa_pod_builder b = { 0 };
uint8_t buffer[1024];
struct spa_pod *param;
@ -240,8 +237,6 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
uint32_t count = 0;
int res;
this = SPA_CONTAINER_OF(node, struct impl, node);
result.id = id;
result.next = start;
next:
@ -251,13 +246,13 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
switch (id) {
case SPA_PARAM_EnumFormat:
if ((res = port_enum_formats(node, direction, port_id,
if ((res = port_enum_formats(this, direction, port_id,
result.index, filter, &param, &b)) <= 0)
return res;
break;
case SPA_PARAM_Format:
if ((res = port_get_format(node, direction, port_id,
if ((res = port_get_format(this, direction, port_id,
result.index, filter, &param, &b)) <= 0)
return res;
break;
@ -277,11 +272,11 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
return 0;
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t flags, const struct spa_pod *format)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port;
int res;
@ -311,35 +306,35 @@ static int port_set_format(struct spa_node *node,
}
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)
{
if (id == SPA_PARAM_Format) {
return port_set_format(node, direction, port_id, flags, param);
return port_set_format(object, direction, port_id, flags, param);
}
else
return -ENOENT;
}
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)
{
if (node == NULL)
if (object == NULL)
return -EINVAL;
if (!IS_VALID_PORT(node, direction, port_id))
if (!IS_VALID_PORT(object, direction, port_id))
return -EINVAL;
return -ENOTSUP;
}
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,
@ -351,20 +346,18 @@ 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;
if (node == NULL)
if (this == NULL)
return -EINVAL;
this = SPA_CONTAINER_OF(node, struct impl, node);
if (!IS_VALID_PORT(this, direction, port_id))
return -EINVAL;
@ -379,9 +372,9 @@ impl_node_port_set_io(struct spa_node *node,
}
static int
impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
impl_node_port_reuse_buffer(void *object, uint32_t port_id, uint32_t buffer_id)
{
if (node == NULL)
if (object == NULL)
return -EINVAL;
if (port_id != 0)
@ -390,17 +383,15 @@ impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t bu
return -ENOTSUP;
}
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 *output;
if (node == NULL)
if (this == NULL)
return -EINVAL;
this = SPA_CONTAINER_OF(node, struct impl, node);
if ((output = this->out_ports[0].io) == NULL)
return -EIO;
@ -415,8 +406,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,
@ -472,7 +463,10 @@ spa_ffmpeg_enc_init(struct spa_handle *handle,
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;
this->info = SPA_NODE_INFO_INIT();
this->info.max_input_ports = 1;

View file

@ -33,6 +33,7 @@
#include <spa/support/cpu.h>
#include <spa/support/plugin.h>
#include <spa/utils/type.h>
#include <spa/utils/hook.h>
#define NAME "cpu"
@ -57,18 +58,18 @@ struct impl {
#endif
static uint32_t
impl_cpu_get_flags(struct spa_cpu *cpu)
impl_cpu_get_flags(void *object)
{
struct impl *impl = SPA_CONTAINER_OF(cpu, struct impl, cpu);
struct impl *impl = object;
if (impl->force != SPA_CPU_FORCE_AUTODETECT)
return impl->force;
return impl->flags;
}
static int
impl_cpu_force_flags(struct spa_cpu *cpu, uint32_t flags)
impl_cpu_force_flags(void *object, uint32_t flags)
{
struct impl *impl = SPA_CONTAINER_OF(cpu, struct impl, cpu);
struct impl *impl = object;
impl->force = flags;
return 0;
}
@ -83,26 +84,25 @@ static uint32_t get_count(struct impl *this)
}
static uint32_t
impl_cpu_get_count(struct spa_cpu *cpu)
impl_cpu_get_count(void *object)
{
struct impl *impl = SPA_CONTAINER_OF(cpu, struct impl, cpu);
struct impl *impl = object;
return impl->count;
}
static uint32_t
impl_cpu_get_max_align(struct spa_cpu *cpu)
impl_cpu_get_max_align(void *object)
{
struct impl *impl = SPA_CONTAINER_OF(cpu, struct impl, cpu);
struct impl *impl = object;
return impl->max_align;
}
static const struct spa_cpu impl_cpu = {
SPA_VERSION_CPU,
NULL,
impl_cpu_get_flags,
impl_cpu_force_flags,
impl_cpu_get_count,
impl_cpu_get_max_align,
static const struct spa_cpu_methods impl_cpu = {
SPA_VERSION_CPU_METHODS,
.get_flags = impl_cpu_get_flags,
.force_flags = impl_cpu_force_flags,
.get_count = impl_cpu_get_count,
.get_max_align = impl_cpu_get_max_align,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
@ -152,7 +152,10 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct impl *) handle;
this->cpu = impl_cpu;
this->cpu.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_CPU,
SPA_VERSION_CPU,
&impl_cpu, this);
for (i = 0; i < n_support; i++) {
if (support[i].type == SPA_TYPE_INTERFACE_Log)

View file

@ -280,10 +280,10 @@ static const struct spa_dbus_connection impl_connection = {
};
static struct spa_dbus_connection *
impl_get_connection(struct spa_dbus *dbus,
impl_get_connection(void *object,
enum spa_dbus_type type)
{
struct impl *impl = SPA_CONTAINER_OF(dbus, struct impl, dbus);
struct impl *impl = object;
struct connection *conn;
DBusError error;
@ -318,9 +318,9 @@ impl_get_connection(struct spa_dbus *dbus,
return NULL;
}
static const struct spa_dbus impl_dbus = {
SPA_VERSION_DBUS,
impl_get_connection,
static const struct spa_dbus_methods impl_dbus = {
SPA_VERSION_DBUS_METHODS,
.get_connection = impl_get_connection,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
@ -372,7 +372,10 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct impl *) handle;
spa_list_init(&this->connection_list);
this->dbus = impl_dbus;
this->dbus.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_DBus,
SPA_VERSION_DBUS,
&impl_dbus, this);
for (i = 0; i < n_support; i++) {
if (support[i].type == SPA_TYPE_INTERFACE_Log)

View file

@ -56,7 +56,7 @@ struct impl {
};
static void
impl_log_logv(struct spa_log *log,
impl_log_logv(void *object,
enum spa_log_level level,
const char *file,
int line,
@ -64,7 +64,7 @@ impl_log_logv(struct spa_log *log,
const char *fmt,
va_list args)
{
struct impl *impl = SPA_CONTAINER_OF(log, struct impl, log);
struct impl *impl = object;
char text[512], location[1024];
static const char *levels[] = { "-", "E", "W", "I", "D", "T", "*T*" };
const char *prefix = "", *suffix = "";
@ -107,7 +107,7 @@ impl_log_logv(struct spa_log *log,
static void
impl_log_log(struct spa_log *log,
impl_log_log(void *object,
enum spa_log_level level,
const char *file,
int line,
@ -116,7 +116,7 @@ impl_log_log(struct spa_log *log,
{
va_list args;
va_start(args, fmt);
impl_log_logv(log, level, file, line, func, fmt, args);
impl_log_logv(object, level, file, line, func, fmt, args);
va_end(args);
}
@ -149,12 +149,10 @@ static void on_trace_event(struct spa_source *source)
}
}
static const struct spa_log impl_log = {
SPA_VERSION_LOG,
DEFAULT_LOG_LEVEL,
NULL,
impl_log_log,
impl_log_logv,
static const struct spa_log_methods impl_log = {
SPA_VERSION_LOG_METHODS,
.log = impl_log_log,
.logv = impl_log_logv,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
@ -217,7 +215,11 @@ impl_init(const struct spa_handle_factory *factory,
this = (struct impl *) handle;
this->log = impl_log;
this->log.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Log,
SPA_VERSION_LOG,
&impl_log, this);
this->log.level = DEFAULT_LOG_LEVEL;
for (i = 0; i < n_support; i++) {
if (support[i].type == SPA_TYPE_INTERFACE_MainLoop)
@ -281,7 +283,7 @@ const struct spa_handle_factory spa_support_logger_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
impl_get_size,
impl_init,
impl_enum_interface_info,
.get_size = impl_get_size,
.init = impl_init,
.enum_interface_info = impl_enum_interface_info,
};

View file

@ -59,7 +59,7 @@ struct invoke_item {
int res;
};
static void loop_signal_event(struct spa_source *source);
static void loop_signal_event(void *object, struct spa_source *source);
struct impl {
struct spa_handle handle;
@ -134,11 +134,11 @@ static inline enum spa_io spa_epoll_to_io(uint32_t events)
return mask;
}
static int loop_add_source(struct spa_loop *loop, struct spa_source *source)
static int loop_add_source(void *object, struct spa_source *source)
{
struct impl *impl = SPA_CONTAINER_OF(loop, struct impl, loop);
struct impl *impl = object;
source->loop = loop;
source->loop = (struct spa_loop*) &impl->loop;
if (source->fd != -1) {
struct epoll_event ep;
@ -153,10 +153,9 @@ static int loop_add_source(struct spa_loop *loop, struct spa_source *source)
return 0;
}
static int loop_update_source(struct spa_source *source)
static int loop_update_source(void *object, struct spa_source *source)
{
struct spa_loop *loop = source->loop;
struct impl *impl = SPA_CONTAINER_OF(loop, struct impl, loop);
struct impl *impl = object;
if (source->fd != -1) {
struct epoll_event ep;
@ -171,19 +170,19 @@ static int loop_update_source(struct spa_source *source)
return 0;
}
static void loop_remove_source(struct spa_source *source)
static int loop_remove_source(void *object, struct spa_source *source)
{
struct spa_loop *loop = source->loop;
struct impl *impl = SPA_CONTAINER_OF(loop, struct impl, loop);
struct impl *impl = object;
if (source->fd != -1)
epoll_ctl(impl->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL);
source->loop = NULL;
return 0;
}
static int
loop_invoke(struct spa_loop *loop,
loop_invoke(void *object,
spa_invoke_func_t func,
uint32_t seq,
const void *data,
@ -191,13 +190,13 @@ loop_invoke(struct spa_loop *loop,
bool block,
void *user_data)
{
struct impl *impl = SPA_CONTAINER_OF(loop, struct impl, loop);
struct impl *impl = object;
bool in_thread = pthread_equal(impl->thread, pthread_self());
struct invoke_item *item;
int res;
if (in_thread) {
res = func(loop, false, seq, data, size, user_data);
res = func(object, false, seq, data, size, user_data);
} else {
int32_t filled;
uint32_t avail, idx, offset, l0;
@ -236,7 +235,7 @@ loop_invoke(struct spa_loop *loop,
spa_ringbuffer_write_update(&impl->buffer, idx + item->item_size);
spa_loop_utils_signal_event(&impl->utils, impl->wakeup);
spa_loop_utils_signal_event((struct spa_loop_utils*)&impl->utils, impl->wakeup);
if (block) {
uint64_t count = 1;
@ -272,7 +271,8 @@ static void wakeup_func(void *data, uint64_t count)
item = SPA_MEMBER(impl->buffer_data, index & (DATAS_SIZE - 1), struct invoke_item);
block = item->block;
item->res = item->func(&impl->loop, true, item->seq, item->data, item->size,
item->res = item->func((struct spa_loop *)&impl->loop,
true, item->seq, item->data, item->size,
item->user_data);
spa_ringbuffer_read_update(&impl->buffer, index + item->item_size);
@ -286,33 +286,31 @@ static void wakeup_func(void *data, uint64_t count)
}
}
static int loop_get_fd(struct spa_loop_control *ctrl)
static int loop_get_fd(void *object)
{
struct impl *impl = SPA_CONTAINER_OF(ctrl, struct impl, control);
struct impl *impl = object;
return impl->epoll_fd;
}
static void
loop_add_hooks(struct spa_loop_control *ctrl,
struct spa_hook *hook,
const struct spa_loop_control_hooks *hooks,
void *data)
loop_add_hook(void *object,
struct spa_hook *hook,
const struct spa_loop_control_hooks *hooks,
void *data)
{
struct impl *impl = SPA_CONTAINER_OF(ctrl, struct impl, control);
struct impl *impl = object;
spa_hook_list_append(&impl->hooks_list, hook, hooks, data);
}
static void loop_enter(struct spa_loop_control *ctrl)
static void loop_enter(void *object)
{
struct impl *impl = SPA_CONTAINER_OF(ctrl, struct impl, control);
struct impl *impl = object;
impl->thread = pthread_self();
}
static void loop_leave(struct spa_loop_control *ctrl)
static void loop_leave(void *object)
{
struct impl *impl = SPA_CONTAINER_OF(ctrl, struct impl, control);
struct impl *impl = object;
impl->thread = 0;
}
@ -324,10 +322,10 @@ static inline void process_destroy(struct impl *impl)
spa_list_init(&impl->destroy_list);
}
static int loop_iterate(struct spa_loop_control *ctrl, int timeout)
static int loop_iterate(void *object, int timeout)
{
struct impl *impl = SPA_CONTAINER_OF(ctrl, struct impl, control);
struct spa_loop *loop = &impl->loop;
struct impl *impl = object;
struct spa_loop *loop = (struct spa_loop *)&impl->loop;
struct epoll_event ep[32];
int i, nfds, save_errno = 0;
@ -364,19 +362,19 @@ static void source_io_func(struct spa_source *source)
impl->func.io(source->data, source->fd, source->rmask);
}
static struct spa_source *loop_add_io(struct spa_loop_utils *utils,
static struct spa_source *loop_add_io(void *object,
int fd,
enum spa_io mask,
bool close, spa_source_io_func_t func, void *data)
{
struct impl *impl = SPA_CONTAINER_OF(utils, struct impl, utils);
struct impl *impl = object;
struct source_impl *source;
source = calloc(1, sizeof(struct source_impl));
if (source == NULL)
return NULL;
source->source.loop = &impl->loop;
source->source.loop = (struct spa_loop *) &impl->loop;
source->source.func = source_io_func;
source->source.data = data;
source->source.fd = fd;
@ -385,14 +383,14 @@ static struct spa_source *loop_add_io(struct spa_loop_utils *utils,
source->close = close;
source->func.io = func;
spa_loop_add_source(&impl->loop, &source->source);
spa_loop_add_source(source->source.loop, &source->source);
spa_list_insert(&impl->source_list, &source->link);
return &source->source;
}
static int loop_update_io(struct spa_source *source, enum spa_io mask)
static int loop_update_io(void *object, struct spa_source *source, enum spa_io mask)
{
source->mask = mask;
return spa_loop_update_source(source->loop, source);
@ -405,17 +403,17 @@ static void source_idle_func(struct spa_source *source)
impl->func.idle(source->data);
}
static struct spa_source *loop_add_idle(struct spa_loop_utils *utils,
static struct spa_source *loop_add_idle(void *object,
bool enabled, spa_source_idle_func_t func, void *data)
{
struct impl *impl = SPA_CONTAINER_OF(utils, struct impl, utils);
struct impl *impl = object;
struct source_impl *source;
source = calloc(1, sizeof(struct source_impl));
if (source == NULL)
return NULL;
source->source.loop = &impl->loop;
source->source.loop = (struct spa_loop *)&impl->loop;
source->source.func = source_idle_func;
source->source.data = data;
source->source.fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
@ -424,19 +422,20 @@ static struct spa_source *loop_add_idle(struct spa_loop_utils *utils,
source->source.mask = SPA_IO_IN;
source->func.idle = func;
spa_loop_add_source(&impl->loop, &source->source);
spa_loop_add_source(source->source.loop, &source->source);
spa_list_insert(&impl->source_list, &source->link);
if (enabled)
spa_loop_utils_enable_idle(&impl->utils, &source->source, true);
spa_loop_utils_enable_idle((struct spa_loop_utils*)&impl->utils,
&source->source, true);
return &source->source;
}
static void loop_enable_idle(struct spa_source *source, bool enabled)
static void loop_enable_idle(void *object, struct spa_source *source, bool enabled)
{
struct source_impl *impl = SPA_CONTAINER_OF(source, struct source_impl, source);
struct source_impl *impl = object;
uint64_t count;
if (enabled && !impl->enabled) {
@ -464,17 +463,17 @@ static void source_event_func(struct spa_source *source)
impl->func.event(source->data, count);
}
static struct spa_source *loop_add_event(struct spa_loop_utils *utils,
static struct spa_source *loop_add_event(void *object,
spa_source_event_func_t func, void *data)
{
struct impl *impl = SPA_CONTAINER_OF(utils, struct impl, utils);
struct impl *impl = object;
struct source_impl *source;
source = calloc(1, sizeof(struct source_impl));
if (source == NULL)
return NULL;
source->source.loop = &impl->loop;
source->source.loop = (struct spa_loop *)&impl->loop;
source->source.func = source_event_func;
source->source.data = data;
source->source.fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
@ -483,14 +482,14 @@ static struct spa_source *loop_add_event(struct spa_loop_utils *utils,
source->close = true;
source->func.event = func;
spa_loop_add_source(&impl->loop, &source->source);
spa_loop_add_source(source->source.loop, &source->source);
spa_list_insert(&impl->source_list, &source->link);
return &source->source;
}
static void loop_signal_event(struct spa_source *source)
static void loop_signal_event(void *object, struct spa_source *source)
{
struct source_impl *impl = SPA_CONTAINER_OF(source, struct source_impl, source);
uint64_t count = 1;
@ -512,17 +511,17 @@ static void source_timer_func(struct spa_source *source)
impl->func.timer(source->data, expirations);
}
static struct spa_source *loop_add_timer(struct spa_loop_utils *utils,
static struct spa_source *loop_add_timer(void *object,
spa_source_timer_func_t func, void *data)
{
struct impl *impl = SPA_CONTAINER_OF(utils, struct impl, utils);
struct impl *impl = object;
struct source_impl *source;
source = calloc(1, sizeof(struct source_impl));
if (source == NULL)
return NULL;
source->source.loop = &impl->loop;
source->source.loop = (struct spa_loop*)&impl->loop;
source->source.func = source_timer_func;
source->source.data = data;
source->source.fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
@ -531,7 +530,7 @@ static struct spa_source *loop_add_timer(struct spa_loop_utils *utils,
source->close = true;
source->func.timer = func;
spa_loop_add_source(&impl->loop, &source->source);
spa_loop_add_source(source->source.loop, &source->source);
spa_list_insert(&impl->source_list, &source->link);
@ -539,7 +538,7 @@ static struct spa_source *loop_add_timer(struct spa_loop_utils *utils,
}
static int
loop_update_timer(struct spa_source *source,
loop_update_timer(void *object, struct spa_source *source,
struct timespec *value, struct timespec *interval, bool absolute)
{
struct itimerspec its;
@ -577,11 +576,11 @@ static void source_signal_func(struct spa_source *source)
impl->func.signal(source->data, impl->signal_number);
}
static struct spa_source *loop_add_signal(struct spa_loop_utils *utils,
static struct spa_source *loop_add_signal(void *object,
int signal_number,
spa_source_signal_func_t func, void *data)
{
struct impl *impl = SPA_CONTAINER_OF(utils, struct impl, utils);
struct impl *impl = object;
struct source_impl *source;
sigset_t mask;
@ -589,7 +588,7 @@ static struct spa_source *loop_add_signal(struct spa_loop_utils *utils,
if (source == NULL)
return NULL;
source->source.loop = &impl->loop;
source->source.loop = (struct spa_loop *)&impl->loop;
source->source.func = source_signal_func;
source->source.data = data;
@ -604,14 +603,14 @@ static struct spa_source *loop_add_signal(struct spa_loop_utils *utils,
source->func.signal = func;
source->signal_number = signal_number;
spa_loop_add_source(&impl->loop, &source->source);
spa_loop_add_source(source->source.loop, &source->source);
spa_list_insert(&impl->source_list, &source->link);
return &source->source;
}
static void loop_destroy_source(struct spa_source *source)
static void loop_destroy_source(void *object, struct spa_source *source)
{
struct source_impl *impl = SPA_CONTAINER_OF(source, struct source_impl, source);
@ -627,35 +626,35 @@ static void loop_destroy_source(struct spa_source *source)
spa_list_insert(&impl->impl->destroy_list, &impl->link);
}
static const struct spa_loop impl_loop = {
SPA_VERSION_LOOP,
loop_add_source,
loop_update_source,
loop_remove_source,
loop_invoke,
static const struct spa_loop_methods impl_loop = {
SPA_VERSION_LOOP_METHODS,
.add_source = loop_add_source,
.update_source = loop_update_source,
.remove_source = loop_remove_source,
.invoke = loop_invoke,
};
static const struct spa_loop_control impl_loop_control = {
SPA_VERSION_LOOP_CONTROL,
loop_get_fd,
loop_add_hooks,
loop_enter,
loop_leave,
loop_iterate,
static const struct spa_loop_control_methods impl_loop_control = {
SPA_VERSION_LOOP_CONTROL_METHODS,
.get_fd = loop_get_fd,
.add_hook = loop_add_hook,
.enter = loop_enter,
.leave = loop_leave,
.iterate = loop_iterate,
};
static const struct spa_loop_utils impl_loop_utils = {
SPA_VERSION_LOOP_UTILS,
loop_add_io,
loop_update_io,
loop_add_idle,
loop_enable_idle,
loop_add_event,
loop_signal_event,
loop_add_timer,
loop_update_timer,
loop_add_signal,
loop_destroy_source,
static const struct spa_loop_utils_methods impl_loop_utils = {
SPA_VERSION_LOOP_UTILS_METHODS,
.add_io = loop_add_io,
.update_io = loop_update_io,
.add_idle = loop_add_idle,
.enable_idle = loop_enable_idle,
.add_event = loop_add_event,
.signal_event = loop_signal_event,
.add_timer = loop_add_timer,
.update_timer = loop_update_timer,
.add_signal = loop_add_signal,
.destroy_source = loop_destroy_source,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
@ -693,7 +692,7 @@ static int impl_clear(struct spa_handle *handle)
impl = (struct impl *) handle;
spa_list_consume(source, &impl->source_list, link)
loop_destroy_source(&source->source);
loop_destroy_source(impl, &source->source);
process_destroy(impl);
@ -727,9 +726,18 @@ impl_init(const struct spa_handle_factory *factory,
handle->clear = impl_clear;
impl = (struct impl *) handle;
impl->loop = impl_loop;
impl->control = impl_loop_control;
impl->utils = impl_loop_utils;
impl->loop.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Loop,
SPA_VERSION_LOOP,
&impl_loop, impl);
impl->control.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_LoopControl,
SPA_VERSION_LOOP_CONTROL,
&impl_loop_control, impl);
impl->utils.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_LoopUtils,
SPA_VERSION_LOOP_UTILS,
&impl_loop_utils, impl);
for (i = 0; i < n_support; i++) {
if (support[i].type == SPA_TYPE_INTERFACE_Log)
@ -746,7 +754,7 @@ impl_init(const struct spa_handle_factory *factory,
spa_ringbuffer_init(&impl->buffer);
impl->wakeup = spa_loop_utils_add_event(&impl->utils, wakeup_func, impl);
impl->wakeup = spa_loop_utils_add_event((struct spa_loop_utils*)&impl->utils, wakeup_func, impl);
impl->ack_fd = eventfd(0, EFD_SEMAPHORE | EFD_CLOEXEC);
spa_log_debug(impl->log, NAME " %p: initialized", impl);

View file

@ -109,22 +109,20 @@ static void reset_props(struct impl *this, struct props *props)
props->live = DEFAULT_LIVE;
}
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:
@ -156,19 +154,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;
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);
switch (id) {
case SPA_PARAM_Props:
@ -281,15 +277,14 @@ static void on_input(struct spa_source *source)
consume_buffer(this);
}
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)) {
@ -358,17 +353,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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);
@ -380,15 +374,13 @@ 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");
@ -399,14 +391,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,
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;
}
@ -438,12 +430,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];
@ -452,11 +444,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;
@ -545,17 +534,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;
@ -567,20 +554,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;
@ -612,7 +596,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,
@ -620,13 +604,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;
@ -637,19 +618,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;
@ -661,20 +639,19 @@ impl_node_port_set_io(struct spa_node *node,
return 0;
}
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)
{
return -ENOTSUP;
}
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;
@ -704,8 +681,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,
@ -790,7 +767,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();

View file

@ -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;
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);
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();

View file

@ -115,19 +115,18 @@ static int emit_info(struct impl *this, bool full)
return 0;
}
static int impl_add_listener(struct spa_device *device,
static int impl_add_listener(void *object,
struct spa_hook *listener,
const struct spa_device_events *events,
void *data)
{
struct impl *this;
struct impl *this = object;
struct spa_hook_list save;
int res = 0;
spa_return_val_if_fail(device != NULL, -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(events != NULL, -EINVAL);
this = SPA_CONTAINER_OF(device, struct impl, device);
spa_hook_list_isolate(&this->hooks, &save, listener, events, data);
if (events->info || events->object_info)
@ -138,25 +137,25 @@ static int impl_add_listener(struct spa_device *device,
return res;
}
static int impl_enum_params(struct spa_device *device, int seq,
static int impl_enum_params(void *object, int seq,
uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter)
{
return -ENOTSUP;
}
static int impl_set_param(struct spa_device *device,
static int impl_set_param(void *object,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return -ENOTSUP;
}
static const struct spa_device impl_device = {
SPA_VERSION_DEVICE,
impl_add_listener,
impl_enum_params,
impl_set_param,
static const struct spa_device_methods impl_device = {
SPA_VERSION_DEVICE_METHODS,
.add_listener = impl_add_listener,
.enum_params = impl_enum_params,
.set_param = impl_set_param,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
@ -218,7 +217,10 @@ impl_init(const struct spa_handle_factory *factory,
spa_hook_list_init(&this->hooks);
this->device = impl_device;
this->device.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Device,
SPA_VERSION_DEVICE,
&impl_device, this);
this->dev.log = this->log;
this->dev.fd = -1;

View file

@ -225,6 +225,7 @@ static int start_monitor(struct impl *this)
this->source.fd = udev_monitor_get_fd(this->umonitor);;
this->source.mask = SPA_IO_IN | SPA_IO_ERR;
spa_log_debug(this->log, "monitor %p", this->umonitor);
spa_loop_add_source(this->main_loop, &this->source);
return 0;
@ -273,16 +274,14 @@ static int enum_devices(struct impl *this)
static int
impl_monitor_set_callbacks(struct spa_monitor *monitor,
impl_monitor_set_callbacks(void *object,
const struct spa_monitor_callbacks *callbacks,
void *data)
{
int res;
struct impl *this;
struct impl *this = object;
spa_return_val_if_fail(monitor != NULL, -EINVAL);
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
spa_return_val_if_fail(this != NULL, -EINVAL);
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
@ -302,9 +301,9 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
return 0;
}
static const struct spa_monitor impl_monitor = {
SPA_VERSION_MONITOR,
impl_monitor_set_callbacks,
static const struct spa_monitor_methods impl_monitor = {
SPA_VERSION_MONITOR_METHODS,
.set_callbacks = impl_monitor_set_callbacks,
};
static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **interface)
@ -327,7 +326,7 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t type, void **i
static int impl_clear(struct spa_handle *handle)
{
struct impl *this = (struct impl *) handle;
impl_monitor_set_callbacks(&this->monitor, NULL, NULL);
impl_monitor_set_callbacks(this, NULL, NULL);
return 0;
}
@ -367,7 +366,10 @@ impl_init(const struct spa_handle_factory *factory,
return -EINVAL;
}
this->monitor = impl_monitor;
this->monitor.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Monitor,
SPA_VERSION_MONITOR,
&impl_monitor, this);
return 0;
}
@ -394,7 +396,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
}
const struct spa_handle_factory spa_v4l2_monitor_factory = {
SPA_VERSION_MONITOR,
SPA_VERSION_HANDLE_FACTORY,
NAME,
NULL,
impl_get_size,

View file

@ -149,22 +149,20 @@ struct impl {
#include "v4l2-utils.c"
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 *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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:
@ -236,15 +234,13 @@ static int impl_node_enum_params(struct spa_node *node, int seq,
return 0;
}
static int impl_node_set_param(struct spa_node *node,
static int impl_node_set_param(void *object,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
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);
switch (id) {
case SPA_PARAM_Props:
@ -266,13 +262,11 @@ static int impl_node_set_param(struct spa_node *node,
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)
{
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);
switch (id) {
case SPA_IO_Clock:
@ -287,16 +281,14 @@ static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size
return 0;
}
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;
int res;
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);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
{
@ -352,17 +344,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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);
@ -373,43 +364,41 @@ impl_node_add_listener(struct spa_node *node,
return 0;
}
static int impl_node_set_callbacks(struct spa_node *node,
static int 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);
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
return 0;
}
static int impl_node_add_port(struct spa_node *node,
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,
static int impl_node_remove_port(void *object,
enum spa_direction direction,
uint32_t port_id)
{
return -ENOTSUP;
}
static int port_get_format(struct spa_node *node,
static int port_get_format(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
const struct spa_pod *filter,
struct spa_pod **param,
struct spa_pod_builder *builder)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port = GET_PORT(this, direction, port_id);
struct spa_pod_frame f;
@ -454,14 +443,14 @@ static int port_get_format(struct spa_node *node,
return 1;
}
static int impl_node_port_enum_params(struct spa_node *node, int seq,
static int 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 *param;
struct spa_pod_builder b = { 0 };
@ -470,11 +459,8 @@ static int 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(this, direction, port_id), -EINVAL);
port = GET_PORT(this, direction, port_id);
@ -494,7 +480,7 @@ static int impl_node_port_enum_params(struct spa_node *node, int seq,
return spa_v4l2_enum_format(this, seq, start, num, filter);
case SPA_PARAM_Format:
if((res = port_get_format(node, direction, port_id,
if((res = port_get_format(this, direction, port_id,
result.index, filter, &param, &b)) <= 0)
return res;
break;
@ -564,12 +550,12 @@ static int impl_node_port_enum_params(struct spa_node *node, int seq,
return 0;
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t flags,
const struct spa_pod *format)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct spa_video_info info;
struct port *port = GET_PORT(this, direction, port_id);
int res;
@ -658,36 +644,33 @@ static int port_set_format(struct spa_node *node,
return 0;
}
static int impl_node_port_set_param(struct spa_node *node,
static int 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)
{
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(object != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(node, direction, port_id), -EINVAL);
spa_return_val_if_fail(CHECK_PORT(object, direction, port_id), -EINVAL);
if (id == SPA_PARAM_Format) {
return port_set_format(node, direction, port_id, flags, param);
return port_set_format(object, direction, port_id, flags, param);
}
else
return -ENOENT;
}
static int impl_node_port_use_buffers(struct spa_node *node,
static int 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;
int res;
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 = GET_PORT(this, direction, port_id);
@ -708,7 +691,7 @@ static int 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,
@ -716,15 +699,12 @@ 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;
int res;
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(buffers != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
port = GET_PORT(this, direction, port_id);
@ -737,19 +717,16 @@ impl_node_port_alloc_buffers(struct spa_node *node,
return res;
}
static int impl_node_port_set_io(struct spa_node *node,
static int 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 = GET_PORT(this, direction, port_id);
@ -767,18 +744,17 @@ static int impl_node_port_set_io(struct spa_node *node,
return 0;
}
static int impl_node_port_reuse_buffer(struct spa_node *node,
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;
int res;
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(this != NULL, -EINVAL);
spa_return_val_if_fail(port_id == 0, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
port = GET_OUT_PORT(this, port_id);
spa_return_val_if_fail(buffer_id < port->n_buffers, -EINVAL);
@ -854,17 +830,15 @@ static int process_control(struct impl *this, struct spa_pod_sequence *control)
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;
int res;
struct spa_io_buffers *io;
struct port *port;
struct buffer *b;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
port = GET_OUT_PORT(this, 0);
io = port->io;
@ -873,7 +847,7 @@ static int impl_node_process(struct spa_node *node)
if (port->control)
process_control(this, &port->control->sequence);
spa_log_trace(this->log, NAME " %p; status %d", node, io->status);
spa_log_trace(this->log, NAME " %p; status %d", this, io->status);
if (io->status == SPA_STATUS_HAVE_BUFFER)
return SPA_STATUS_HAVE_BUFFER;
@ -891,7 +865,7 @@ static int impl_node_process(struct spa_node *node)
b = spa_list_first(&port->queue, struct buffer, link);
spa_list_remove(&b->link);
spa_log_trace(this->log, NAME " %p: dequeue buffer %d", node, b->id);
spa_log_trace(this->log, NAME " %p: dequeue buffer %d", this, b->id);
io->buffer_id = b->id;
io->status = SPA_STATUS_HAVE_BUFFER;
@ -899,8 +873,8 @@ static int impl_node_process(struct spa_node *node)
return SPA_STATUS_HAVE_BUFFER;
}
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,
@ -985,7 +959,10 @@ impl_init(const struct spa_handle_factory *factory,
return -EINVAL;
}
this->node = impl_node;
this->node.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Node,
SPA_VERSION_NODE,
&impl_node, this);
spa_hook_list_init(&this->hooks);
this->info_all = SPA_NODE_CHANGE_MASK_FLAGS |

View file

@ -122,22 +122,20 @@ struct impl {
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < MAX_PORTS)
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 *param;
struct spa_pod_builder b = { 0 };
uint8_t buffer[1024];
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:
@ -211,19 +209,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;
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);
switch (id) {
case SPA_PARAM_Props:
@ -343,15 +339,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)) {
@ -424,17 +419,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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);
@ -446,34 +440,32 @@ 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);
this->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
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;
}
static int port_enum_formats(struct spa_node *node,
static int port_enum_formats(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
const struct spa_pod *filter,
@ -506,12 +498,12 @@ static int port_enum_formats(struct spa_node *node,
}
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];
@ -520,11 +512,9 @@ 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(this, direction, port_id), -EINVAL);
port = &this->port;
@ -537,7 +527,7 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
switch (id) {
case SPA_PARAM_EnumFormat:
if ((res = port_enum_formats(node, direction, port_id,
if ((res = port_enum_formats(this, direction, port_id,
result.index, filter, &param, &b)) <= 0)
return res;
break;
@ -658,17 +648,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;
@ -680,20 +668,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;
@ -727,7 +712,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,
@ -735,13 +720,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;
@ -752,19 +734,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;
@ -790,15 +769,12 @@ static inline void reuse_buffer(struct impl *this, struct port *port, uint32_t i
set_timer(this, true);
}
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;
spa_return_val_if_fail(buffer_id < port->n_buffers, -EINVAL);
@ -808,15 +784,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);
@ -835,8 +810,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,
@ -921,7 +896,11 @@ 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_PROPS |
SPA_NODE_CHANGE_MASK_PARAMS;

View file

@ -111,11 +111,11 @@ struct impl {
#define GET_OUT_PORT(this,p) (&this->out_ports[p])
#define GET_PORT(this,d,p) (d == SPA_DIRECTION_INPUT ? GET_IN_PORT(this,p) : GET_OUT_PORT(this,p))
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;
@ -123,10 +123,9 @@ static int impl_node_enum_params(struct spa_node *node, int seq,
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);
p = &this->props;
result.id = id;
@ -184,19 +183,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;
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);
switch (id) {
case SPA_PARAM_Props:
@ -220,15 +217,13 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
return 0;
}
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;
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);
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
@ -264,17 +259,16 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
}
static int
impl_node_add_listener(struct spa_node *node,
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);
@ -287,26 +281,26 @@ 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)
{
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;
}
static int port_enum_formats(struct spa_node *node,
static int port_enum_formats(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t index,
const struct spa_pod *filter,
@ -333,12 +327,12 @@ static int port_enum_formats(struct spa_node *node,
}
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];
@ -347,11 +341,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(this, direction, port_id), -EINVAL);
port = GET_PORT(this, direction, port_id);
@ -365,7 +356,7 @@ impl_node_port_enum_params(struct spa_node *node, int seq,
switch (id) {
case SPA_PARAM_EnumFormat:
if ((res = port_enum_formats(node, direction, port_id,
if ((res = port_enum_formats(this, direction, port_id,
result.index, filter, &param, &b)) <= 0)
return res;
break;
@ -445,12 +436,12 @@ static int clear_buffers(struct impl *this, struct port *port)
return 0;
}
static int port_set_format(struct spa_node *node,
static int port_set_format(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t flags,
const struct spa_pod *format)
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct impl *this = object;
struct port *port;
int res;
@ -491,37 +482,34 @@ static int port_set_format(struct spa_node *node,
}
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)
{
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(object != NULL, -EINVAL);
spa_return_val_if_fail(CHECK_PORT(node, direction, port_id), -EINVAL);
spa_return_val_if_fail(CHECK_PORT(object, direction, port_id), -EINVAL);
if (id == SPA_PARAM_Format) {
return port_set_format(node, direction, port_id, flags, param);
return port_set_format(object, direction, port_id, flags, param);
}
else
return -ENOENT;
}
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 = GET_PORT(this, direction, port_id);
@ -560,7 +548,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,
@ -572,19 +560,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 = GET_PORT(this, direction, port_id);
@ -614,15 +599,12 @@ static void recycle_buffer(struct impl *this, uint32_t id)
spa_log_trace(this->log, NAME " %p: recycle buffer %d", this, id);
}
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(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id),
-EINVAL);
@ -696,16 +678,14 @@ static void do_volume(struct impl *this, struct spa_buffer *dbuf, struct spa_buf
dd[0].chunk->stride = 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 *in_port, *out_port;
struct spa_io_buffers *input, *output;
struct buffer *dbuf, *sbuf;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(this != NULL, -EINVAL);
out_port = GET_OUT_PORT(this, 0);
output = out_port->io;
@ -750,8 +730,8 @@ static int impl_node_process(struct spa_node *node)
return SPA_STATUS_HAVE_BUFFER;
}
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,
@ -824,7 +804,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();