mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
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:
parent
eb6481efb3
commit
ff946e3d4b
85 changed files with 3051 additions and 3000 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue