diff options
author | Wim Taymans <wtaymans@redhat.com> | 2019-05-20 16:11:23 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2019-05-23 12:59:24 +0200 |
commit | ff946e3d4be276c8f36a656a708a4c736a3e15aa (patch) | |
tree | 486730290f5ea9ced87e2a0ce6bf5fd470232065 /spa/plugins/alsa | |
parent | eb6481efb3c3f4288c2e0156940ee10434577a11 (diff) |
interface: add an interface structiface2
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.
Diffstat (limited to 'spa/plugins/alsa')
-rw-r--r-- | spa/plugins/alsa/alsa-device.c | 38 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-monitor.c | 21 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-sink.c | 116 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-source.c | 117 |
4 files changed, 129 insertions, 163 deletions
diff --git a/spa/plugins/alsa/alsa-device.c b/spa/plugins/alsa/alsa-device.c index 932e9217..981f02fb 100644 --- a/spa/plugins/alsa/alsa-device.c +++ b/spa/plugins/alsa/alsa-device.c @@ -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); diff --git a/spa/plugins/alsa/alsa-monitor.c b/spa/plugins/alsa/alsa-monitor.c index 9a77852b..6fbdfc1c 100644 --- a/spa/plugins/alsa/alsa-monitor.c +++ b/spa/plugins/alsa/alsa-monitor.c @@ -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; - - spa_return_val_if_fail(monitor != NULL, -EINVAL); + struct impl *this = object; - 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; } diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 36ece317..af5e2bf3 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -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; - - spa_return_val_if_fail(node != NULL, -EINVAL); + struct state *this = object; - 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; - - spa_return_val_if_fail(node != NULL, -EINVAL); + struct state *this = object; - 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(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); 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; - - spa_return_val_if_fail(node != NULL, -EINVAL); + struct state *this = object; - 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; diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index d7720b95..faf19919 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -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; - - spa_return_val_if_fail(node != NULL, -EINVAL); + struct state *this = object; - 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; - - spa_return_val_if_fail(node != NULL, -EINVAL); + struct state *this = object; - 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; - - spa_return_val_if_fail(node != NULL, -EINVAL); + struct state *this = object; - 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; |