avoid deref

We can avoid a deref when we use container_of to get from the interface
to the handle.
This commit is contained in:
Wim Taymans 2016-10-12 17:27:29 +02:00
parent 6b3bb79e70
commit 82414810e8
23 changed files with 433 additions and 385 deletions

View file

@ -38,6 +38,7 @@
typedef struct { typedef struct {
uint32_t node; uint32_t node;
uint32_t clock;
} URI; } URI;
struct _PinosSpaALSAMonitorPrivate struct _PinosSpaALSAMonitorPrivate
@ -105,7 +106,7 @@ add_item (PinosSpaALSAMonitor *this, SpaMonitorItem *item)
SpaResult res; SpaResult res;
SpaHandle *handle; SpaHandle *handle;
PinosNode *node; PinosNode *node;
void *iface; void *node_iface, *clock_iface;
PinosProperties *props = NULL; PinosProperties *props = NULL;
g_debug ("alsa-monitor %p: add: \"%s\" (%s)", this, item->name, item->id); g_debug ("alsa-monitor %p: add: \"%s\" (%s)", this, item->name, item->id);
@ -119,8 +120,12 @@ add_item (PinosSpaALSAMonitor *this, SpaMonitorItem *item)
g_error ("can't make factory instance: %d", res); g_error ("can't make factory instance: %d", res);
return; return;
} }
if ((res = spa_handle_get_interface (handle, priv->uri.node, &iface)) < 0) { if ((res = spa_handle_get_interface (handle, priv->uri.node, &node_iface)) < 0) {
g_error ("can't get MONITOR interface: %d", res); g_error ("can't get NODE interface: %d", res);
return;
}
if ((res = spa_handle_get_interface (handle, priv->uri.clock, &clock_iface)) < 0) {
g_error ("can't get CLOCK interface: %d", res);
return; return;
} }
@ -138,7 +143,8 @@ add_item (PinosSpaALSAMonitor *this, SpaMonitorItem *item)
node = g_object_new (PINOS_TYPE_NODE, node = g_object_new (PINOS_TYPE_NODE,
"daemon", priv->daemon, "daemon", priv->daemon,
"name", item->factory->name, "name", item->factory->name,
"node", iface, "node", node_iface,
"clock", clock_iface,
"properties", props, "properties", props,
NULL); NULL);
@ -203,6 +209,7 @@ monitor_constructed (GObject * object)
G_OBJECT_CLASS (pinos_spa_alsa_monitor_parent_class)->constructed (object); G_OBJECT_CLASS (pinos_spa_alsa_monitor_parent_class)->constructed (object);
priv->uri.node = spa_id_map_get_id (priv->daemon->map, SPA_NODE_URI); priv->uri.node = spa_id_map_get_id (priv->daemon->map, SPA_NODE_URI);
priv->uri.clock = spa_id_map_get_id (priv->daemon->map, SPA_CLOCK_URI);
while (TRUE) { while (TRUE) {
SpaMonitorItem *item; SpaMonitorItem *item;

View file

@ -31,6 +31,8 @@
struct _PinosSpaAudioTestSrcPrivate struct _PinosSpaAudioTestSrcPrivate
{ {
PinosRingbuffer *ringbuffer; PinosRingbuffer *ringbuffer;
SpaHandle *handle;
}; };
enum { enum {
@ -40,9 +42,8 @@ enum {
G_DEFINE_TYPE (PinosSpaAudioTestSrc, pinos_spa_audiotestsrc, PINOS_TYPE_NODE); G_DEFINE_TYPE (PinosSpaAudioTestSrc, pinos_spa_audiotestsrc, PINOS_TYPE_NODE);
static SpaResult static SpaResult
make_node (PinosDaemon *daemon, SpaNode **node, const char *lib, const char *name) make_node (PinosDaemon *daemon, SpaHandle **handle, SpaNode **node, const char *lib, const char *name)
{ {
SpaHandle *handle;
SpaResult res; SpaResult res;
void *hnd, *state = NULL; void *hnd, *state = NULL;
SpaEnumHandleFactoryFunc enum_func; SpaEnumHandleFactoryFunc enum_func;
@ -68,16 +69,16 @@ make_node (PinosDaemon *daemon, SpaNode **node, const char *lib, const char *nam
if (strcmp (factory->name, name)) if (strcmp (factory->name, name))
continue; continue;
handle = calloc (1, factory->size); *handle = calloc (1, factory->size);
if ((res = spa_handle_factory_init (factory, if ((res = spa_handle_factory_init (factory,
handle, *handle,
NULL, NULL,
daemon->support, daemon->support,
daemon->n_support)) < 0) { daemon->n_support)) < 0) {
g_error ("can't make factory instance: %d", res); g_error ("can't make factory instance: %d", res);
return res; return res;
} }
if ((res = spa_handle_get_interface (handle, if ((res = spa_handle_get_interface (*handle,
spa_id_map_get_id (daemon->map, SPA_NODE_URI), spa_id_map_get_id (daemon->map, SPA_NODE_URI),
&iface)) < 0) { &iface)) < 0) {
g_error ("can't get interface %d", res); g_error ("can't get interface %d", res);
@ -145,12 +146,12 @@ src_constructed (GObject * object)
static void static void
src_finalize (GObject * object) src_finalize (GObject * object)
{ {
PinosNode *node = PINOS_NODE (object);
PinosSpaAudioTestSrc *src = PINOS_SPA_AUDIOTESTSRC (object); PinosSpaAudioTestSrc *src = PINOS_SPA_AUDIOTESTSRC (object);
PinosSpaAudioTestSrcPrivate *priv = src->priv;
g_debug ("audiotestsrc %p: dispose", src); g_debug ("audiotestsrc %p: dispose", src);
spa_handle_clear (node->node->handle); spa_handle_clear (priv->handle);
g_free (node->node->handle); g_free (priv->handle);
G_OBJECT_CLASS (pinos_spa_audiotestsrc_parent_class)->finalize (object); G_OBJECT_CLASS (pinos_spa_audiotestsrc_parent_class)->finalize (object);
} }
@ -182,8 +183,10 @@ pinos_spa_audiotestsrc_new (PinosDaemon *daemon,
PinosNode *node; PinosNode *node;
SpaNode *n; SpaNode *n;
SpaResult res; SpaResult res;
SpaHandle *handle;
if ((res = make_node (daemon, if ((res = make_node (daemon,
&handle,
&n, &n,
"build/spa/plugins/audiotestsrc/libspa-audiotestsrc.so", "build/spa/plugins/audiotestsrc/libspa-audiotestsrc.so",
"audiotestsrc")) < 0) { "audiotestsrc")) < 0) {
@ -198,5 +201,7 @@ pinos_spa_audiotestsrc_new (PinosDaemon *daemon,
"node", n, "node", n,
NULL); NULL);
PINOS_SPA_AUDIOTESTSRC (node)->priv->handle = handle;
return node; return node;
} }

View file

@ -38,6 +38,7 @@
typedef struct { typedef struct {
uint32_t node; uint32_t node;
uint32_t clock;
} URI; } URI;
struct _PinosSpaV4l2MonitorPrivate struct _PinosSpaV4l2MonitorPrivate
@ -105,7 +106,8 @@ add_item (PinosSpaV4l2Monitor *this, SpaMonitorItem *item)
SpaResult res; SpaResult res;
SpaHandle *handle; SpaHandle *handle;
PinosNode *node; PinosNode *node;
void *iface; void *node_iface;
void *clock_iface;
PinosProperties *props = NULL; PinosProperties *props = NULL;
g_debug ("v4l2-monitor %p: add: \"%s\" (%s)", this, item->name, item->id); g_debug ("v4l2-monitor %p: add: \"%s\" (%s)", this, item->name, item->id);
@ -119,10 +121,14 @@ add_item (PinosSpaV4l2Monitor *this, SpaMonitorItem *item)
g_error ("can't make factory instance: %d", res); g_error ("can't make factory instance: %d", res);
return; return;
} }
if ((res = spa_handle_get_interface (handle, priv->uri.node, &iface)) < 0) { if ((res = spa_handle_get_interface (handle, priv->uri.node, &node_iface)) < 0) {
g_error ("can't get NODE interface: %d", res); g_error ("can't get NODE interface: %d", res);
return; return;
} }
if ((res = spa_handle_get_interface (handle, priv->uri.clock, &clock_iface)) < 0) {
g_error ("can't get CLOCK interface: %d", res);
return;
}
if (item->info) { if (item->info) {
unsigned int i; unsigned int i;
@ -138,7 +144,8 @@ add_item (PinosSpaV4l2Monitor *this, SpaMonitorItem *item)
node = g_object_new (PINOS_TYPE_NODE, node = g_object_new (PINOS_TYPE_NODE,
"daemon", priv->daemon, "daemon", priv->daemon,
"name", item->factory->name, "name", item->factory->name,
"node", iface, "node", node_iface,
"clock", clock_iface,
"properties", props, "properties", props,
NULL); NULL);
@ -203,6 +210,7 @@ monitor_constructed (GObject * object)
G_OBJECT_CLASS (pinos_spa_v4l2_monitor_parent_class)->constructed (object); G_OBJECT_CLASS (pinos_spa_v4l2_monitor_parent_class)->constructed (object);
priv->uri.node = spa_id_map_get_id (priv->daemon->map, SPA_NODE_URI); priv->uri.node = spa_id_map_get_id (priv->daemon->map, SPA_NODE_URI);
priv->uri.clock = spa_id_map_get_id (priv->daemon->map, SPA_CLOCK_URI);
while (TRUE) { while (TRUE) {
SpaMonitorItem *item; SpaMonitorItem *item;

View file

@ -29,7 +29,7 @@
struct _PinosSpaVideoTestSrcPrivate struct _PinosSpaVideoTestSrcPrivate
{ {
gint dummy; SpaHandle *handle;
}; };
enum { enum {
@ -39,9 +39,8 @@ enum {
G_DEFINE_TYPE (PinosSpaVideoTestSrc, pinos_spa_videotestsrc, PINOS_TYPE_NODE); G_DEFINE_TYPE (PinosSpaVideoTestSrc, pinos_spa_videotestsrc, PINOS_TYPE_NODE);
static SpaResult static SpaResult
make_node (PinosDaemon *daemon, SpaNode **node, const char *lib, const char *name) make_node (PinosDaemon *daemon, SpaHandle **handle, SpaNode **node, const char *lib, const char *name)
{ {
SpaHandle *handle;
SpaResult res; SpaResult res;
void *hnd, *state = NULL; void *hnd, *state = NULL;
SpaEnumHandleFactoryFunc enum_func; SpaEnumHandleFactoryFunc enum_func;
@ -67,14 +66,14 @@ make_node (PinosDaemon *daemon, SpaNode **node, const char *lib, const char *nam
if (strcmp (factory->name, name)) if (strcmp (factory->name, name))
continue; continue;
handle = calloc (1, factory->size); *handle = calloc (1, factory->size);
if ((res = factory->init (factory, handle, NULL, daemon->support, daemon->n_support)) < 0) { if ((res = spa_handle_factory_init (factory, *handle, NULL, daemon->support, daemon->n_support)) < 0) {
g_error ("can't make factory instance: %d", res); g_error ("can't make factory instance: %d", res);
return res; return res;
} }
if ((res = handle->get_interface (handle, if ((res = spa_handle_get_interface (*handle,
spa_id_map_get_id (daemon->map, SPA_NODE_URI), spa_id_map_get_id (daemon->map, SPA_NODE_URI),
&iface)) < 0) { &iface)) < 0) {
g_error ("can't get interface %d", res); g_error ("can't get interface %d", res);
return res; return res;
} }
@ -113,12 +112,12 @@ set_property (GObject *object,
static void static void
source_finalize (GObject * object) source_finalize (GObject * object)
{ {
PinosNode *node = PINOS_NODE (object);
PinosSpaVideoTestSrc *source = PINOS_SPA_VIDEOTESTSRC (object); PinosSpaVideoTestSrc *source = PINOS_SPA_VIDEOTESTSRC (object);
PinosSpaVideoTestSrcPrivate *priv = source->priv;
g_debug ("spa-source %p: dispose", source); g_debug ("spa-source %p: dispose", source);
spa_handle_clear (node->node->handle); spa_handle_clear (priv->handle);
g_free (node->node->handle); g_free (priv->handle);
G_OBJECT_CLASS (pinos_spa_videotestsrc_parent_class)->finalize (object); G_OBJECT_CLASS (pinos_spa_videotestsrc_parent_class)->finalize (object);
} }
@ -149,8 +148,10 @@ pinos_spa_videotestsrc_new (PinosDaemon *daemon,
PinosNode *node; PinosNode *node;
SpaNode *n; SpaNode *n;
SpaResult res; SpaResult res;
SpaHandle *handle;
if ((res = make_node (daemon, if ((res = make_node (daemon,
&handle,
&n, &n,
"build/spa/plugins/videotestsrc/libspa-videotestsrc.so", "build/spa/plugins/videotestsrc/libspa-videotestsrc.so",
"videotestsrc")) < 0) { "videotestsrc")) < 0) {
@ -165,5 +166,7 @@ pinos_spa_videotestsrc_new (PinosDaemon *daemon,
"node", n, "node", n,
NULL); NULL);
PINOS_SPA_VIDEOTESTSRC (node)->priv->handle = handle;
return node; return node;
} }

View file

@ -44,6 +44,7 @@ struct _PinosClientNodePrivate
{ {
int fd; int fd;
GSocket *sockets[2]; GSocket *sockets[2];
SpaHandle *handle;
}; };
#define PINOS_CLIENT_NODE_GET_PRIVATE(obj) \ #define PINOS_CLIENT_NODE_GET_PRIVATE(obj) \
@ -181,7 +182,6 @@ pinos_client_node_dispose (GObject * object)
static void static void
pinos_client_node_finalize (GObject * object) pinos_client_node_finalize (GObject * object)
{ {
PinosNode *node = PINOS_NODE (object);
PinosClientNode *this = PINOS_CLIENT_NODE (object); PinosClientNode *this = PINOS_CLIENT_NODE (object);
PinosClientNodePrivate *priv = this->priv; PinosClientNodePrivate *priv = this->priv;
@ -189,8 +189,8 @@ pinos_client_node_finalize (GObject * object)
g_clear_object (&priv->sockets[0]); g_clear_object (&priv->sockets[0]);
g_clear_object (&priv->sockets[1]); g_clear_object (&priv->sockets[1]);
spa_handle_clear (node->node->handle); spa_handle_clear (priv->handle);
g_free (node->node->handle); g_free (priv->handle);
G_OBJECT_CLASS (pinos_client_node_parent_class)->finalize (object); G_OBJECT_CLASS (pinos_client_node_parent_class)->finalize (object);
} }
@ -228,9 +228,8 @@ pinos_client_node_init (PinosClientNode * node)
} }
static SpaResult static SpaResult
make_node (PinosDaemon *daemon, SpaNode **node, const char *lib, const char *name) make_node (PinosDaemon *daemon, SpaHandle **handle, SpaNode **node, const char *lib, const char *name)
{ {
SpaHandle *handle;
SpaResult res; SpaResult res;
void *hnd, *state = NULL; void *hnd, *state = NULL;
SpaEnumHandleFactoryFunc enum_func; SpaEnumHandleFactoryFunc enum_func;
@ -256,16 +255,16 @@ make_node (PinosDaemon *daemon, SpaNode **node, const char *lib, const char *nam
if (strcmp (factory->name, name)) if (strcmp (factory->name, name))
continue; continue;
handle = calloc (1, factory->size); *handle = calloc (1, factory->size);
if ((res = factory->init (factory, if ((res = factory->init (factory,
handle, *handle,
NULL, NULL,
daemon->support, daemon->support,
daemon->n_support)) < 0) { daemon->n_support)) < 0) {
g_error ("can't make factory instance: %d", res); g_error ("can't make factory instance: %d", res);
return res; return res;
} }
if ((res = handle->get_interface (handle, if ((res = spa_handle_get_interface (*handle,
spa_id_map_get_id (daemon->map, SPA_NODE_URI), spa_id_map_get_id (daemon->map, SPA_NODE_URI),
&iface)) < 0) { &iface)) < 0) {
g_error ("can't get interface %d", res); g_error ("can't get interface %d", res);
@ -296,10 +295,13 @@ pinos_client_node_new (PinosDaemon *daemon,
{ {
SpaNode *n; SpaNode *n;
SpaResult res; SpaResult res;
SpaHandle *handle;
PinosNode *node;
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL); g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
if ((res = make_node (daemon, if ((res = make_node (daemon,
&handle,
&n, &n,
"build/spa/plugins/remote/libspa-remote.so", "build/spa/plugins/remote/libspa-remote.so",
"proxy")) < 0) { "proxy")) < 0) {
@ -307,11 +309,15 @@ pinos_client_node_new (PinosDaemon *daemon,
return NULL; return NULL;
} }
return g_object_new (PINOS_TYPE_CLIENT_NODE, node = g_object_new (PINOS_TYPE_CLIENT_NODE,
"daemon", daemon, "daemon", daemon,
"client", client, "client", client,
"name", name, "name", name,
"properties", properties, "properties", properties,
"node", n, "node", n,
NULL); NULL);
PINOS_CLIENT_NODE (node)->priv->handle = handle;
return node;
} }

View file

@ -112,6 +112,7 @@ enum
PROP_NAME, PROP_NAME,
PROP_PROPERTIES, PROP_PROPERTIES,
PROP_NODE, PROP_NODE,
PROP_CLOCK,
}; };
enum enum
@ -587,6 +588,10 @@ pinos_node_get_property (GObject *_object,
g_value_set_pointer (value, this->node); g_value_set_pointer (value, this->node);
break; break;
case PROP_CLOCK:
g_value_set_pointer (value, this->clock);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (this, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (this, prop_id, pspec);
break; break;
@ -638,14 +643,20 @@ pinos_node_set_property (GObject *_object,
case PROP_NODE: case PROP_NODE:
{ {
void *iface;
this->node = g_value_get_pointer (value); this->node = g_value_get_pointer (value);
#if 0
void *iface;
if (this->node->handle->get_interface (this->node->handle, if (this->node->handle->get_interface (this->node->handle,
spa_id_map_get_id (priv->daemon->map, SPA_CLOCK_URI), spa_id_map_get_id (priv->daemon->map, SPA_CLOCK_URI),
&iface) >= 0) &iface) >= 0)
this->clock = iface; this->clock = iface;
#endif
break; break;
} }
case PROP_CLOCK:
this->clock = g_value_get_pointer (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (this, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (this, prop_id, pspec);
break; break;
@ -853,6 +864,14 @@ pinos_node_class_init (PinosNodeClass * klass)
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_CLOCK,
g_param_spec_pointer ("clock",
"Clock",
"The SPA clock",
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_RTLOOP, PROP_RTLOOP,
g_param_spec_object ("rt-loop", g_param_spec_object ("rt-loop",

View file

@ -51,8 +51,6 @@ typedef enum {
* The main processing clocks. * The main processing clocks.
*/ */
struct _SpaClock { struct _SpaClock {
/* pointer to the handle owning this interface */
SpaHandle *handle;
/* the total size of this clock. This can be used to expand this /* the total size of this clock. This can be used to expand this
* structure in the future */ * structure in the future */
size_t size; size_t size;

View file

@ -116,6 +116,46 @@ typedef void (*SpaNotify) (void *data);
# define SPA_PRINTF_FUNC(fmt, arg1) # define SPA_PRINTF_FUNC(fmt, arg1)
#endif #endif
#ifndef SPA_LIKELY
#ifdef __GNUC__
#define SPA_LIKELY(x) (__builtin_expect(!!(x),1))
#define SPA_UNLIKELY(x) (__builtin_expect(!!(x),0))
#else
#define SPA_LIKELY(x) (x)
#define SPA_UNLIKELY(x) (x)
#endif
#endif
#define spa_return_if_fail (log, expr) \
do { \
if (SPA_UNLIKELY (!(expr))) { \
spa_log_debug(log, "Assertion '%s' failed\n", #expr); \
return; \
} \
} while(false)
#define spa_return_val_if_fail (log, expr, val) \
do { \
if (SPA_UNLIKELY(!(expr))) { \
spa_log_debug (log, "Assertion '%s' failed\n", #expr); \
return (val); \
} \
} while(false)
/* spa_assert_se() is an assert which guarantees side effects of x,
* i.e. is never optimized away, regardless of NDEBUG or FASTPATH. */
#define spa_assert_se (expr) \
do { \
if (SPA_UNLIKELY(!(expr))) { \
spa_log_error("Assertion '%s' failed, Aborting\n.", #expr); \
abort(); \
} \
} while (false)
/* Does exactly nothing */
#define spa_nop() do {} while (false)
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View file

@ -98,8 +98,6 @@ typedef void (*SpaMonitorEventCallback) (SpaMonitor *monitor,
* The device monitor interface. * The device monitor interface.
*/ */
struct _SpaMonitor { struct _SpaMonitor {
/* pointer to the handle owning this interface */
SpaHandle *handle;
/** /**
* SpaMonitor::info * SpaMonitor::info
* *

View file

@ -148,8 +148,6 @@ typedef void (*SpaNodeEventCallback) (SpaNode *node,
* The main processing nodes. * The main processing nodes.
*/ */
struct _SpaNode { struct _SpaNode {
/* pointer to the handle owning this interface */
SpaHandle *handle;
/* the total size of this node. This can be used to expand this /* the total size of this node. This can be used to expand this
* structure in the future */ * structure in the future */
size_t size; size_t size;

View file

@ -247,10 +247,10 @@ spa_alsa_monitor_set_event_callback (SpaMonitor *monitor,
SpaResult res; SpaResult res;
SpaALSAMonitor *this; SpaALSAMonitor *this;
if (monitor == NULL || monitor->handle == NULL) if (monitor == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSAMonitor *) monitor->handle; this = SPA_CONTAINER_OF (monitor, SpaALSAMonitor, monitor);
this->event_cb = callback; this->event_cb = callback;
this->user_data = user_data; this->user_data = user_data;
@ -299,10 +299,10 @@ spa_alsa_monitor_enum_items (SpaMonitor *monitor,
struct udev_list_entry *devices; struct udev_list_entry *devices;
struct udev_device *dev; struct udev_device *dev;
if (monitor == NULL || monitor->handle == NULL || item == NULL || state == NULL) if (monitor == NULL || item == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSAMonitor *) monitor->handle; this = SPA_CONTAINER_OF (monitor, SpaALSAMonitor, monitor);
if ((res = alsa_udev_open (this)) < 0) if ((res = alsa_udev_open (this)) < 0)
return res; return res;
@ -343,7 +343,6 @@ again:
} }
static const SpaMonitor alsamonitor = { static const SpaMonitor alsamonitor = {
NULL,
NULL, NULL,
sizeof (SpaMonitor), sizeof (SpaMonitor),
spa_alsa_monitor_set_event_callback, spa_alsa_monitor_set_event_callback,
@ -413,7 +412,6 @@ alsa_monitor_init (const SpaHandleFactory *factory,
this->uri.monitor = spa_id_map_get_id (this->map, SPA_MONITOR_URI); this->uri.monitor = spa_id_map_get_id (this->map, SPA_MONITOR_URI);
this->monitor = alsamonitor; this->monitor = alsamonitor;
this->monitor.handle = handle;
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }

View file

@ -114,10 +114,10 @@ spa_alsa_sink_node_get_props (SpaNode *node,
{ {
SpaALSASink *this; SpaALSASink *this;
if (node == NULL || node->handle == NULL || props == NULL) if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASink *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASink, node);
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
*props = &this->props[0].props; *props = &this->props[0].props;
@ -133,10 +133,10 @@ spa_alsa_sink_node_set_props (SpaNode *node,
SpaALSAProps *p; SpaALSAProps *p;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASink *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASink, node);
p = &this->props[1]; p = &this->props[1];
if (props == NULL) { if (props == NULL) {
@ -155,10 +155,10 @@ spa_alsa_sink_node_send_command (SpaNode *node,
{ {
SpaALSASink *this; SpaALSASink *this;
if (node == NULL || node->handle == NULL || command == NULL) if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASink *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASink, node);
switch (command->type) { switch (command->type) {
case SPA_NODE_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
@ -190,10 +190,10 @@ spa_alsa_sink_node_set_event_callback (SpaNode *node,
{ {
SpaALSASink *this; SpaALSASink *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASink *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASink, node);
this->event_cb = event; this->event_cb = event;
this->user_data = user_data; this->user_data = user_data;
@ -208,7 +208,7 @@ spa_alsa_sink_node_get_n_ports (SpaNode *node,
unsigned int *n_output_ports, unsigned int *n_output_ports,
unsigned int *max_output_ports) unsigned int *max_output_ports)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports) if (n_input_ports)
@ -230,7 +230,7 @@ spa_alsa_sink_node_get_port_ids (SpaNode *node,
unsigned int n_output_ports, unsigned int n_output_ports,
uint32_t *output_ids) uint32_t *output_ids)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports > 0 && input_ids != NULL) if (n_input_ports > 0 && input_ids != NULL)
@ -267,10 +267,10 @@ spa_alsa_sink_node_port_enum_formats (SpaNode *node,
SpaALSASink *this; SpaALSASink *this;
int index; int index;
if (node == NULL || node->handle == NULL || format == NULL || state == NULL) if (node == NULL || format == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASink *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -307,10 +307,10 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
SpaALSASink *this; SpaALSASink *this;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASink *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -357,10 +357,10 @@ spa_alsa_sink_node_port_get_format (SpaNode *node,
{ {
SpaALSASink *this; SpaALSASink *this;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASink *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -381,10 +381,10 @@ spa_alsa_sink_node_port_get_info (SpaNode *node,
{ {
SpaALSASink *this; SpaALSASink *this;
if (node == NULL || node->handle == NULL || info == NULL) if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASink *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -433,13 +433,13 @@ spa_alsa_sink_node_port_alloc_buffers (SpaNode *node,
{ {
SpaALSASink *this; SpaALSASink *this;
if (node == NULL || node->handle == NULL || buffers == NULL) if (node == NULL || buffers == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
this = (SpaALSASink *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (!this->have_format) if (!this->have_format)
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
@ -455,10 +455,10 @@ spa_alsa_sink_node_port_get_status (SpaNode *node,
{ {
SpaALSASink *this; SpaALSASink *this;
if (node == NULL || node->handle == NULL || status == NULL) if (node == NULL || status == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASink *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASink, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -477,10 +477,10 @@ spa_alsa_sink_node_port_push_input (SpaNode *node,
unsigned int i; unsigned int i;
bool have_error = false, have_enough = false; bool have_error = false, have_enough = false;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASink *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASink, node);
for (i = 0; i < n_info; i++) { for (i = 0; i < n_info; i++) {
if (info[i].port_id != 0) { if (info[i].port_id != 0) {
@ -540,7 +540,6 @@ spa_alsa_sink_node_port_push_event (SpaNode *node,
static const SpaNode alsasink_node = { static const SpaNode alsasink_node = {
NULL,
sizeof (SpaNode), sizeof (SpaNode),
NULL, NULL,
SPA_NODE_STATE_INIT, SPA_NODE_STATE_INIT,
@ -624,7 +623,6 @@ alsa_sink_init (const SpaHandleFactory *factory,
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
this->node = alsasink_node; this->node = alsasink_node;
this->node.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.n_prop_info = PROP_ID_LAST;
this->props[1].props.prop_info = prop_info; this->props[1].props.prop_info = prop_info;
this->stream = SND_PCM_STREAM_PLAYBACK; this->stream = SND_PCM_STREAM_PLAYBACK;

View file

@ -116,10 +116,10 @@ spa_alsa_source_node_get_props (SpaNode *node,
{ {
SpaALSASource *this; SpaALSASource *this;
if (node == NULL || node->handle == NULL || props == NULL) if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
*props = &this->props[0].props; *props = &this->props[0].props;
@ -135,10 +135,10 @@ spa_alsa_source_node_set_props (SpaNode *node,
SpaALSAProps *p; SpaALSAProps *p;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
p = &this->props[1]; p = &this->props[1];
if (props == NULL) { if (props == NULL) {
@ -157,10 +157,10 @@ spa_alsa_source_node_send_command (SpaNode *node,
{ {
SpaALSASource *this; SpaALSASource *this;
if (node == NULL || node->handle == NULL || command == NULL) if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
switch (command->type) { switch (command->type) {
case SPA_NODE_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
@ -194,10 +194,10 @@ spa_alsa_source_node_set_event_callback (SpaNode *node,
{ {
SpaALSASource *this; SpaALSASource *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
this->event_cb = event; this->event_cb = event;
this->user_data = user_data; this->user_data = user_data;
@ -212,7 +212,7 @@ spa_alsa_source_node_get_n_ports (SpaNode *node,
unsigned int *n_output_ports, unsigned int *n_output_ports,
unsigned int *max_output_ports) unsigned int *max_output_ports)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports) if (n_input_ports)
@ -234,7 +234,7 @@ spa_alsa_source_node_get_port_ids (SpaNode *node,
unsigned int n_output_ports, unsigned int n_output_ports,
uint32_t *output_ids) uint32_t *output_ids)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_output_ports > 0 && output_ids != NULL) if (n_output_ports > 0 && output_ids != NULL)
@ -271,10 +271,10 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
SpaALSASource *this; SpaALSASource *this;
int index; int index;
if (node == NULL || node->handle == NULL || format == NULL || state == NULL) if (node == NULL || format == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -336,10 +336,10 @@ spa_alsa_source_node_port_set_format (SpaNode *node,
SpaALSASource *this; SpaALSASource *this;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -392,10 +392,10 @@ spa_alsa_source_node_port_get_format (SpaNode *node,
{ {
SpaALSASource *this; SpaALSASource *this;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -416,10 +416,10 @@ spa_alsa_source_node_port_get_info (SpaNode *node,
{ {
SpaALSASource *this; SpaALSASource *this;
if (node == NULL || node->handle == NULL || info == NULL) if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -458,13 +458,13 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node,
SpaResult res; SpaResult res;
int i; int i;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (!this->have_format) if (!this->have_format)
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
@ -517,13 +517,13 @@ spa_alsa_source_node_port_alloc_buffers (SpaNode *node,
{ {
SpaALSASource *this; SpaALSASource *this;
if (node == NULL || node->handle == NULL || buffers == NULL) if (node == NULL || buffers == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (this->n_buffers == 0) if (this->n_buffers == 0)
return SPA_RESULT_NO_FORMAT; return SPA_RESULT_NO_FORMAT;
@ -539,10 +539,10 @@ spa_alsa_source_node_port_get_status (SpaNode *node,
{ {
SpaALSASource *this; SpaALSASource *this;
if (node == NULL || node->handle == NULL || status == NULL) if (node == NULL || status == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -569,10 +569,10 @@ spa_alsa_source_node_port_pull_output (SpaNode *node,
unsigned int i; unsigned int i;
bool have_error = false; bool have_error = false;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
for (i = 0; i < n_info; i++) { for (i = 0; i < n_info; i++) {
SpaALSABuffer *b; SpaALSABuffer *b;
@ -614,10 +614,10 @@ spa_alsa_source_node_port_reuse_buffer (SpaNode *node,
{ {
SpaALSASource *this; SpaALSASource *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) node->handle; this = SPA_CONTAINER_OF (node, SpaALSASource, node);
if (port_id != 0) if (port_id != 0)
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -643,7 +643,6 @@ spa_alsa_source_node_port_push_event (SpaNode *node,
} }
static const SpaNode alsasource_node = { static const SpaNode alsasource_node = {
NULL,
sizeof (SpaNode), sizeof (SpaNode),
NULL, NULL,
SPA_NODE_STATE_INIT, SPA_NODE_STATE_INIT,
@ -692,10 +691,10 @@ spa_alsa_source_clock_get_time (SpaClock *clock,
{ {
SpaALSASource *this; SpaALSASource *this;
if (clock == NULL || clock->handle == NULL) if (clock == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaALSASource *) clock->handle; this = SPA_CONTAINER_OF (clock, SpaALSASource, clock);
if (rate) if (rate)
*rate = SPA_USEC_PER_SEC; *rate = SPA_USEC_PER_SEC;
@ -708,7 +707,6 @@ spa_alsa_source_clock_get_time (SpaClock *clock,
} }
static const SpaClock alsasource_clock = { static const SpaClock alsasource_clock = {
NULL,
sizeof (SpaClock), sizeof (SpaClock),
NULL, NULL,
SPA_CLOCK_STATE_STOPPED, SPA_CLOCK_STATE_STOPPED,
@ -779,9 +777,7 @@ alsa_source_init (const SpaHandleFactory *factory,
this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI); this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI);
this->node = alsasource_node; this->node = alsasource_node;
this->node.handle = handle;
this->clock = alsasource_clock; this->clock = alsasource_clock;
this->clock.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.n_prop_info = PROP_ID_LAST;
this->props[1].props.prop_info = prop_info; this->props[1].props.prop_info = prop_info;
this->stream = SND_PCM_STREAM_CAPTURE; this->stream = SND_PCM_STREAM_CAPTURE;

View file

@ -112,10 +112,10 @@ spa_audiomixer_node_get_props (SpaNode *node,
{ {
SpaAudioMixer *this; SpaAudioMixer *this;
if (node == NULL || node->handle == NULL || props == NULL) if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
*props = &this->props[0].props; *props = &this->props[0].props;
@ -131,10 +131,10 @@ spa_audiomixer_node_set_props (SpaNode *node,
SpaAudioMixerProps *p; SpaAudioMixerProps *p;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
p = &this->props[1]; p = &this->props[1];
if (props == NULL) { if (props == NULL) {
@ -158,10 +158,10 @@ spa_audiomixer_node_send_command (SpaNode *node,
{ {
SpaAudioMixer *this; SpaAudioMixer *this;
if (node == NULL || node->handle == NULL || command == NULL) if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
switch (command->type) { switch (command->type) {
case SPA_NODE_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
@ -191,10 +191,10 @@ spa_audiomixer_node_set_event_callback (SpaNode *node,
{ {
SpaAudioMixer *this; SpaAudioMixer *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
this->event_cb = event; this->event_cb = event;
this->user_data = user_data; this->user_data = user_data;
@ -209,7 +209,7 @@ spa_audiomixer_node_get_n_ports (SpaNode *node,
unsigned int *n_output_ports, unsigned int *n_output_ports,
unsigned int *max_output_ports) unsigned int *max_output_ports)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports) if (n_input_ports)
@ -234,10 +234,10 @@ spa_audiomixer_node_get_port_ids (SpaNode *node,
SpaAudioMixer *this; SpaAudioMixer *this;
int i, idx; int i, idx;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (input_ids) { if (input_ids) {
for (i = 0, idx = 0; i < MAX_PORTS && idx < n_input_ports; i++) { for (i = 0, idx = 0; i < MAX_PORTS && idx < n_input_ports; i++) {
@ -258,10 +258,10 @@ spa_audiomixer_node_add_port (SpaNode *node,
{ {
SpaAudioMixer *this; SpaAudioMixer *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_FREE_IN_PORT (this, direction, port_id)) if (!CHECK_FREE_IN_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -287,10 +287,10 @@ spa_audiomixer_node_remove_port (SpaNode *node,
{ {
SpaAudioMixer *this; SpaAudioMixer *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_IN_PORT (this, direction, port_id)) if (!CHECK_IN_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -320,10 +320,10 @@ spa_audiomixer_node_port_enum_formats (SpaNode *node,
SpaAudioMixerPort *port; SpaAudioMixerPort *port;
int index; int index;
if (node == NULL || node->handle == NULL || format == NULL || state == NULL) if (node == NULL || format == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -358,10 +358,10 @@ spa_audiomixer_node_port_set_format (SpaNode *node,
SpaAudioMixerPort *port; SpaAudioMixerPort *port;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -390,10 +390,10 @@ spa_audiomixer_node_port_get_format (SpaNode *node,
SpaAudioMixer *this; SpaAudioMixer *this;
SpaAudioMixerPort *port; SpaAudioMixerPort *port;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -417,10 +417,10 @@ spa_audiomixer_node_port_get_info (SpaNode *node,
SpaAudioMixer *this; SpaAudioMixer *this;
SpaAudioMixerPort *port; SpaAudioMixerPort *port;
if (node == NULL || node->handle == NULL || info == NULL) if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -480,10 +480,10 @@ spa_audiomixer_node_port_get_status (SpaNode *node,
SpaAudioMixer *this; SpaAudioMixer *this;
SpaAudioMixerPort *port; SpaAudioMixerPort *port;
if (node == NULL || node->handle == NULL || status == NULL) if (node == NULL || status == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -506,10 +506,10 @@ spa_audiomixer_node_port_push_input (SpaNode *node,
unsigned int i; unsigned int i;
bool have_error = false; bool have_error = false;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (this->out_ports[0].status.flags & SPA_PORT_STATUS_FLAG_HAVE_OUTPUT) if (this->out_ports[0].status.flags & SPA_PORT_STATUS_FLAG_HAVE_OUTPUT)
return SPA_RESULT_HAVE_ENOUGH_INPUT; return SPA_RESULT_HAVE_ENOUGH_INPUT;
@ -684,10 +684,10 @@ spa_audiomixer_node_port_pull_output (SpaNode *node,
int i; int i;
bool have_error = false; bool have_error = false;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioMixer *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
if (!CHECK_OUT_PORT (this, SPA_DIRECTION_OUTPUT, info->port_id)) if (!CHECK_OUT_PORT (this, SPA_DIRECTION_OUTPUT, info->port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -731,7 +731,6 @@ spa_audiomixer_node_port_push_event (SpaNode *node,
} }
static const SpaNode audiomixer_node = { static const SpaNode audiomixer_node = {
NULL,
sizeof (SpaNode), sizeof (SpaNode),
NULL, NULL,
SPA_NODE_STATE_INIT, SPA_NODE_STATE_INIT,
@ -815,7 +814,6 @@ spa_audiomixer_init (const SpaHandleFactory *factory,
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
this->node = audiomixer_node; this->node = audiomixer_node;
this->node.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.n_prop_info = PROP_ID_LAST;
this->props[1].props.prop_info = prop_info; this->props[1].props.prop_info = prop_info;
reset_audiomixer_props (&this->props[1]); reset_audiomixer_props (&this->props[1]);

View file

@ -187,10 +187,10 @@ spa_audiotestsrc_node_get_props (SpaNode *node,
{ {
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
if (node == NULL || node->handle == NULL || props == NULL) if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
*props = &this->props[0].props; *props = &this->props[0].props;
@ -206,10 +206,10 @@ spa_audiotestsrc_node_set_props (SpaNode *node,
SpaAudioTestSrcProps *p; SpaAudioTestSrcProps *p;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
p = &this->props[1]; p = &this->props[1];
if (props == NULL) { if (props == NULL) {
@ -346,10 +346,10 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
{ {
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
if (node == NULL || node->handle == NULL || command == NULL) if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
switch (command->type) { switch (command->type) {
case SPA_NODE_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
@ -413,10 +413,10 @@ spa_audiotestsrc_node_set_event_callback (SpaNode *node,
{ {
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (event_cb == NULL && this->event_cb) { if (event_cb == NULL && this->event_cb) {
spa_poll_remove_item (this->data_loop, &this->timer); spa_poll_remove_item (this->data_loop, &this->timer);
@ -438,7 +438,7 @@ spa_audiotestsrc_node_get_n_ports (SpaNode *node,
unsigned int *n_output_ports, unsigned int *n_output_ports,
unsigned int *max_output_ports) unsigned int *max_output_ports)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports) if (n_input_ports)
@ -460,7 +460,7 @@ spa_audiotestsrc_node_get_port_ids (SpaNode *node,
unsigned int n_output_ports, unsigned int n_output_ports,
uint32_t *output_ids) uint32_t *output_ids)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_output_ports > 0 && output_ids != NULL) if (n_output_ports > 0 && output_ids != NULL)
@ -496,10 +496,10 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
int index; int index;
if (node == NULL || node->handle == NULL || format == NULL || state == NULL) if (node == NULL || format == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -546,10 +546,10 @@ spa_audiotestsrc_node_port_set_format (SpaNode *node,
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -600,10 +600,10 @@ spa_audiotestsrc_node_port_get_format (SpaNode *node,
{ {
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -624,10 +624,10 @@ spa_audiotestsrc_node_port_get_info (SpaNode *node,
{ {
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
if (node == NULL || node->handle == NULL || info == NULL) if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -665,10 +665,10 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node,
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
unsigned int i; unsigned int i;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -726,10 +726,10 @@ spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node,
{ {
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -751,10 +751,10 @@ spa_audiotestsrc_node_port_get_status (SpaNode *node,
{ {
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
if (node == NULL || node->handle == NULL || status == NULL) if (node == NULL || status == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -785,10 +785,10 @@ spa_audiotestsrc_node_port_pull_output (SpaNode *node,
unsigned int i; unsigned int i;
bool have_error = false; bool have_error = false;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
for (i = 0; i < n_info; i++) { for (i = 0; i < n_info; i++) {
ATSBuffer *b; ATSBuffer *b;
@ -830,10 +830,10 @@ spa_audiotestsrc_node_port_reuse_buffer (SpaNode *node,
SpaAudioTestSrc *this; SpaAudioTestSrc *this;
ATSBuffer *b; ATSBuffer *b;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaAudioTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
if (port_id != 0) if (port_id != 0)
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -868,7 +868,6 @@ spa_audiotestsrc_node_port_push_event (SpaNode *node,
} }
static const SpaNode audiotestsrc_node = { static const SpaNode audiotestsrc_node = {
NULL,
sizeof (SpaNode), sizeof (SpaNode),
NULL, NULL,
SPA_NODE_STATE_INIT, SPA_NODE_STATE_INIT,
@ -918,7 +917,7 @@ spa_audiotestsrc_clock_get_time (SpaClock *clock,
struct timespec now; struct timespec now;
uint64_t tnow; uint64_t tnow;
if (clock == NULL || clock->handle == NULL) if (clock == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (rate) if (rate)
@ -936,7 +935,6 @@ spa_audiotestsrc_clock_get_time (SpaClock *clock,
} }
static const SpaClock audiotestsrc_clock = { static const SpaClock audiotestsrc_clock = {
NULL,
sizeof (SpaClock), sizeof (SpaClock),
NULL, NULL,
SPA_CLOCK_STATE_STOPPED, SPA_CLOCK_STATE_STOPPED,
@ -1020,9 +1018,7 @@ audiotestsrc_init (const SpaHandleFactory *factory,
this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI); this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI);
this->node = audiotestsrc_node; this->node = audiotestsrc_node;
this->node.handle = handle;
this->clock = audiotestsrc_clock; this->clock = audiotestsrc_clock;
this->clock.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.n_prop_info = PROP_ID_LAST;
this->props[1].props.prop_info = prop_info; this->props[1].props.prop_info = prop_info;
reset_audiotestsrc_props (&this->props[1]); reset_audiotestsrc_props (&this->props[1]);

View file

@ -96,10 +96,10 @@ spa_ffmpeg_dec_node_get_props (SpaNode *node,
{ {
SpaFFMpegDec *this; SpaFFMpegDec *this;
if (node == NULL || node->handle == NULL || props == NULL) if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegDec *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
*props = &this->props[0].props; *props = &this->props[0].props;
@ -115,10 +115,10 @@ spa_ffmpeg_dec_node_set_props (SpaNode *node,
SpaFFMpegDecProps *p; SpaFFMpegDecProps *p;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegDec *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
p = &this->props[1]; p = &this->props[1];
if (props == NULL) { if (props == NULL) {
@ -143,10 +143,10 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node,
{ {
SpaFFMpegDec *this; SpaFFMpegDec *this;
if (node == NULL || node->handle == NULL || command == NULL) if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegDec *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
switch (command->type) { switch (command->type) {
case SPA_NODE_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
@ -176,10 +176,10 @@ spa_ffmpeg_dec_node_set_event_callback (SpaNode *node,
{ {
SpaFFMpegDec *this; SpaFFMpegDec *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegDec *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
this->event_cb = event; this->event_cb = event;
this->user_data = user_data; this->user_data = user_data;
@ -194,7 +194,7 @@ spa_ffmpeg_dec_node_get_n_ports (SpaNode *node,
unsigned int *n_output_ports, unsigned int *n_output_ports,
unsigned int *max_output_ports) unsigned int *max_output_ports)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports) if (n_input_ports)
@ -216,7 +216,7 @@ spa_ffmpeg_dec_node_get_port_ids (SpaNode *node,
unsigned int n_output_ports, unsigned int n_output_ports,
uint32_t *output_ids) uint32_t *output_ids)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports > 0 && input_ids != NULL) if (n_input_ports > 0 && input_ids != NULL)
@ -256,10 +256,10 @@ spa_ffmpeg_dec_node_port_enum_formats (SpaNode *node,
SpaFFMpegPort *port; SpaFFMpegPort *port;
int index; int index;
if (node == NULL || node->handle == NULL || format == NULL || state == NULL) if (node == NULL || format == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegDec *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
if (!IS_VALID_PORT (this, direction, port_id)) if (!IS_VALID_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -294,10 +294,10 @@ spa_ffmpeg_dec_node_port_set_format (SpaNode *node,
SpaFFMpegPort *port; SpaFFMpegPort *port;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegDec *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
if (!IS_VALID_PORT (this, direction, port_id)) if (!IS_VALID_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -329,10 +329,10 @@ spa_ffmpeg_dec_node_port_get_format (SpaNode *node,
SpaFFMpegDec *this; SpaFFMpegDec *this;
SpaFFMpegPort *port; SpaFFMpegPort *port;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegDec *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
if (!IS_VALID_PORT (this, direction, port_id)) if (!IS_VALID_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -356,10 +356,10 @@ spa_ffmpeg_dec_node_port_get_info (SpaNode *node,
SpaFFMpegDec *this; SpaFFMpegDec *this;
SpaFFMpegPort *port; SpaFFMpegPort *port;
if (node == NULL || node->handle == NULL || info == NULL) if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegDec *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
if (!IS_VALID_PORT (this, direction, port_id)) if (!IS_VALID_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -395,7 +395,7 @@ spa_ffmpeg_dec_node_port_use_buffers (SpaNode *node,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (!IS_VALID_PORT (node, direction, port_id)) if (!IS_VALID_PORT (node, direction, port_id))
@ -425,10 +425,10 @@ spa_ffmpeg_dec_node_port_get_status (SpaNode *node,
SpaFFMpegDec *this; SpaFFMpegDec *this;
SpaFFMpegPort *port; SpaFFMpegPort *port;
if (node == NULL || node->handle == NULL || status == NULL) if (node == NULL || status == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegDec *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
if (!IS_VALID_PORT (this, direction, port_id)) if (!IS_VALID_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -457,10 +457,10 @@ spa_ffmpeg_dec_node_port_pull_output (SpaNode *node,
unsigned int i; unsigned int i;
bool have_error = false; bool have_error = false;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegDec *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
for (i = 0; i < n_info; i++) { for (i = 0; i < n_info; i++) {
if (info[i].port_id != 0) { if (info[i].port_id != 0) {
@ -488,7 +488,7 @@ spa_ffmpeg_dec_node_port_reuse_buffer (SpaNode *node,
uint32_t port_id, uint32_t port_id,
uint32_t buffer_id) uint32_t buffer_id)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (port_id != 0) if (port_id != 0)
@ -508,7 +508,6 @@ spa_ffmpeg_dec_node_port_push_event (SpaNode *node,
static const SpaNode ffmpeg_dec_node = { static const SpaNode ffmpeg_dec_node = {
NULL,
sizeof (SpaNode), sizeof (SpaNode),
NULL, NULL,
SPA_NODE_STATE_INIT, SPA_NODE_STATE_INIT,
@ -581,7 +580,6 @@ spa_ffmpeg_dec_init (SpaHandle *handle,
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
this->node = ffmpeg_dec_node; this->node = ffmpeg_dec_node;
this->node.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.n_prop_info = PROP_ID_LAST;
this->props[1].props.prop_info = prop_info; this->props[1].props.prop_info = prop_info;
reset_ffmpeg_dec_props (&this->props[1]); reset_ffmpeg_dec_props (&this->props[1]);

View file

@ -108,10 +108,10 @@ spa_ffmpeg_enc_node_get_props (SpaNode *node,
{ {
SpaFFMpegEnc *this; SpaFFMpegEnc *this;
if (node == NULL || node->handle == NULL || props == NULL) if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegEnc *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
*props = &this->props[0].props; *props = &this->props[0].props;
@ -127,10 +127,10 @@ spa_ffmpeg_enc_node_set_props (SpaNode *node,
SpaFFMpegEncProps *p; SpaFFMpegEncProps *p;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegEnc *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
p = &this->props[1]; p = &this->props[1];
if (props == NULL) { if (props == NULL) {
@ -149,10 +149,10 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node,
{ {
SpaFFMpegEnc *this; SpaFFMpegEnc *this;
if (node == NULL || node->handle == NULL || command == NULL) if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegEnc *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
switch (command->type) { switch (command->type) {
case SPA_NODE_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
@ -182,10 +182,10 @@ spa_ffmpeg_enc_node_set_event_callback (SpaNode *node,
{ {
SpaFFMpegEnc *this; SpaFFMpegEnc *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegEnc *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
this->event_cb = event; this->event_cb = event;
this->user_data = user_data; this->user_data = user_data;
@ -200,7 +200,7 @@ spa_ffmpeg_enc_node_get_n_ports (SpaNode *node,
unsigned int *n_output_ports, unsigned int *n_output_ports,
unsigned int *max_output_ports) unsigned int *max_output_ports)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports) if (n_input_ports)
@ -222,7 +222,7 @@ spa_ffmpeg_enc_node_get_port_ids (SpaNode *node,
unsigned int n_output_ports, unsigned int n_output_ports,
uint32_t *output_ids) uint32_t *output_ids)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports > 0 && input_ids != NULL) if (n_input_ports > 0 && input_ids != NULL)
@ -262,10 +262,10 @@ spa_ffmpeg_enc_node_port_enum_formats (SpaNode *node,
SpaFFMpegPort *port; SpaFFMpegPort *port;
int index; int index;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegEnc *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
if (!IS_VALID_PORT (this, direction, port_id)) if (!IS_VALID_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -300,10 +300,10 @@ spa_ffmpeg_enc_node_port_set_format (SpaNode *node,
SpaFFMpegPort *port; SpaFFMpegPort *port;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegEnc *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
if (!IS_VALID_PORT (this, direction, port_id)) if (!IS_VALID_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -338,10 +338,10 @@ spa_ffmpeg_enc_node_port_get_format (SpaNode *node,
SpaFFMpegEnc *this; SpaFFMpegEnc *this;
SpaFFMpegPort *port; SpaFFMpegPort *port;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegEnc *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
if (!IS_VALID_PORT (this, direction, port_id)) if (!IS_VALID_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -365,10 +365,10 @@ spa_ffmpeg_enc_node_port_get_info (SpaNode *node,
SpaFFMpegEnc *this; SpaFFMpegEnc *this;
SpaFFMpegPort *port; SpaFFMpegPort *port;
if (node == NULL || node->handle == NULL || info == NULL) if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegEnc *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
if (!IS_VALID_PORT (this, direction, port_id)) if (!IS_VALID_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -404,7 +404,7 @@ spa_ffmpeg_enc_node_port_use_buffers (SpaNode *node,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (!IS_VALID_PORT (node, direction, port_id)) if (!IS_VALID_PORT (node, direction, port_id))
@ -434,10 +434,10 @@ spa_ffmpeg_enc_node_port_get_status (SpaNode *node,
SpaFFMpegEnc *this; SpaFFMpegEnc *this;
SpaFFMpegPort *port; SpaFFMpegPort *port;
if (node == NULL || node->handle == NULL || status == NULL) if (node == NULL || status == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegEnc *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
if (!IS_VALID_PORT (this, direction, port_id)) if (!IS_VALID_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -466,10 +466,10 @@ spa_ffmpeg_enc_node_port_pull_output (SpaNode *node,
unsigned int i; unsigned int i;
bool have_error = false; bool have_error = false;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaFFMpegEnc *) node->handle; this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
for (i = 0; i < n_info; i++) { for (i = 0; i < n_info; i++) {
@ -498,7 +498,7 @@ spa_ffmpeg_enc_node_port_reuse_buffer (SpaNode *node,
uint32_t port_id, uint32_t port_id,
uint32_t buffer_id) uint32_t buffer_id)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (port_id != 0) if (port_id != 0)
@ -517,7 +517,6 @@ spa_ffmpeg_enc_node_port_push_event (SpaNode *node,
} }
static const SpaNode ffmpeg_enc_node = { static const SpaNode ffmpeg_enc_node = {
NULL,
sizeof (SpaNode), sizeof (SpaNode),
NULL, NULL,
SPA_NODE_STATE_INIT, SPA_NODE_STATE_INIT,
@ -590,7 +589,6 @@ spa_ffmpeg_enc_init (SpaHandle *handle,
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
this->node = ffmpeg_enc_node; this->node = ffmpeg_enc_node;
this->node.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.n_prop_info = PROP_ID_LAST;
this->props[1].props.prop_info = prop_info; this->props[1].props.prop_info = prop_info;
reset_ffmpeg_enc_props (&this->props[1]); reset_ffmpeg_enc_props (&this->props[1]);

View file

@ -196,10 +196,10 @@ spa_proxy_node_get_props (SpaNode *node,
{ {
SpaProxy *this; SpaProxy *this;
if (node == NULL || node->handle == NULL || props == NULL) if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
*props = &this->props[0].props; *props = &this->props[0].props;
@ -215,10 +215,10 @@ spa_proxy_node_set_props (SpaNode *node,
SpaProxyProps *op, *np; SpaProxyProps *op, *np;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
op = &this->props[1]; op = &this->props[1];
np = &this->props[0]; np = &this->props[0];
@ -248,10 +248,10 @@ spa_proxy_node_send_command (SpaNode *node,
SpaProxy *this; SpaProxy *this;
SpaResult res = SPA_RESULT_OK; SpaResult res = SPA_RESULT_OK;
if (node == NULL || node->handle == NULL || command == NULL) if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
switch (command->type) { switch (command->type) {
case SPA_NODE_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
@ -314,10 +314,10 @@ spa_proxy_node_set_event_callback (SpaNode *node,
{ {
SpaProxy *this; SpaProxy *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
this->event_cb = event; this->event_cb = event;
this->user_data = user_data; this->user_data = user_data;
@ -333,10 +333,10 @@ spa_proxy_node_get_n_ports (SpaNode *node,
{ {
SpaProxy *this; SpaProxy *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (n_input_ports) if (n_input_ports)
*n_input_ports = this->n_inputs; *n_input_ports = this->n_inputs;
@ -360,10 +360,10 @@ spa_proxy_node_get_port_ids (SpaNode *node,
SpaProxy *this; SpaProxy *this;
int c, i; int c, i;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (input_ids) { if (input_ids) {
for (c = 0, i = 0; i < MAX_INPUTS && c < n_input_ports; i++) { for (c = 0, i = 0; i < MAX_INPUTS && c < n_input_ports; i++) {
@ -485,10 +485,10 @@ spa_proxy_node_add_port (SpaNode *node,
SpaProxy *this; SpaProxy *this;
SpaProxyPort *port; SpaProxyPort *port;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_FREE_PORT (this, direction, port_id)) if (!CHECK_FREE_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -506,10 +506,10 @@ spa_proxy_node_remove_port (SpaNode *node,
{ {
SpaProxy *this; SpaProxy *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -531,10 +531,10 @@ spa_proxy_node_port_enum_formats (SpaNode *node,
SpaProxyPort *port; SpaProxyPort *port;
int index; int index;
if (node == NULL || node->handle == NULL || format == NULL || state == NULL) if (node == NULL || format == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -566,10 +566,10 @@ spa_proxy_node_port_set_format (SpaNode *node,
uint8_t buf[128]; uint8_t buf[128];
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -600,10 +600,10 @@ spa_proxy_node_port_get_format (SpaNode *node,
SpaProxy *this; SpaProxy *this;
SpaProxyPort *port; SpaProxyPort *port;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -627,10 +627,10 @@ spa_proxy_node_port_get_info (SpaNode *node,
SpaProxy *this; SpaProxy *this;
SpaProxyPort *port; SpaProxyPort *port;
if (node == NULL || node->handle == NULL || info == NULL) if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -669,10 +669,10 @@ spa_proxy_node_port_get_status (SpaNode *node,
SpaProxy *this; SpaProxy *this;
SpaProxyPort *port; SpaProxyPort *port;
if (node == NULL || node->handle == NULL || status == NULL) if (node == NULL || status == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -708,10 +708,10 @@ spa_proxy_node_port_use_buffers (SpaNode *node,
SpaControlMemRef *memref; SpaControlMemRef *memref;
void *p; void *p;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
spa_log_info (this->log, "proxy %p: use buffers %p %u\n", this, buffers, n_buffers); spa_log_info (this->log, "proxy %p: use buffers %p %u\n", this, buffers, n_buffers);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
@ -870,10 +870,10 @@ spa_proxy_node_port_alloc_buffers (SpaNode *node,
SpaProxy *this; SpaProxy *this;
SpaProxyPort *port; SpaProxyPort *port;
if (node == NULL || node->handle == NULL || buffers == NULL) if (node == NULL || buffers == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -942,10 +942,10 @@ spa_proxy_node_port_push_input (SpaNode *node,
uint8_t buf[64]; uint8_t buf[64];
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
spa_control_builder_init_into (&builder, buf, sizeof(buf), NULL, 0); spa_control_builder_init_into (&builder, buf, sizeof(buf), NULL, 0);
@ -1007,10 +1007,10 @@ spa_proxy_node_port_pull_output (SpaNode *node,
bool have_error = false; bool have_error = false;
bool need_more = false; bool need_more = false;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
for (i = 0; i < n_info; i++) { for (i = 0; i < n_info; i++) {
if (!CHECK_OUT_PORT (this, SPA_DIRECTION_OUTPUT, info[i].port_id)) { if (!CHECK_OUT_PORT (this, SPA_DIRECTION_OUTPUT, info[i].port_id)) {
@ -1055,10 +1055,10 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node,
SpaNodeEvent ne; SpaNodeEvent ne;
SpaNodeEventReuseBuffer rb; SpaNodeEventReuseBuffer rb;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
if (!CHECK_OUT_PORT (this, SPA_DIRECTION_OUTPUT, port_id)) if (!CHECK_OUT_PORT (this, SPA_DIRECTION_OUTPUT, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -1090,10 +1090,10 @@ spa_proxy_node_port_push_event (SpaNode *node,
{ {
SpaProxy *this; SpaProxy *this;
if (node == NULL || node->handle == NULL || event == NULL) if (node == NULL || event == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaProxy *) node->handle; this = SPA_CONTAINER_OF (node, SpaProxy, node);
switch (event->type) { switch (event->type) {
default: default:
@ -1277,7 +1277,6 @@ proxy_on_fd_events (SpaPollNotifyData *data)
} }
static const SpaNode proxy_node = { static const SpaNode proxy_node = {
NULL,
sizeof (SpaNode), sizeof (SpaNode),
NULL, NULL,
SPA_NODE_STATE_INIT, SPA_NODE_STATE_INIT,
@ -1382,7 +1381,6 @@ proxy_init (const SpaHandleFactory *factory,
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
this->node = proxy_node; this->node = proxy_node;
this->node.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.n_prop_info = PROP_ID_LAST;
this->props[1].props.prop_info = prop_info; this->props[1].props.prop_info = prop_info;
reset_proxy_props (&this->props[1]); reset_proxy_props (&this->props[1]);

View file

@ -218,10 +218,10 @@ spa_v4l2_monitor_set_event_callback (SpaMonitor *monitor,
SpaResult res; SpaResult res;
SpaV4l2Monitor *this; SpaV4l2Monitor *this;
if (monitor == NULL || monitor->handle == NULL) if (monitor == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Monitor *) monitor->handle; this = SPA_CONTAINER_OF (monitor, SpaV4l2Monitor, monitor);
this->event_cb = callback; this->event_cb = callback;
this->user_data = user_data; this->user_data = user_data;
@ -271,10 +271,10 @@ spa_v4l2_monitor_enum_items (SpaMonitor *monitor,
struct udev_list_entry *devices; struct udev_list_entry *devices;
struct udev_device *dev; struct udev_device *dev;
if (monitor == NULL || monitor->handle == NULL || item == NULL || state == NULL) if (monitor == NULL || item == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Monitor *) monitor->handle; this = SPA_CONTAINER_OF (monitor, SpaV4l2Monitor, monitor);
if ((res = v4l2_udev_open (this)) < 0) if ((res = v4l2_udev_open (this)) < 0)
return res; return res;
@ -315,7 +315,6 @@ spa_v4l2_monitor_enum_items (SpaMonitor *monitor,
} }
static const SpaMonitor v4l2monitor = { static const SpaMonitor v4l2monitor = {
NULL,
NULL, NULL,
sizeof (SpaMonitor), sizeof (SpaMonitor),
spa_v4l2_monitor_set_event_callback, spa_v4l2_monitor_set_event_callback,
@ -385,7 +384,6 @@ v4l2_monitor_init (const SpaHandleFactory *factory,
this->uri.monitor = spa_id_map_get_id (this->map, SPA_MONITOR_URI); this->uri.monitor = spa_id_map_get_id (this->map, SPA_MONITOR_URI);
this->monitor = v4l2monitor; this->monitor = v4l2monitor;
this->monitor.handle = handle;
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }

View file

@ -186,10 +186,10 @@ spa_v4l2_source_node_get_props (SpaNode *node,
{ {
SpaV4l2Source *this; SpaV4l2Source *this;
if (node == NULL || node->handle == NULL || props == NULL) if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
*props = &this->props[0].props; *props = &this->props[0].props;
@ -205,10 +205,10 @@ spa_v4l2_source_node_set_props (SpaNode *node,
SpaV4l2SourceProps *p; SpaV4l2SourceProps *p;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
p = &this->props[1]; p = &this->props[1];
if (props == NULL) { if (props == NULL) {
@ -228,10 +228,10 @@ spa_v4l2_source_node_send_command (SpaNode *node,
SpaV4l2Source *this; SpaV4l2Source *this;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL || command == NULL) if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
switch (command->type) { switch (command->type) {
case SPA_NODE_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
@ -288,10 +288,10 @@ spa_v4l2_source_node_set_event_callback (SpaNode *node,
{ {
SpaV4l2Source *this; SpaV4l2Source *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
this->event_cb = event; this->event_cb = event;
this->user_data = user_data; this->user_data = user_data;
@ -306,7 +306,7 @@ spa_v4l2_source_node_get_n_ports (SpaNode *node,
unsigned int *n_output_ports, unsigned int *n_output_ports,
unsigned int *max_output_ports) unsigned int *max_output_ports)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports) if (n_input_ports)
@ -328,7 +328,7 @@ spa_v4l2_source_node_get_port_ids (SpaNode *node,
unsigned int n_output_ports, unsigned int n_output_ports,
uint32_t *output_ids) uint32_t *output_ids)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_output_ports > 0 && output_ids != NULL) if (n_output_ports > 0 && output_ids != NULL)
@ -382,10 +382,10 @@ spa_v4l2_source_node_port_enum_formats (SpaNode *node,
SpaV4l2Source *this; SpaV4l2Source *this;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL || format == NULL || state == NULL) if (node == NULL || format == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -408,10 +408,10 @@ spa_v4l2_source_node_port_set_format (SpaNode *node,
V4l2Format *f, *tf; V4l2Format *f, *tf;
size_t fs; size_t fs;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -477,10 +477,10 @@ spa_v4l2_source_node_port_get_format (SpaNode *node,
SpaV4l2Source *this; SpaV4l2Source *this;
SpaV4l2State *state; SpaV4l2State *state;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -503,10 +503,10 @@ spa_v4l2_source_node_port_get_info (SpaNode *node,
{ {
SpaV4l2Source *this; SpaV4l2Source *this;
if (node == NULL || node->handle == NULL || info == NULL) if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -545,10 +545,10 @@ spa_v4l2_source_node_port_use_buffers (SpaNode *node,
SpaV4l2State *state; SpaV4l2State *state;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -588,10 +588,10 @@ spa_v4l2_source_node_port_alloc_buffers (SpaNode *node,
SpaV4l2State *state; SpaV4l2State *state;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL || buffers == NULL) if (node == NULL || buffers == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -621,10 +621,10 @@ spa_v4l2_source_node_port_get_status (SpaNode *node,
{ {
SpaV4l2Source *this; SpaV4l2Source *this;
if (node == NULL || node->handle == NULL || status == NULL) if (node == NULL || status == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -652,10 +652,10 @@ spa_v4l2_source_node_port_pull_output (SpaNode *node,
unsigned int i; unsigned int i;
bool have_error = false; bool have_error = false;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
for (i = 0; i < n_info; i++) { for (i = 0; i < n_info; i++) {
V4l2Buffer *b; V4l2Buffer *b;
@ -699,10 +699,10 @@ spa_v4l2_source_node_port_reuse_buffer (SpaNode *node,
SpaV4l2State *state; SpaV4l2State *state;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) node->handle; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
if (port_id != 0) if (port_id != 0)
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -731,7 +731,6 @@ spa_v4l2_source_node_port_push_event (SpaNode *node,
static const SpaNode v4l2source_node = { static const SpaNode v4l2source_node = {
NULL,
sizeof (SpaNode), sizeof (SpaNode),
NULL, NULL,
SPA_NODE_STATE_INIT, SPA_NODE_STATE_INIT,
@ -781,10 +780,10 @@ spa_v4l2_source_clock_get_time (SpaClock *clock,
SpaV4l2Source *this; SpaV4l2Source *this;
SpaV4l2State *state; SpaV4l2State *state;
if (clock == NULL || clock->handle == NULL) if (clock == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaV4l2Source *) clock->handle; this = SPA_CONTAINER_OF (clock, SpaV4l2Source, clock);
state = &this->state[0]; state = &this->state[0];
if (rate) if (rate)
@ -798,7 +797,6 @@ spa_v4l2_source_clock_get_time (SpaClock *clock,
} }
static const SpaClock v4l2source_clock = { static const SpaClock v4l2source_clock = {
NULL,
sizeof (SpaClock), sizeof (SpaClock),
NULL, NULL,
SPA_CLOCK_STATE_STOPPED, SPA_CLOCK_STATE_STOPPED,
@ -874,9 +872,7 @@ v4l2_source_init (const SpaHandleFactory *factory,
this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI); this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI);
this->node = v4l2source_node; this->node = v4l2source_node;
this->node.handle = handle;
this->clock = v4l2source_clock; this->clock = v4l2source_clock;
this->clock.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.n_prop_info = PROP_ID_LAST;
this->props[1].props.prop_info = prop_info; this->props[1].props.prop_info = prop_info;
reset_v4l2_source_props (&this->props[1]); reset_v4l2_source_props (&this->props[1]);

View file

@ -140,10 +140,10 @@ spa_videotestsrc_node_get_props (SpaNode *node,
{ {
SpaVideoTestSrc *this; SpaVideoTestSrc *this;
if (node == NULL || node->handle == NULL || props == NULL) if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
*props = &this->props[0].props; *props = &this->props[0].props;
@ -159,10 +159,10 @@ spa_videotestsrc_node_set_props (SpaNode *node,
SpaVideoTestSrcProps *p; SpaVideoTestSrcProps *p;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
p = &this->props[1]; p = &this->props[1];
if (props == NULL) { if (props == NULL) {
@ -294,10 +294,10 @@ spa_videotestsrc_node_send_command (SpaNode *node,
{ {
SpaVideoTestSrc *this; SpaVideoTestSrc *this;
if (node == NULL || node->handle == NULL || command == NULL) if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
switch (command->type) { switch (command->type) {
case SPA_NODE_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
@ -361,10 +361,10 @@ spa_videotestsrc_node_set_event_callback (SpaNode *node,
{ {
SpaVideoTestSrc *this; SpaVideoTestSrc *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (event_cb == NULL && this->event_cb) { if (event_cb == NULL && this->event_cb) {
spa_poll_remove_item (this->data_loop, &this->timer); spa_poll_remove_item (this->data_loop, &this->timer);
@ -386,7 +386,7 @@ spa_videotestsrc_node_get_n_ports (SpaNode *node,
unsigned int *n_output_ports, unsigned int *n_output_ports,
unsigned int *max_output_ports) unsigned int *max_output_ports)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports) if (n_input_ports)
@ -408,7 +408,7 @@ spa_videotestsrc_node_get_port_ids (SpaNode *node,
unsigned int n_output_ports, unsigned int n_output_ports,
uint32_t *output_ids) uint32_t *output_ids)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_output_ports > 0 && output_ids != NULL) if (n_output_ports > 0 && output_ids != NULL)
@ -444,10 +444,10 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
SpaVideoTestSrc *this; SpaVideoTestSrc *this;
int index; int index;
if (node == NULL || node->handle == NULL || format == NULL || state == NULL) if (node == NULL || format == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -494,10 +494,10 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
SpaVideoTestSrc *this; SpaVideoTestSrc *this;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -549,10 +549,10 @@ spa_videotestsrc_node_port_get_format (SpaNode *node,
{ {
SpaVideoTestSrc *this; SpaVideoTestSrc *this;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -573,10 +573,10 @@ spa_videotestsrc_node_port_get_info (SpaNode *node,
{ {
SpaVideoTestSrc *this; SpaVideoTestSrc *this;
if (node == NULL || node->handle == NULL || info == NULL) if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -614,10 +614,10 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
SpaVideoTestSrc *this; SpaVideoTestSrc *this;
unsigned int i; unsigned int i;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -675,10 +675,10 @@ spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
{ {
SpaVideoTestSrc *this; SpaVideoTestSrc *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -700,10 +700,10 @@ spa_videotestsrc_node_port_get_status (SpaNode *node,
{ {
SpaVideoTestSrc *this; SpaVideoTestSrc *this;
if (node == NULL || node->handle == NULL || status == NULL) if (node == NULL || status == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -733,10 +733,10 @@ spa_videotestsrc_node_port_pull_output (SpaNode *node,
unsigned int i; unsigned int i;
bool have_error = false; bool have_error = false;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
for (i = 0; i < n_info; i++) { for (i = 0; i < n_info; i++) {
VTSBuffer *b; VTSBuffer *b;
@ -778,10 +778,10 @@ spa_videotestsrc_node_port_reuse_buffer (SpaNode *node,
SpaVideoTestSrc *this; SpaVideoTestSrc *this;
VTSBuffer *b; VTSBuffer *b;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
if (port_id != 0) if (port_id != 0)
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -816,7 +816,6 @@ spa_videotestsrc_node_port_push_event (SpaNode *node,
} }
static const SpaNode videotestsrc_node = { static const SpaNode videotestsrc_node = {
NULL,
sizeof (SpaNode), sizeof (SpaNode),
NULL, NULL,
SPA_NODE_STATE_INIT, SPA_NODE_STATE_INIT,
@ -866,7 +865,7 @@ spa_videotestsrc_clock_get_time (SpaClock *clock,
struct timespec now; struct timespec now;
uint64_t tnow; uint64_t tnow;
if (clock == NULL || clock->handle == NULL) if (clock == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (rate) if (rate)
@ -884,7 +883,6 @@ spa_videotestsrc_clock_get_time (SpaClock *clock,
} }
static const SpaClock videotestsrc_clock = { static const SpaClock videotestsrc_clock = {
NULL,
sizeof (SpaClock), sizeof (SpaClock),
NULL, NULL,
SPA_CLOCK_STATE_STOPPED, SPA_CLOCK_STATE_STOPPED,
@ -964,9 +962,7 @@ videotestsrc_init (const SpaHandleFactory *factory,
this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI); this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI);
this->node = videotestsrc_node; this->node = videotestsrc_node;
this->node.handle = handle;
this->clock = videotestsrc_clock; this->clock = videotestsrc_clock;
this->clock.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.n_prop_info = PROP_ID_LAST;
this->props[1].props.prop_info = prop_info; this->props[1].props.prop_info = prop_info;
reset_videotestsrc_props (&this->props[1]); reset_videotestsrc_props (&this->props[1]);

View file

@ -122,10 +122,10 @@ spa_volume_node_get_props (SpaNode *node,
{ {
SpaVolume *this; SpaVolume *this;
if (node == NULL || node->handle == NULL || props == NULL) if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVolume *) node->handle; this = SPA_CONTAINER_OF (node, SpaVolume, node);
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
*props = &this->props[0].props; *props = &this->props[0].props;
@ -141,10 +141,10 @@ spa_volume_node_set_props (SpaNode *node,
SpaVolumeProps *p; SpaVolumeProps *p;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVolume *) node->handle; this = SPA_CONTAINER_OF (node, SpaVolume, node);
p = &this->props[1]; p = &this->props[1];
if (props == NULL) { if (props == NULL) {
@ -162,10 +162,10 @@ spa_volume_node_send_command (SpaNode *node,
{ {
SpaVolume *this; SpaVolume *this;
if (node == NULL || node->handle == NULL || command == NULL) if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVolume *) node->handle; this = SPA_CONTAINER_OF (node, SpaVolume, node);
switch (command->type) { switch (command->type) {
case SPA_NODE_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
@ -195,10 +195,10 @@ spa_volume_node_set_event_callback (SpaNode *node,
{ {
SpaVolume *this; SpaVolume *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVolume *) node->handle; this = SPA_CONTAINER_OF (node, SpaVolume, node);
this->event_cb = event; this->event_cb = event;
this->user_data = user_data; this->user_data = user_data;
@ -213,7 +213,7 @@ spa_volume_node_get_n_ports (SpaNode *node,
unsigned int *n_output_ports, unsigned int *n_output_ports,
unsigned int *max_output_ports) unsigned int *max_output_ports)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports) if (n_input_ports)
@ -235,7 +235,7 @@ spa_volume_node_get_port_ids (SpaNode *node,
unsigned int n_output_ports, unsigned int n_output_ports,
uint32_t *output_ids) uint32_t *output_ids)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports > 0 && input_ids) if (n_input_ports > 0 && input_ids)
@ -274,10 +274,10 @@ spa_volume_node_port_enum_formats (SpaNode *node,
SpaVolume *this; SpaVolume *this;
int index; int index;
if (node == NULL || node->handle == NULL || format == NULL || state == NULL) if (node == NULL || format == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVolume *) node->handle; this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -310,10 +310,10 @@ spa_volume_node_port_set_format (SpaNode *node,
SpaVolumePort *port; SpaVolumePort *port;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVolume *) node->handle; this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -342,10 +342,10 @@ spa_volume_node_port_get_format (SpaNode *node,
SpaVolume *this; SpaVolume *this;
SpaVolumePort *port; SpaVolumePort *port;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVolume *) node->handle; this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -369,10 +369,10 @@ spa_volume_node_port_get_info (SpaNode *node,
SpaVolume *this; SpaVolume *this;
SpaVolumePort *port; SpaVolumePort *port;
if (node == NULL || node->handle == NULL || info == NULL) if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVolume *) node->handle; this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -432,10 +432,10 @@ spa_volume_node_port_get_status (SpaNode *node,
SpaVolume *this; SpaVolume *this;
SpaVolumePort *port; SpaVolumePort *port;
if (node == NULL || node->handle == NULL || status == NULL) if (node == NULL || status == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVolume *) node->handle; this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -461,10 +461,10 @@ spa_volume_node_port_push_input (SpaNode *node,
bool have_error = false; bool have_error = false;
bool have_enough = false; bool have_enough = false;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVolume *) node->handle; this = SPA_CONTAINER_OF (node, SpaVolume, node);
for (i = 0; i < n_info; i++) { for (i = 0; i < n_info; i++) {
SpaVolumePort *port; SpaVolumePort *port;
@ -545,10 +545,10 @@ spa_volume_node_port_pull_output (SpaNode *node,
uint16_t *src, *dst; uint16_t *src, *dst;
double volume; double volume;
if (node == NULL || node->handle == NULL || n_info == 0 || info == NULL) if (node == NULL || n_info == 0 || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVolume *) node->handle; this = SPA_CONTAINER_OF (node, SpaVolume, node);
if (info[0].port_id != 0) if (info[0].port_id != 0)
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -627,7 +627,6 @@ spa_volume_node_port_push_event (SpaNode *node,
} }
static const SpaNode volume_node = { static const SpaNode volume_node = {
NULL,
sizeof (SpaNode), sizeof (SpaNode),
NULL, NULL,
SPA_NODE_STATE_INIT, SPA_NODE_STATE_INIT,
@ -711,7 +710,6 @@ volume_init (const SpaHandleFactory *factory,
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
this->node = volume_node; this->node = volume_node;
this->node.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.n_prop_info = PROP_ID_LAST;
this->props[1].props.prop_info = prop_info; this->props[1].props.prop_info = prop_info;
reset_volume_props (&this->props[1]); reset_volume_props (&this->props[1]);

View file

@ -141,10 +141,10 @@ spa_xv_sink_node_get_props (SpaNode *node,
{ {
SpaXvSink *this; SpaXvSink *this;
if (node == NULL || node->handle == NULL || props == NULL) if (node == NULL || props == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaXvSink *) node->handle; this = SPA_CONTAINER_OF (node, SpaXvSink, node);
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
*props = &this->props[0].props; *props = &this->props[0].props;
@ -160,10 +160,10 @@ spa_xv_sink_node_set_props (SpaNode *node,
SpaXvSinkProps *p; SpaXvSinkProps *p;
SpaResult res; SpaResult res;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaXvSink *) node->handle; this = SPA_CONTAINER_OF (node, SpaXvSink, node);
p = &this->props[1]; p = &this->props[1];
if (props == NULL) { if (props == NULL) {
@ -182,10 +182,10 @@ spa_xv_sink_node_send_command (SpaNode *node,
{ {
SpaXvSink *this; SpaXvSink *this;
if (node == NULL || node->handle == NULL || command == NULL) if (node == NULL || command == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaXvSink *) node->handle; this = SPA_CONTAINER_OF (node, SpaXvSink, node);
switch (command->type) { switch (command->type) {
case SPA_NODE_COMMAND_INVALID: case SPA_NODE_COMMAND_INVALID:
@ -218,10 +218,10 @@ spa_xv_sink_node_set_event_callback (SpaNode *node,
{ {
SpaXvSink *this; SpaXvSink *this;
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaXvSink *) node->handle; this = SPA_CONTAINER_OF (node, SpaXvSink, node);
this->event_cb = event; this->event_cb = event;
this->user_data = user_data; this->user_data = user_data;
@ -236,7 +236,7 @@ spa_xv_sink_node_get_n_ports (SpaNode *node,
unsigned int *n_output_ports, unsigned int *n_output_ports,
unsigned int *max_output_ports) unsigned int *max_output_ports)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_input_ports) if (n_input_ports)
@ -258,7 +258,7 @@ spa_xv_sink_node_get_port_ids (SpaNode *node,
unsigned int n_output_ports, unsigned int n_output_ports,
uint32_t *output_ids) uint32_t *output_ids)
{ {
if (node == NULL || node->handle == NULL) if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
if (n_output_ports > 0 && output_ids != NULL) if (n_output_ports > 0 && output_ids != NULL)
@ -295,10 +295,10 @@ spa_xv_sink_node_port_enum_formats (SpaNode *node,
SpaXvSink *this; SpaXvSink *this;
int index; int index;
if (node == NULL || node->handle == NULL || format == NULL || state == NULL) if (node == NULL || format == NULL || state == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaXvSink *) node->handle; this = SPA_CONTAINER_OF (node, SpaXvSink, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -332,10 +332,10 @@ spa_xv_sink_node_port_set_format (SpaNode *node,
SpaFormat *f, *tf; SpaFormat *f, *tf;
size_t fs; size_t fs;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaXvSink *) node->handle; this = SPA_CONTAINER_OF (node, SpaXvSink, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -377,10 +377,10 @@ spa_xv_sink_node_port_get_format (SpaNode *node,
{ {
SpaXvSink *this; SpaXvSink *this;
if (node == NULL || node->handle == NULL || format == NULL) if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaXvSink *) node->handle; this = SPA_CONTAINER_OF (node, SpaXvSink, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -401,10 +401,10 @@ spa_xv_sink_node_port_get_info (SpaNode *node,
{ {
SpaXvSink *this; SpaXvSink *this;
if (node == NULL || node->handle == NULL || info == NULL) if (node == NULL || info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaXvSink *) node->handle; this = SPA_CONTAINER_OF (node, SpaXvSink, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -462,10 +462,10 @@ spa_xv_sink_node_port_get_status (SpaNode *node,
{ {
SpaXvSink *this; SpaXvSink *this;
if (node == NULL || node->handle == NULL || status == NULL) if (node == NULL || status == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaXvSink *) node->handle; this = SPA_CONTAINER_OF (node, SpaXvSink, node);
if (!CHECK_PORT (this, direction, port_id)) if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT; return SPA_RESULT_INVALID_PORT;
@ -509,7 +509,6 @@ spa_xv_sink_node_port_push_event (SpaNode *node,
} }
static const SpaNode xvsink_node = { static const SpaNode xvsink_node = {
NULL,
sizeof (SpaNode), sizeof (SpaNode),
NULL, NULL,
SPA_NODE_STATE_INIT, SPA_NODE_STATE_INIT,
@ -593,7 +592,6 @@ xv_sink_init (const SpaHandleFactory *factory,
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
this->node = xvsink_node; this->node = xvsink_node;
this->node.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.n_prop_info = PROP_ID_LAST;
this->props[1].props.prop_info = prop_info; this->props[1].props.prop_info = prop_info;
reset_xv_sink_props (&this->props[1]); reset_xv_sink_props (&this->props[1]);