mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04: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
|
|
@ -250,9 +250,9 @@ static const struct spa_node_callbacks sink_callbacks = {
|
|||
.reuse_buffer = on_sink_reuse_buffer
|
||||
};
|
||||
|
||||
static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
||||
static int do_add_source(void *object, struct spa_source *source)
|
||||
{
|
||||
struct data *data = SPA_CONTAINER_OF(loop, struct data, data_loop);
|
||||
struct data *data = object;
|
||||
|
||||
data->sources[data->n_sources] = *source;
|
||||
data->n_sources++;
|
||||
|
|
@ -261,22 +261,19 @@ static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int do_update_source(struct spa_source *source)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void do_remove_source(struct spa_source *source)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
do_invoke(struct spa_loop *loop,
|
||||
do_invoke(void *object,
|
||||
spa_invoke_func_t func, uint32_t seq, const void *data, size_t size, bool block, void *user_data)
|
||||
{
|
||||
return func(loop, false, seq, data, size, user_data);
|
||||
return func(object, false, seq, data, size, user_data);
|
||||
}
|
||||
|
||||
static const struct spa_loop_methods impl_loop = {
|
||||
SPA_VERSION_LOOP_METHODS,
|
||||
.add_source = do_add_source,
|
||||
.invoke = do_invoke,
|
||||
};
|
||||
|
||||
static int make_nodes(struct data *data, const char *device)
|
||||
{
|
||||
int res;
|
||||
|
|
@ -505,11 +502,8 @@ int main(int argc, char *argv[])
|
|||
spa_graph_init(&data.graph, &data.graph_state);
|
||||
|
||||
data.log = &default_log.log;
|
||||
data.data_loop.version = SPA_VERSION_LOOP;
|
||||
data.data_loop.add_source = do_add_source;
|
||||
data.data_loop.update_source = do_update_source;
|
||||
data.data_loop.remove_source = do_remove_source;
|
||||
data.data_loop.invoke = do_invoke;
|
||||
data.data_loop.iface = SPA_INTERFACE_INIT(
|
||||
SPA_TYPE_INTERFACE_Loop, SPA_VERSION_LOOP, &impl_loop, &data);
|
||||
|
||||
if ((str = getenv("SPA_DEBUG")))
|
||||
data.log->level = atoi(str);
|
||||
|
|
|
|||
|
|
@ -29,14 +29,20 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct spa_device;
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/dict.h>
|
||||
#include <spa/support/plugin.h>
|
||||
#include <spa/pod/builder.h>
|
||||
#include <spa/pod/event.h>
|
||||
|
||||
/**
|
||||
* spa_device:
|
||||
*
|
||||
* The device interface.
|
||||
*/
|
||||
#define SPA_VERSION_DEVICE 0
|
||||
struct spa_device { struct spa_interface iface; };
|
||||
|
||||
struct spa_device_info {
|
||||
#define SPA_VERSION_DEVICE_INFO 0
|
||||
uint32_t version;
|
||||
|
|
@ -103,14 +109,12 @@ struct spa_device_events {
|
|||
};
|
||||
|
||||
/**
|
||||
* spa_device:
|
||||
*
|
||||
* The device interface.
|
||||
* spa_device_methods:
|
||||
*/
|
||||
struct spa_device {
|
||||
/* the version of this device. This can be used to expand this
|
||||
struct spa_device_methods {
|
||||
/* the version of the methods. This can be used to expand this
|
||||
* structure in the future */
|
||||
#define SPA_VERSION_DEVICE 0
|
||||
#define SPA_VERSION_DEVICE_METHODS 0
|
||||
uint32_t version;
|
||||
|
||||
/**
|
||||
|
|
@ -128,7 +132,7 @@ struct spa_device {
|
|||
* \return 0 on success
|
||||
* < 0 errno on error
|
||||
*/
|
||||
int (*add_listener) (struct spa_device *device,
|
||||
int (*add_listener) (void *object,
|
||||
struct spa_hook *listener,
|
||||
const struct spa_device_events *events,
|
||||
void *data);
|
||||
|
|
@ -157,7 +161,7 @@ struct spa_device {
|
|||
* -ENOTSUP when there are no parameters
|
||||
* implemented on \a device
|
||||
*/
|
||||
int (*enum_params) (struct spa_device *device, int seq,
|
||||
int (*enum_params) (void *object, int seq,
|
||||
uint32_t id, uint32_t index, uint32_t max,
|
||||
const struct spa_pod *filter);
|
||||
|
||||
|
|
@ -182,14 +186,24 @@ struct spa_device {
|
|||
* -ENOTSUP when there are no parameters implemented on \a device
|
||||
* -ENOENT the parameter is unknown
|
||||
*/
|
||||
int (*set_param) (struct spa_device *device,
|
||||
int (*set_param) (void *object,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param);
|
||||
};
|
||||
|
||||
#define spa_device_add_listener(d,...) (d)->add_listener((d),__VA_ARGS__)
|
||||
#define spa_device_enum_params(d,...) (d)->enum_params((d),__VA_ARGS__)
|
||||
#define spa_device_set_param(d,...) (d)->set_param((d),__VA_ARGS__)
|
||||
#define spa_device_method(o,method,version,...) \
|
||||
({ \
|
||||
int _res = -ENOTSUP; \
|
||||
struct spa_device *_o = o; \
|
||||
spa_interface_call_res(&_o->iface, \
|
||||
struct spa_device_methods, _res, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
|
||||
#define spa_device_add_listener(d,...) spa_device_method(d, add_listener, 0, __VA_ARGS__)
|
||||
#define spa_device_enum_params(d,...) spa_device_method(d, enum_params, 0, __VA_ARGS__)
|
||||
#define spa_device_set_param(d,...) spa_device_method(d, set_param, 0, __VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -29,13 +29,14 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct spa_monitor;
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/dict.h>
|
||||
#include <spa/pod/event.h>
|
||||
#include <spa/pod/builder.h>
|
||||
|
||||
#define SPA_VERSION_MONITOR 0
|
||||
struct spa_monitor { struct spa_interface iface; };
|
||||
|
||||
enum spa_monitor_event {
|
||||
SPA_MONITOR_EVENT_Invalid,
|
||||
SPA_MONITOR_EVENT_Added,
|
||||
|
|
@ -87,14 +88,14 @@ struct spa_monitor_callbacks {
|
|||
};
|
||||
|
||||
/**
|
||||
* spa_monitor:
|
||||
* spa_monitor_methods:
|
||||
*
|
||||
* The device monitor interface.
|
||||
* The device monitor methods.
|
||||
*/
|
||||
struct spa_monitor {
|
||||
struct spa_monitor_methods {
|
||||
/* the version of this monitor. This can be used to expand this
|
||||
* structure in the future */
|
||||
#define SPA_VERSION_MONITOR 0
|
||||
#define SPA_VERSION_MONITOR_METHODS 0
|
||||
uint32_t version;
|
||||
|
||||
/**
|
||||
|
|
@ -108,12 +109,21 @@ struct spa_monitor {
|
|||
* \return 0 on success
|
||||
* < 0 errno on error
|
||||
*/
|
||||
int (*set_callbacks) (struct spa_monitor *monitor,
|
||||
int (*set_callbacks) (void *object,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
void *data);
|
||||
};
|
||||
|
||||
#define spa_monitor_set_callbacks(m,...) (m)->set_callbacks((m),__VA_ARGS__)
|
||||
static inline int spa_monitor_set_callbacks(struct spa_monitor *m,
|
||||
const struct spa_monitor_callbacks *callbacks, void *data)
|
||||
{
|
||||
int res = -ENOTSUP;
|
||||
spa_interface_call_res(&m->iface,
|
||||
struct spa_monitor_methods, res, set_callbacks, 0,
|
||||
callbacks, data);
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -29,13 +29,18 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct spa_node;
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/utils/type.h>
|
||||
#include <spa/utils/hook.h>
|
||||
|
||||
|
||||
/**
|
||||
* A spa_node is a component that can consume and produce buffers.
|
||||
*/
|
||||
#define SPA_VERSION_NODE 0
|
||||
struct spa_node { struct spa_interface iface; };
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
|
||||
#include <spa/pod/builder.h>
|
||||
|
|
@ -206,14 +211,13 @@ struct spa_node_callbacks {
|
|||
#define SPA_NODE_PARAM_FLAG_NEAREST (1 << 2) /* allow set fields to be rounded to the
|
||||
* nearest allowed field value. */
|
||||
|
||||
|
||||
/**
|
||||
* A spa_node is a component that can consume and produce buffers.
|
||||
* Node methods
|
||||
*/
|
||||
struct spa_node {
|
||||
/* the version of this node. This can be used to expand this
|
||||
struct spa_node_methods {
|
||||
/* the version of the node methods. This can be used to expand this
|
||||
* structure in the future */
|
||||
#define SPA_VERSION_NODE 0
|
||||
#define SPA_VERSION_NODE_METHODS 0
|
||||
uint32_t version;
|
||||
|
||||
/**
|
||||
|
|
@ -230,7 +234,7 @@ struct spa_node {
|
|||
* \return 0 on success
|
||||
* < 0 errno on error
|
||||
*/
|
||||
int (*add_listener) (struct spa_node *node,
|
||||
int (*add_listener) (void *object,
|
||||
struct spa_hook *listener,
|
||||
const struct spa_node_events *events,
|
||||
void *data);
|
||||
|
|
@ -247,7 +251,7 @@ struct spa_node {
|
|||
* \return 0 on success
|
||||
* -EINVAL when node is NULL
|
||||
*/
|
||||
int (*set_callbacks) (struct spa_node *node,
|
||||
int (*set_callbacks) (void *object,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
void *data);
|
||||
/**
|
||||
|
|
@ -265,7 +269,7 @@ struct spa_node {
|
|||
* -EINVAL when node is NULL
|
||||
* an async result
|
||||
*/
|
||||
int (*sync) (struct spa_node *node, int seq);
|
||||
int (*sync) (void *object, int seq);
|
||||
|
||||
/**
|
||||
* Enumerate the parameters of a node.
|
||||
|
|
@ -298,7 +302,7 @@ struct spa_node {
|
|||
* an async return value when the result event will be
|
||||
* emited later.
|
||||
*/
|
||||
int (*enum_params) (struct spa_node *node, int seq,
|
||||
int (*enum_params) (void *object, int seq,
|
||||
uint32_t id, uint32_t start, uint32_t max,
|
||||
const struct spa_pod *filter);
|
||||
|
||||
|
|
@ -323,7 +327,7 @@ struct spa_node {
|
|||
* -ENOTSUP when there are no parameters implemented on \a node
|
||||
* -ENOENT the parameter is unknown
|
||||
*/
|
||||
int (*set_param) (struct spa_node *node,
|
||||
int (*set_param) (void *object,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param);
|
||||
|
||||
|
|
@ -345,7 +349,7 @@ struct spa_node {
|
|||
* -ENOENT when \a id is unknown
|
||||
* -ENOSPC when \a size is too small
|
||||
*/
|
||||
int (*set_io) (struct spa_node *node,
|
||||
int (*set_io) (void *object,
|
||||
uint32_t id, void *data, size_t size);
|
||||
|
||||
/**
|
||||
|
|
@ -362,7 +366,7 @@ struct spa_node {
|
|||
* -ENOTSUP when this node can't process commands
|
||||
* -EINVAL \a command is an invalid command
|
||||
*/
|
||||
int (*send_command) (struct spa_node *node, const struct spa_command *command);
|
||||
int (*send_command) (void *object, const struct spa_command *command);
|
||||
|
||||
/**
|
||||
* Make a new port with \a port_id. The caller should use the lowest unused
|
||||
|
|
@ -380,7 +384,7 @@ struct spa_node {
|
|||
* \return 0 on success
|
||||
* -EINVAL when node is NULL
|
||||
*/
|
||||
int (*add_port) (struct spa_node *node,
|
||||
int (*add_port) (void *object,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
const struct spa_dict *props);
|
||||
|
||||
|
|
@ -394,7 +398,7 @@ struct spa_node {
|
|||
* -EINVAL when node is NULL or when port_id is unknown or
|
||||
* when the port can't be removed.
|
||||
*/
|
||||
int (*remove_port) (struct spa_node *node,
|
||||
int (*remove_port) (void *object,
|
||||
enum spa_direction direction, uint32_t port_id);
|
||||
|
||||
/**
|
||||
|
|
@ -427,7 +431,7 @@ struct spa_node {
|
|||
* an async return value when the result event will be
|
||||
* emited later.
|
||||
*/
|
||||
int (*port_enum_params) (struct spa_node *node, int seq,
|
||||
int (*port_enum_params) (void *object, int seq,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t id, uint32_t start, uint32_t max,
|
||||
const struct spa_pod *filter);
|
||||
|
|
@ -455,7 +459,7 @@ struct spa_node {
|
|||
* -ESRCH when the type or size of a property is not correct.
|
||||
* -ENOENT when the param id is not found
|
||||
*/
|
||||
int (*port_set_param) (struct spa_node *node,
|
||||
int (*port_set_param) (void *object,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t id, uint32_t flags,
|
||||
|
|
@ -493,7 +497,7 @@ struct spa_node {
|
|||
* \param n_buffers number of elements in \a buffers
|
||||
* \return 0 on success
|
||||
*/
|
||||
int (*port_use_buffers) (struct spa_node *node,
|
||||
int (*port_use_buffers) (void *object,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_buffer **buffers,
|
||||
|
|
@ -530,7 +534,7 @@ struct spa_node {
|
|||
* \return 0 on success
|
||||
* -EBUSY when the node already has allocated buffers.
|
||||
*/
|
||||
int (*port_alloc_buffers) (struct spa_node *node,
|
||||
int (*port_alloc_buffers) (void *object,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_pod **params,
|
||||
|
|
@ -558,7 +562,7 @@ struct spa_node {
|
|||
* -ENOENT when \a id is unknown
|
||||
* -ENOSPC when \a size is too small
|
||||
*/
|
||||
int (*port_set_io) (struct spa_node *node,
|
||||
int (*port_set_io) (void *object,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t id,
|
||||
|
|
@ -575,7 +579,7 @@ struct spa_node {
|
|||
* \return 0 on success
|
||||
* -EINVAL when node is NULL
|
||||
*/
|
||||
int (*port_reuse_buffer) (struct spa_node *node, uint32_t port_id, uint32_t buffer_id);
|
||||
int (*port_reuse_buffer) (void *object, uint32_t port_id, uint32_t buffer_id);
|
||||
|
||||
/**
|
||||
* Process the node
|
||||
|
|
@ -592,26 +596,36 @@ struct spa_node {
|
|||
* When the node can accept new input in the next cycle, the
|
||||
* SPA_STATUS_NEED_BUFFER bit will be set.
|
||||
*/
|
||||
int (*process) (struct spa_node *node);
|
||||
int (*process) (void *object);
|
||||
};
|
||||
|
||||
#define spa_node_add_listener(n,...) (n)->add_listener((n),__VA_ARGS__)
|
||||
#define spa_node_set_callbacks(n,...) (n)->set_callbacks((n),__VA_ARGS__)
|
||||
#define spa_node_sync(n,...) (n)->sync((n),__VA_ARGS__)
|
||||
#define spa_node_enum_params(n,...) (n)->enum_params((n),__VA_ARGS__)
|
||||
#define spa_node_set_param(n,...) (n)->set_param((n),__VA_ARGS__)
|
||||
#define spa_node_set_io(n,...) (n)->set_io((n),__VA_ARGS__)
|
||||
#define spa_node_send_command(n,...) (n)->send_command((n),__VA_ARGS__)
|
||||
#define spa_node_add_port(n,...) (n)->add_port((n),__VA_ARGS__)
|
||||
#define spa_node_remove_port(n,...) (n)->remove_port((n),__VA_ARGS__)
|
||||
#define spa_node_port_enum_params(n,...) (n)->port_enum_params((n),__VA_ARGS__)
|
||||
#define spa_node_port_set_param(n,...) (n)->port_set_param((n),__VA_ARGS__)
|
||||
#define spa_node_port_use_buffers(n,...) (n)->port_use_buffers((n),__VA_ARGS__)
|
||||
#define spa_node_port_alloc_buffers(n,...) (n)->port_alloc_buffers((n),__VA_ARGS__)
|
||||
#define spa_node_port_set_io(n,...) (n)->port_set_io((n),__VA_ARGS__)
|
||||
#define spa_node_method(o,method,version,...) \
|
||||
({ \
|
||||
int _res = -ENOTSUP; \
|
||||
struct spa_node *_n = o; \
|
||||
spa_interface_call_res(&_n->iface, \
|
||||
struct spa_node_methods, _res, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
|
||||
#define spa_node_port_reuse_buffer(n,...) (n)->port_reuse_buffer((n),__VA_ARGS__)
|
||||
#define spa_node_process(n) (n)->process((n))
|
||||
#define spa_node_add_listener(n,...) spa_node_method(n, add_listener, 0, __VA_ARGS__)
|
||||
#define spa_node_set_callbacks(n,...) spa_node_method(n, set_callbacks, 0, __VA_ARGS__)
|
||||
#define spa_node_sync(n,...) spa_node_method(n, sync, 0, __VA_ARGS__)
|
||||
#define spa_node_enum_params(n,...) spa_node_method(n, enum_params, 0, __VA_ARGS__)
|
||||
#define spa_node_set_param(n,...) spa_node_method(n, set_param, 0, __VA_ARGS__)
|
||||
#define spa_node_set_io(n,...) spa_node_method(n, set_io, 0, __VA_ARGS__)
|
||||
#define spa_node_send_command(n,...) spa_node_method(n, send_command, 0, __VA_ARGS__)
|
||||
#define spa_node_add_port(n,...) spa_node_method(n, add_port, 0, __VA_ARGS__)
|
||||
#define spa_node_remove_port(n,...) spa_node_method(n, remove_port, 0, __VA_ARGS__)
|
||||
#define spa_node_port_enum_params(n,...) spa_node_method(n, port_enum_params, 0, __VA_ARGS__)
|
||||
#define spa_node_port_set_param(n,...) spa_node_method(n, port_set_param, 0, __VA_ARGS__)
|
||||
#define spa_node_port_use_buffers(n,...) spa_node_method(n, port_use_buffers, 0, __VA_ARGS__)
|
||||
#define spa_node_port_alloc_buffers(n,...) spa_node_method(n, port_alloc_buffers, 0, __VA_ARGS__)
|
||||
#define spa_node_port_set_io(n,...) spa_node_method(n, port_set_io, 0, __VA_ARGS__)
|
||||
|
||||
#define spa_node_port_reuse_buffer(n,...) spa_node_method(n, port_reuse_buffer, 0, __VA_ARGS__)
|
||||
#define spa_node_process(n) spa_node_method(n, process, 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -61,11 +61,13 @@ static inline int spa_node_enum_params_sync(struct spa_node *node,
|
|||
SPA_VERSION_NODE_EVENTS,
|
||||
.result = spa_result_func_node_params,
|
||||
};
|
||||
int res = 0;
|
||||
int res;
|
||||
|
||||
spa_node_add_listener(node, &listener, &node_events, &data);
|
||||
res = spa_node_enum_params(node, 0, id, *index, 1, filter);
|
||||
spa_hook_remove(&listener);
|
||||
res = spa_node_add_listener(node, &listener, &node_events, &data);
|
||||
if (res >= 0) {
|
||||
res = spa_node_enum_params(node, 0, id, *index, 1, filter);
|
||||
spa_hook_remove(&listener);
|
||||
}
|
||||
|
||||
if (data.data.param == NULL) {
|
||||
if (res > 0)
|
||||
|
|
@ -93,10 +95,12 @@ static inline int spa_node_port_enum_params_sync(struct spa_node *node,
|
|||
};
|
||||
int res;
|
||||
|
||||
spa_node_add_listener(node, &listener, &node_events, &data);
|
||||
res = spa_node_port_enum_params(node, 0, direction, port_id,
|
||||
id, *index, 1, filter);
|
||||
spa_hook_remove(&listener);
|
||||
res = spa_node_add_listener(node, &listener, &node_events, &data);
|
||||
if (res >= 0) {
|
||||
res = spa_node_port_enum_params(node, 0, direction, port_id,
|
||||
id, *index, 1, filter);
|
||||
spa_hook_remove(&listener);
|
||||
}
|
||||
|
||||
if (data.data.param == NULL) {
|
||||
if (res > 0)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,13 @@ extern "C" {
|
|||
#include <stdarg.h>
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/hook.h>
|
||||
|
||||
/**
|
||||
* The CPU features interface
|
||||
*/
|
||||
#define SPA_VERSION_CPU 0
|
||||
struct spa_cpu { struct spa_interface iface; };
|
||||
|
||||
/* x86 specific */
|
||||
#define SPA_CPU_FLAG_MMX (1<<0) /**< standard MMX */
|
||||
|
|
@ -72,35 +79,40 @@ extern "C" {
|
|||
|
||||
#define SPA_CPU_FORCE_AUTODETECT ((uint32_t)-1)
|
||||
/**
|
||||
* The CPU features interface
|
||||
* methods
|
||||
*/
|
||||
struct spa_cpu {
|
||||
/** the version of this interface. This can be used to expand this
|
||||
struct spa_cpu_methods {
|
||||
/** the version of the methods. This can be used to expand this
|
||||
structure in the future */
|
||||
#define SPA_VERSION_CPU 0
|
||||
#define SPA_VERSION_CPU_METHODS 0
|
||||
uint32_t version;
|
||||
/**
|
||||
* Extra information about the interface
|
||||
*/
|
||||
const struct spa_dict *info;
|
||||
|
||||
/** get CPU flags */
|
||||
uint32_t (*get_flags) (struct spa_cpu *cpu);
|
||||
uint32_t (*get_flags) (void *object);
|
||||
|
||||
/** force CPU flags, use SPA_CPU_FORCE_AUTODETECT to autodetect CPU flags */
|
||||
int (*force_flags) (struct spa_cpu *cpu, uint32_t flags);
|
||||
int (*force_flags) (void *object, uint32_t flags);
|
||||
|
||||
/** get number of CPU cores */
|
||||
uint32_t (*get_count) (struct spa_cpu *cpu);
|
||||
uint32_t (*get_count) (void *object);
|
||||
|
||||
/** get maximum required alignment of data */
|
||||
uint32_t (*get_max_align) (struct spa_cpu *cpu);
|
||||
uint32_t (*get_max_align) (void *object);
|
||||
};
|
||||
|
||||
#define spa_cpu_get_flags(c) (c)->get_flags((c))
|
||||
#define spa_cpu_force_flags(c,f) (c)->force_flags((c), (f))
|
||||
#define spa_cpu_get_count(c) (c)->get_count((c))
|
||||
#define spa_cpu_get_max_align(c) (c)->get_max_align((c))
|
||||
#define spa_cpu_method(o,method,version,...) \
|
||||
({ \
|
||||
int _res = -ENOTSUP; \
|
||||
struct spa_cpu *_c = o; \
|
||||
spa_interface_call_res(&_c->iface, \
|
||||
struct spa_cpu_methods, _res, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
#define spa_cpu_get_flags(c) spa_cpu_method(c, get_flags, 0)
|
||||
#define spa_cpu_force_flags(c,f) spa_cpu_method(c, force_flags, 0, f)
|
||||
#define spa_cpu_get_count(c) spa_cpu_method(c, get_count, 0)
|
||||
#define spa_cpu_get_max_align(c) spa_cpu_method(c, get_max_align, 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ extern "C" {
|
|||
|
||||
#include <spa/support/loop.h>
|
||||
|
||||
#define SPA_VERSION_DBUS 0
|
||||
struct spa_dbus { struct spa_interface iface; };
|
||||
|
||||
enum spa_dbus_type {
|
||||
SPA_DBUS_TYPE_SESSION, /**< The login session bus */
|
||||
SPA_DBUS_TYPE_SYSTEM, /**< The systemwide bus */
|
||||
|
|
@ -58,10 +61,8 @@ struct spa_dbus_connection {
|
|||
#define spa_dbus_connection_get(c) (c)->get((c))
|
||||
#define spa_dbus_connection_destroy(c) (c)->destroy((c))
|
||||
|
||||
struct spa_dbus {
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
#define SPA_VERSION_DBUS 0
|
||||
struct spa_dbus_methods {
|
||||
#define SPA_VERSION_DBUS_METHODS 0
|
||||
uint32_t version;
|
||||
|
||||
/**
|
||||
|
|
@ -76,11 +77,19 @@ struct spa_dbus {
|
|||
* \param error location for the DBusError
|
||||
* \return a new dbus connection wrapper or NULL on error
|
||||
*/
|
||||
struct spa_dbus_connection * (*get_connection) (struct spa_dbus *dbus,
|
||||
struct spa_dbus_connection * (*get_connection) (void *object,
|
||||
enum spa_dbus_type type);
|
||||
};
|
||||
|
||||
#define spa_dbus_get_connection(d,...) (d)->get_connection((d),__VA_ARGS__)
|
||||
static inline struct spa_dbus_connection *
|
||||
spa_dbus_get_connection(struct spa_dbus *dbus, enum spa_dbus_type type)
|
||||
{
|
||||
struct spa_dbus_connection *res = NULL;
|
||||
spa_interface_call_res(&dbus->iface,
|
||||
struct spa_dbus_methods, res,
|
||||
get_connection, 0, type);
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ extern "C" {
|
|||
|
||||
#include <spa/support/log.h>
|
||||
|
||||
static inline void spa_log_impl_logv(struct spa_log *log,
|
||||
static inline void spa_log_impl_logv(void *object,
|
||||
enum spa_log_level level,
|
||||
const char *file,
|
||||
int line,
|
||||
|
|
@ -49,7 +49,7 @@ static inline void spa_log_impl_logv(struct spa_log *log,
|
|||
levels[level], strrchr(file, '/') + 1, line, func, text);
|
||||
fputs(location, stderr);
|
||||
}
|
||||
static inline void spa_log_impl_log(struct spa_log *log,
|
||||
static inline void spa_log_impl_log(void *object,
|
||||
enum spa_log_level level,
|
||||
const char *file,
|
||||
int line,
|
||||
|
|
@ -58,24 +58,26 @@ static inline void spa_log_impl_log(struct spa_log *log,
|
|||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
spa_log_impl_logv(log, level, file, line, func, fmt, args);
|
||||
spa_log_impl_logv(object, level, file, line, func, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#define SPA_LOG_IMPL_DEFINE(name) \
|
||||
struct { \
|
||||
struct spa_log log; \
|
||||
struct spa_log_methods methods; \
|
||||
} name
|
||||
|
||||
#define SPA_LOG_IMPL_INIT \
|
||||
{ { SPA_VERSION_LOG, \
|
||||
SPA_LOG_LEVEL_INFO, \
|
||||
NULL, \
|
||||
spa_log_impl_log, \
|
||||
#define SPA_LOG_IMPL_INIT(name) \
|
||||
{ { { SPA_TYPE_INTERFACE_Log, SPA_VERSION_LOG, \
|
||||
SPA_CALLBACKS_INIT(&name.methods, &name) }, \
|
||||
SPA_LOG_LEVEL_INFO, }, \
|
||||
{ SPA_VERSION_LOG_METHODS, \
|
||||
spa_log_impl_log, \
|
||||
spa_log_impl_logv,} }
|
||||
|
||||
#define SPA_LOG_IMPL(name) \
|
||||
SPA_LOG_IMPL_DEFINE(name) = SPA_LOG_IMPL_INIT
|
||||
SPA_LOG_IMPL_DEFINE(name) = SPA_LOG_IMPL_INIT(name)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ extern "C" {
|
|||
#include <stdarg.h>
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/hook.h>
|
||||
|
||||
enum spa_log_level {
|
||||
SPA_LOG_LEVEL_NONE = 0,
|
||||
|
|
@ -49,17 +50,16 @@ struct spa_log {
|
|||
/** the version of this log. This can be used to expand this
|
||||
* structure in the future */
|
||||
#define SPA_VERSION_LOG 0
|
||||
uint32_t version;
|
||||
struct spa_interface iface;
|
||||
/**
|
||||
* Logging level, everything above this level is not logged
|
||||
*/
|
||||
enum spa_log_level level;
|
||||
};
|
||||
|
||||
/**
|
||||
* Extra information about the log
|
||||
*/
|
||||
const struct spa_dict *info;
|
||||
|
||||
struct spa_log_methods {
|
||||
#define SPA_VERSION_LOG_METHODS 0
|
||||
uint32_t version;
|
||||
/**
|
||||
* Log a message with the given log level.
|
||||
*
|
||||
|
|
@ -71,7 +71,7 @@ struct spa_log {
|
|||
* \param fmt printf style format
|
||||
* \param ... format arguments
|
||||
*/
|
||||
void (*log) (struct spa_log *log,
|
||||
void (*log) (void *object,
|
||||
enum spa_log_level level,
|
||||
const char *file,
|
||||
int line,
|
||||
|
|
@ -89,7 +89,7 @@ struct spa_log {
|
|||
* \param fmt printf style format
|
||||
* \param args format arguments
|
||||
*/
|
||||
void (*logv) (struct spa_log *log,
|
||||
void (*logv) (void *object,
|
||||
enum spa_log_level level,
|
||||
const char *file,
|
||||
int line,
|
||||
|
|
@ -105,8 +105,20 @@ struct spa_log {
|
|||
|
||||
#define spa_log_log(l,lev,...) \
|
||||
({ \
|
||||
if (SPA_UNLIKELY (spa_log_level_enabled (l, lev))) \
|
||||
(l)->log((l),lev,__VA_ARGS__); \
|
||||
struct spa_log *_l = l; \
|
||||
if (SPA_UNLIKELY (spa_log_level_enabled(_l, lev))) \
|
||||
spa_interface_call(&_l->iface, \
|
||||
struct spa_log_methods, log, 0, lev, \
|
||||
__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define spa_log_logv(l,lev,...) \
|
||||
({ \
|
||||
struct spa_log *_l = l; \
|
||||
if (SPA_UNLIKELY (spa_log_level_enabled(_l, lev))) \
|
||||
spa_interface_call(&_l->iface, \
|
||||
struct spa_log_methods, logv, 0, lev, \
|
||||
__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define spa_log_error(l,...) spa_log_log(l,SPA_LOG_LEVEL_ERROR,__FILE__,__LINE__,__func__,__VA_ARGS__)
|
||||
|
|
@ -129,7 +141,9 @@ static inline void spa_log_##name (struct spa_log *l, const char *format, ...)
|
|||
if (SPA_UNLIKELY (spa_log_level_enabled (l, lev))) { \
|
||||
va_list varargs; \
|
||||
va_start (varargs, format); \
|
||||
(l)->logv((l),lev,__FILE__,__LINE__,__func__,format,varargs); \
|
||||
spa_interface_call(&l->iface, \
|
||||
struct spa_log_methods, logv, 0, lev, \
|
||||
__FILE__,__LINE__,__func__,format,varargs); \
|
||||
va_end (varargs); \
|
||||
} \
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,15 +29,18 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct spa_loop;
|
||||
struct spa_loop_control;
|
||||
struct spa_loop_utils;
|
||||
struct spa_source;
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/hook.h>
|
||||
#include <spa/utils/result.h>
|
||||
|
||||
#define SPA_VERSION_LOOP 0
|
||||
struct spa_loop { struct spa_interface iface; };
|
||||
#define SPA_VERSION_LOOP_CONTROL 0
|
||||
struct spa_loop_control { struct spa_interface iface; };
|
||||
#define SPA_VERSION_LOOP_UTILS 0
|
||||
struct spa_loop_utils { struct spa_interface iface; };
|
||||
struct spa_source;
|
||||
|
||||
enum spa_io {
|
||||
SPA_IO_IN = (1 << 0),
|
||||
SPA_IO_OUT = (1 << 1),
|
||||
|
|
@ -66,24 +69,26 @@ typedef int (*spa_invoke_func_t) (struct spa_loop *loop,
|
|||
/**
|
||||
* Register sources and work items to an event loop
|
||||
*/
|
||||
struct spa_loop {
|
||||
struct spa_loop_methods {
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
#define SPA_VERSION_LOOP 0
|
||||
#define SPA_VERSION_LOOP_METHODS 0
|
||||
uint32_t version;
|
||||
|
||||
/** add a source to the loop */
|
||||
int (*add_source) (struct spa_loop *loop,
|
||||
int (*add_source) (void *object,
|
||||
struct spa_source *source);
|
||||
|
||||
/** update the source io mask */
|
||||
int (*update_source) (struct spa_source *source);
|
||||
int (*update_source) (void *object,
|
||||
struct spa_source *source);
|
||||
|
||||
/** remove a source from the loop */
|
||||
void (*remove_source) (struct spa_source *source);
|
||||
int (*remove_source) (void *object,
|
||||
struct spa_source *source);
|
||||
|
||||
/** invoke a function in the context of this loop */
|
||||
int (*invoke) (struct spa_loop *loop,
|
||||
int (*invoke) (void *object,
|
||||
spa_invoke_func_t func,
|
||||
uint32_t seq,
|
||||
const void *data,
|
||||
|
|
@ -92,10 +97,20 @@ struct spa_loop {
|
|||
void *user_data);
|
||||
};
|
||||
|
||||
#define spa_loop_add_source(l,...) (l)->add_source((l),__VA_ARGS__)
|
||||
#define spa_loop_update_source(l,...) (l)->update_source(__VA_ARGS__)
|
||||
#define spa_loop_remove_source(l,...) (l)->remove_source(__VA_ARGS__)
|
||||
#define spa_loop_invoke(l,...) (l)->invoke((l),__VA_ARGS__)
|
||||
#define spa_loop_method(o,method,version,...) \
|
||||
({ \
|
||||
int _res = -ENOTSUP; \
|
||||
struct spa_loop *_o = o; \
|
||||
spa_interface_call_res(&_o->iface, \
|
||||
struct spa_loop_methods, _res, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
|
||||
#define spa_loop_add_source(l,...) spa_loop_method(l,add_source,0,##__VA_ARGS__)
|
||||
#define spa_loop_update_source(l,...) spa_loop_method(l,update_source,0,##__VA_ARGS__)
|
||||
#define spa_loop_remove_source(l,...) spa_loop_method(l,remove_source,0,##__VA_ARGS__)
|
||||
#define spa_loop_invoke(l,...) spa_loop_method(l,invoke,0,##__VA_ARGS__)
|
||||
|
||||
|
||||
/** Control hooks */
|
||||
|
|
@ -116,13 +131,13 @@ struct spa_loop_control_hooks {
|
|||
/**
|
||||
* Control an event loop
|
||||
*/
|
||||
struct spa_loop_control {
|
||||
struct spa_loop_control_methods {
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
#define SPA_VERSION_LOOP_CONTROL 0
|
||||
#define SPA_VERSION_LOOP_CONTROL_METHODS 0
|
||||
uint32_t version;
|
||||
|
||||
int (*get_fd) (struct spa_loop_control *ctrl);
|
||||
int (*get_fd) (void *object);
|
||||
|
||||
/** Add a hook
|
||||
* \param ctrl the control to change
|
||||
|
|
@ -130,7 +145,7 @@ struct spa_loop_control {
|
|||
*
|
||||
* Adds hooks to the loop controlled by \a ctrl.
|
||||
*/
|
||||
void (*add_hook) (struct spa_loop_control *ctrl,
|
||||
void (*add_hook) (void *object,
|
||||
struct spa_hook *hook,
|
||||
const struct spa_loop_control_hooks *hooks,
|
||||
void *data);
|
||||
|
|
@ -142,14 +157,14 @@ struct spa_loop_control {
|
|||
* before calling iterate and is typically used to capture the thread
|
||||
* that this loop will run in.
|
||||
*/
|
||||
void (*enter) (struct spa_loop_control *ctrl);
|
||||
void (*enter) (void *object);
|
||||
/** Leave a loop
|
||||
* \param ctrl the control
|
||||
*
|
||||
* Ends the iteration of a loop. This should be called after calling
|
||||
* iterate.
|
||||
*/
|
||||
void (*leave) (struct spa_loop_control *ctrl);
|
||||
void (*leave) (void *object);
|
||||
|
||||
/** Perform one iteration of the loop.
|
||||
* \param ctrl the control
|
||||
|
|
@ -160,14 +175,32 @@ struct spa_loop_control {
|
|||
* up to \a timeout and then dispatch the fds with activity.
|
||||
* The number of dispatched fds is returned.
|
||||
*/
|
||||
int (*iterate) (struct spa_loop_control *ctrl, int timeout);
|
||||
int (*iterate) (void *object, int timeout);
|
||||
};
|
||||
|
||||
#define spa_loop_control_get_fd(l) (l)->get_fd(l)
|
||||
#define spa_loop_control_add_hook(l,...) (l)->add_hook((l),__VA_ARGS__)
|
||||
#define spa_loop_control_enter(l) (l)->enter(l)
|
||||
#define spa_loop_control_iterate(l,...) (l)->iterate((l),__VA_ARGS__)
|
||||
#define spa_loop_control_leave(l) (l)->leave(l)
|
||||
#define spa_loop_control_method_v(o,method,version,...) \
|
||||
({ \
|
||||
struct spa_loop_control *_o = o; \
|
||||
spa_interface_call(&_o->iface, \
|
||||
struct spa_loop_control_methods, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define spa_loop_control_method_r(o,method,version,...) \
|
||||
({ \
|
||||
int _res = -ENOTSUP; \
|
||||
struct spa_loop_control *_o = o; \
|
||||
spa_interface_call_res(&_o->iface, \
|
||||
struct spa_loop_control_methods, _res, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
|
||||
#define spa_loop_control_get_fd(l) spa_loop_control_method_r(l,get_fd,0)
|
||||
#define spa_loop_control_add_hook(l,...) spa_loop_control_method_v(l,add_hook,0,__VA_ARGS__)
|
||||
#define spa_loop_control_enter(l) spa_loop_control_method_v(l,enter,0)
|
||||
#define spa_loop_control_leave(l) spa_loop_control_method_v(l,leave,0)
|
||||
#define spa_loop_control_iterate(l,...) spa_loop_control_method_r(l,iterate,0,__VA_ARGS__)
|
||||
|
||||
|
||||
typedef void (*spa_source_io_func_t) (void *data, int fd, enum spa_io mask);
|
||||
|
|
@ -179,55 +212,84 @@ typedef void (*spa_source_signal_func_t) (void *data, int signal_number);
|
|||
/**
|
||||
* Create sources for an event loop
|
||||
*/
|
||||
struct spa_loop_utils {
|
||||
struct spa_loop_utils_methods {
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
#define SPA_VERSION_LOOP_UTILS 0
|
||||
#define SPA_VERSION_LOOP_UTILS_METHODS 0
|
||||
uint32_t version;
|
||||
|
||||
struct spa_source *(*add_io) (struct spa_loop_utils *utils,
|
||||
struct spa_source *(*add_io) (void *object,
|
||||
int fd,
|
||||
enum spa_io mask,
|
||||
bool close,
|
||||
spa_source_io_func_t func, void *data);
|
||||
|
||||
int (*update_io) (struct spa_source *source, enum spa_io mask);
|
||||
int (*update_io) (void *object, struct spa_source *source, enum spa_io mask);
|
||||
|
||||
struct spa_source *(*add_idle) (struct spa_loop_utils *utils,
|
||||
struct spa_source *(*add_idle) (void *object,
|
||||
bool enabled,
|
||||
spa_source_idle_func_t func, void *data);
|
||||
void (*enable_idle) (struct spa_source *source, bool enabled);
|
||||
void (*enable_idle) (void *object, struct spa_source *source, bool enabled);
|
||||
|
||||
struct spa_source *(*add_event) (struct spa_loop_utils *utils,
|
||||
struct spa_source *(*add_event) (void *object,
|
||||
spa_source_event_func_t func, void *data);
|
||||
void (*signal_event) (struct spa_source *source);
|
||||
void (*signal_event) (void *object, struct spa_source *source);
|
||||
|
||||
struct spa_source *(*add_timer) (struct spa_loop_utils *utils,
|
||||
struct spa_source *(*add_timer) (void *object,
|
||||
spa_source_timer_func_t func, void *data);
|
||||
int (*update_timer) (struct spa_source *source,
|
||||
int (*update_timer) (void *object,
|
||||
struct spa_source *source,
|
||||
struct timespec *value,
|
||||
struct timespec *interval,
|
||||
bool absolute);
|
||||
struct spa_source *(*add_signal) (struct spa_loop_utils *utils,
|
||||
struct spa_source *(*add_signal) (void *object,
|
||||
int signal_number,
|
||||
spa_source_signal_func_t func, void *data);
|
||||
|
||||
/** destroy a source allocated with this interface. This function
|
||||
* should only be called when the loop is not running or from the
|
||||
* context of the running loop */
|
||||
void (*destroy_source) (struct spa_source *source);
|
||||
void (*destroy_source) (void *object, struct spa_source *source);
|
||||
};
|
||||
|
||||
#define spa_loop_utils_add_io(l,...) (l)->add_io(l,__VA_ARGS__)
|
||||
#define spa_loop_utils_update_io(l,...) (l)->update_io(__VA_ARGS__)
|
||||
#define spa_loop_utils_add_idle(l,...) (l)->add_idle(l,__VA_ARGS__)
|
||||
#define spa_loop_utils_enable_idle(l,...) (l)->enable_idle(__VA_ARGS__)
|
||||
#define spa_loop_utils_add_event(l,...) (l)->add_event(l,__VA_ARGS__)
|
||||
#define spa_loop_utils_signal_event(l,...) (l)->signal_event(__VA_ARGS__)
|
||||
#define spa_loop_utils_add_timer(l,...) (l)->add_timer(l,__VA_ARGS__)
|
||||
#define spa_loop_utils_update_timer(l,...) (l)->update_timer(__VA_ARGS__)
|
||||
#define spa_loop_utils_add_signal(l,...) (l)->add_signal(l,__VA_ARGS__)
|
||||
#define spa_loop_utils_destroy_source(l,...) (l)->destroy_source(__VA_ARGS__)
|
||||
#define spa_loop_utils_method_v(o,method,version,...) \
|
||||
({ \
|
||||
struct spa_loop_utils *_o = o; \
|
||||
spa_interface_call(&_o->iface, \
|
||||
struct spa_loop_utils_methods, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define spa_loop_utils_method_r(o,method,version,...) \
|
||||
({ \
|
||||
int _res = -ENOTSUP; \
|
||||
struct spa_loop_utils *_o = o; \
|
||||
spa_interface_call_res(&_o->iface, \
|
||||
struct spa_loop_utils_methods, _res, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
#define spa_loop_utils_method_s(o,method,version,...) \
|
||||
({ \
|
||||
struct spa_source *_res = NULL; \
|
||||
struct spa_loop_utils *_o = o; \
|
||||
spa_interface_call_res(&_o->iface, \
|
||||
struct spa_loop_utils_methods, _res, \
|
||||
method, version, ##__VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
|
||||
|
||||
#define spa_loop_utils_add_io(l,...) spa_loop_utils_method_s(l,add_io,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_update_io(l,...) spa_loop_utils_method_r(l,update_io,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_add_idle(l,...) spa_loop_utils_method_s(l,add_idle,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_enable_idle(l,...) spa_loop_utils_method_v(l,enable_idle,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_add_event(l,...) spa_loop_utils_method_s(l,add_event,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_signal_event(l,...) spa_loop_utils_method_v(l,signal_event,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_add_timer(l,...) spa_loop_utils_method_s(l,add_timer,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_update_timer(l,...) spa_loop_utils_method_r(l,update_timer,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_add_signal(l,...) spa_loop_utils_method_s(l,add_signal,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_destroy_source(l,...) spa_loop_utils_method_v(l,destroy_source,0,__VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -37,11 +37,12 @@ struct spa_handle {
|
|||
#define SPA_VERSION_HANDLE 0
|
||||
uint32_t version;
|
||||
|
||||
/* user_data that can be set by the application */
|
||||
void *user_data;
|
||||
/**
|
||||
* Get the interface provided by \a handle with \a type.
|
||||
*
|
||||
* \a interface is always a struct spa_interface but depending on
|
||||
* \a type, the struct might contain other information.
|
||||
*
|
||||
* \param handle a spa_handle
|
||||
* \param type the interface type
|
||||
* \param interface result to hold the interface.
|
||||
|
|
|
|||
|
|
@ -52,6 +52,15 @@ struct spa_callbacks {
|
|||
|
||||
#define SPA_CALLBACKS_INIT(_funcs,_data) (struct spa_callbacks){ _funcs, _data, }
|
||||
|
||||
struct spa_interface {
|
||||
uint32_t type;
|
||||
uint32_t version;
|
||||
struct spa_callbacks cb;
|
||||
};
|
||||
|
||||
#define SPA_INTERFACE_INIT(_type,_version,_funcs,_data) \
|
||||
(struct spa_interface){ _type, _version, SPA_CALLBACKS_INIT(_funcs,_data), }
|
||||
|
||||
/** A hook, contains the structure with functions and the data passed
|
||||
* to the functions. */
|
||||
struct spa_hook {
|
||||
|
|
@ -130,6 +139,12 @@ spa_hook_list_join(struct spa_hook_list *list,
|
|||
res; \
|
||||
})
|
||||
|
||||
#define spa_interface_call(iface,type,method,vers,...) \
|
||||
spa_callbacks_call(&(iface)->cb,type,method,vers,##__VA_ARGS__)
|
||||
|
||||
#define spa_interface_call_res(iface,type,res,method,vers,...) \
|
||||
spa_callbacks_call_res(&(iface)->cb,type,res,method,vers,##__VA_ARGS__)
|
||||
|
||||
#define spa_hook_list_call_simple(l,type,method,vers,...) \
|
||||
({ \
|
||||
struct spa_hook_list *_l = l; \
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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, ¶m, &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();
|
||||
|
|
|
|||
|
|
@ -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, ¶m, &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)
|
||||
|
|
|
|||
|
|
@ -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, ¶m, &b)) <= 0)
|
||||
if ((res = port_enum_formats(object, direction, port_id, result.index, ¶m, &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 |
|
||||
|
|
|
|||
|
|
@ -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, ¶m, &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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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, ¶m, &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();
|
||||
|
|
|
|||
|
|
@ -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, ¶m, &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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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, ¶m, &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, ¶m, &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;
|
||||
|
|
|
|||
|
|
@ -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, ¶m, &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, ¶m, &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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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, ¶m, &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 |
|
||||
|
|
|
|||
|
|
@ -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, ¶m, &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;
|
||||
|
|
|
|||
|
|
@ -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, ¶m, &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();
|
||||
|
|
|
|||
|
|
@ -240,19 +240,9 @@ static void inspect_factory(struct data *data, const struct spa_handle_factory *
|
|||
}
|
||||
}
|
||||
|
||||
static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_update_source(struct spa_source *source)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void do_remove_source(struct spa_source *source)
|
||||
{
|
||||
}
|
||||
static const struct spa_loop_methods impl_loop = {
|
||||
SPA_VERSION_LOOP_METHODS,
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
|
@ -269,10 +259,10 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
data.log = &default_log.log;
|
||||
data.loop.version = SPA_VERSION_LOOP;
|
||||
data.loop.add_source = do_add_source;
|
||||
data.loop.update_source = do_update_source;
|
||||
data.loop.remove_source = do_remove_source;
|
||||
data.loop.iface = SPA_INTERFACE_INIT(
|
||||
SPA_TYPE_INTERFACE_Loop,
|
||||
SPA_VERSION_LOOP,
|
||||
&impl_loop, &data);
|
||||
|
||||
if ((str = getenv("SPA_DEBUG")))
|
||||
data.log->level = atoi(str);
|
||||
|
|
|
|||
|
|
@ -88,9 +88,9 @@ static int on_monitor_event(void *_data, struct spa_event *event)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
||||
static int do_add_source(void *object, struct spa_source *source)
|
||||
{
|
||||
struct data *data = SPA_CONTAINER_OF(loop, struct data, main_loop);
|
||||
struct data *data = object;
|
||||
|
||||
data->sources[data->n_sources] = *source;
|
||||
data->n_sources++;
|
||||
|
|
@ -99,14 +99,10 @@ static int do_add_source(struct spa_loop *loop, struct spa_source *source)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int do_update_source(struct spa_source *source)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void do_remove_source(struct spa_source *source)
|
||||
{
|
||||
}
|
||||
static const struct spa_loop_methods impl_loop = {
|
||||
SPA_VERSION_LOOP_METHODS,
|
||||
.add_source = do_add_source,
|
||||
};
|
||||
|
||||
static const struct spa_monitor_callbacks impl_callbacks = {
|
||||
SPA_VERSION_MONITOR_CALLBACKS,
|
||||
|
|
@ -161,10 +157,10 @@ int main(int argc, char *argv[])
|
|||
uint32_t fidx;
|
||||
|
||||
data.log = &default_log.log;
|
||||
data.main_loop.version = SPA_VERSION_LOOP;
|
||||
data.main_loop.add_source = do_add_source;
|
||||
data.main_loop.update_source = do_update_source;
|
||||
data.main_loop.remove_source = do_remove_source;
|
||||
data.main_loop.iface = SPA_INTERFACE_INIT(
|
||||
SPA_TYPE_INTERFACE_Loop,
|
||||
SPA_VERSION_LOOP,
|
||||
&impl_loop, &data);
|
||||
|
||||
data.support[1] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, data.log);
|
||||
data.support[2] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_MainLoop, &data.main_loop);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue