Remove dynamic types

Do not use dynamic types anymore. The reason is that it's difficult:

- to maintain a shared type database over a network.
- the extra overhead when translating between processes and for
  maintaining the translation tables.
- race conditions in translating in RT-threads, this is a problem
  because we want to make event streams.

We now have simple enums with types and extension points for all
types. This is also nicer to use in general.
We don't need the mapper anymore or pass strings around as types.
There is a parallel type info system to get more info about ids and
enums and their hierarchy. It can also be used for debugging.
This commit is contained in:
Wim Taymans 2018-08-23 17:47:57 +02:00
parent e6977fa178
commit fca3e1d85d
162 changed files with 5200 additions and 7461 deletions

View file

@ -0,0 +1,55 @@
/* Simple Plugin API
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_COMMAND_NODE_TYPES_H__
#define __SPA_COMMAND_NODE_TYPES_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/type-info.h>
#include <spa/node/command.h>
#define SPA_TYPE_COMMAND__Node SPA_TYPE_COMMAND_BASE "Node"
#define SPA_TYPE_COMMAND_NODE_BASE SPA_TYPE_COMMAND__Node ":"
/** Suspend a node. This will release all resources of the node */
#define SPA_TYPE_COMMAND_NODE__Suspend SPA_TYPE_COMMAND_NODE_BASE "Suspend"
/** Pause processing of a node */
#define SPA_TYPE_COMMAND_NODE__Pause SPA_TYPE_COMMAND_NODE_BASE "Pause"
/** Start processing of a node */
#define SPA_TYPE_COMMAND_NODE__Start SPA_TYPE_COMMAND_NODE_BASE "Start"
/** Enable ports of a node. When sent to a port, enables just that port. Enabled
* ports on a Started node begin streaming immediately */
#define SPA_TYPE_COMMAND_NODE__Enable SPA_TYPE_COMMAND_NODE_BASE "Enable"
/** Disable ports of a node. When sent to a port, disables just that port. */
#define SPA_TYPE_COMMAND_NODE__Disable SPA_TYPE_COMMAND_NODE_BASE "Disable"
/** Flush all data from the node or port */
#define SPA_TYPE_COMMAND_NODE__Flush SPA_TYPE_COMMAND_NODE_BASE "Flush"
/** Drain all data from the node or port */
#define SPA_TYPE_COMMAND_NODE__Drain SPA_TYPE_COMMAND_NODE_BASE "Drain"
/** Set a marker on a node or port */
#define SPA_TYPE_COMMAND_NODE__Marker SPA_TYPE_COMMAND_NODE_BASE "Marker"
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _SPA_COMMAND_NODE_TYPES_H__ */

View file

@ -24,56 +24,8 @@
extern "C" {
#endif
#include <spa/support/type-map.h>
#include <spa/pod/command.h>
#define SPA_TYPE_COMMAND__Node SPA_TYPE_COMMAND_BASE "Node"
#define SPA_TYPE_COMMAND_NODE_BASE SPA_TYPE_COMMAND__Node ":"
/** Suspend a node. This will release all resources of the node */
#define SPA_TYPE_COMMAND_NODE__Suspend SPA_TYPE_COMMAND_NODE_BASE "Suspend"
/** Pause processing of a node */
#define SPA_TYPE_COMMAND_NODE__Pause SPA_TYPE_COMMAND_NODE_BASE "Pause"
/** Start processing of a node */
#define SPA_TYPE_COMMAND_NODE__Start SPA_TYPE_COMMAND_NODE_BASE "Start"
/** Enable ports of a node. When sent to a port, enables just that port. Enabled
* ports on a Started node begin streaming immediately */
#define SPA_TYPE_COMMAND_NODE__Enable SPA_TYPE_COMMAND_NODE_BASE "Enable"
/** Disable ports of a node. When sent to a port, disables just that port. */
#define SPA_TYPE_COMMAND_NODE__Disable SPA_TYPE_COMMAND_NODE_BASE "Disable"
/** Flush all data from the node or port */
#define SPA_TYPE_COMMAND_NODE__Flush SPA_TYPE_COMMAND_NODE_BASE "Flush"
/** Drain all data from the node or port */
#define SPA_TYPE_COMMAND_NODE__Drain SPA_TYPE_COMMAND_NODE_BASE "Drain"
/** Set a marker on a node or port */
#define SPA_TYPE_COMMAND_NODE__Marker SPA_TYPE_COMMAND_NODE_BASE "Marker"
struct spa_type_command_node {
uint32_t Suspend;
uint32_t Pause;
uint32_t Start;
uint32_t Enable;
uint32_t Disable;
uint32_t Flush;
uint32_t Drain;
uint32_t Marker;
};
static inline void
spa_type_command_node_map(struct spa_type_map *map, struct spa_type_command_node *type)
{
if (type->Suspend == 0) {
type->Suspend = spa_type_map_get_id(map, SPA_TYPE_COMMAND_NODE__Suspend);
type->Pause = spa_type_map_get_id(map, SPA_TYPE_COMMAND_NODE__Pause);
type->Start = spa_type_map_get_id(map, SPA_TYPE_COMMAND_NODE__Start);
type->Enable = spa_type_map_get_id(map, SPA_TYPE_COMMAND_NODE__Enable);
type->Disable = spa_type_map_get_id(map, SPA_TYPE_COMMAND_NODE__Disable);
type->Flush = spa_type_map_get_id(map, SPA_TYPE_COMMAND_NODE__Flush);
type->Drain = spa_type_map_get_id(map, SPA_TYPE_COMMAND_NODE__Drain);
type->Marker = spa_type_map_get_id(map, SPA_TYPE_COMMAND_NODE__Marker);
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View file

@ -0,0 +1,41 @@
/* Simple Plugin API
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_EVENT_NODE_TYPES_H__
#define __SPA_EVENT_NODE_TYPES_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/type-info.h>
#include <spa/node/event.h>
#define SPA_TYPE_EVENT__Node SPA_TYPE_EVENT_BASE "Node"
#define SPA_TYPE_EVENT_NODE_BASE SPA_TYPE_EVENT__Node ":"
#define SPA_TYPE_EVENT_NODE__Error SPA_TYPE_EVENT_NODE_BASE "Error"
#define SPA_TYPE_EVENT_NODE__Buffering SPA_TYPE_EVENT_NODE_BASE "Buffering"
#define SPA_TYPE_EVENT_NODE__RequestRefresh SPA_TYPE_EVENT_NODE_BASE "RequestRefresh"
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_EVENT_NODE_TYPES_H__ */

View file

@ -26,32 +26,8 @@ extern "C" {
#include <spa/utils/defs.h>
#include <spa/pod/event.h>
#include <spa/support/type-map.h>
#include <spa/node/node.h>
#define SPA_TYPE_EVENT__Node SPA_TYPE_EVENT_BASE "Node"
#define SPA_TYPE_EVENT_NODE_BASE SPA_TYPE_EVENT__Node ":"
#define SPA_TYPE_EVENT_NODE__Error SPA_TYPE_EVENT_NODE_BASE "Error"
#define SPA_TYPE_EVENT_NODE__Buffering SPA_TYPE_EVENT_NODE_BASE "Buffering"
#define SPA_TYPE_EVENT_NODE__RequestRefresh SPA_TYPE_EVENT_NODE_BASE "RequestRefresh"
struct spa_type_event_node {
uint32_t Error;
uint32_t Buffering;
uint32_t RequestRefresh;
};
static inline void
spa_type_event_node_map(struct spa_type_map *map, struct spa_type_event_node *type)
{
if (type->Error == 0) {
type->Error = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__Error);
type->Buffering = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__Buffering);
type->RequestRefresh = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__RequestRefresh);
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View file

@ -0,0 +1,51 @@
/* Simple Plugin API
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_IO_TYPES_H__
#define __SPA_IO_TYPES_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/type-info.h>
#include <spa/node/io.h>
/** Base for IO structures to interface with node ports */
#define SPA_TYPE__IO SPA_TYPE_POINTER_BASE "IO"
#define SPA_TYPE_IO_BASE SPA_TYPE__IO ":"
/** Base for control structures */
#define SPA_TYPE_IO__Control SPA_TYPE_IO_BASE "Control"
#define SPA_TYPE_IO_CONTROL_BASE SPA_TYPE_IO__Control ":"
/** An io area to exchange buffers with a port */
#define SPA_TYPE_IO__Buffers SPA_TYPE_IO_BASE "Buffers"
/** IO area with clock information */
#define SPA_TYPE_IO__Clock SPA_TYPE_IO_BASE "Clock"
/** IO area with latency information */
#define SPA_TYPE_IO__Latency SPA_TYPE_IO_BASE "Latency"
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_IO_TYPES_H__ */

View file

@ -24,34 +24,14 @@
extern "C" {
#endif
#include <spa/support/type-map.h>
/** Base for IO structures to interface with node ports */
#define SPA_TYPE__IO SPA_TYPE_POINTER_BASE "IO"
#define SPA_TYPE_IO_BASE SPA_TYPE__IO ":"
/** Base for control structures */
#define SPA_TYPE_IO__Control SPA_TYPE_IO_BASE "Control"
#define SPA_TYPE_IO_CONTROL_BASE SPA_TYPE_IO__Control ":"
/** Base for controlable properties */
#define SPA_TYPE_IO__Prop SPA_TYPE_IO_BASE "Prop"
#define SPA_TYPE_IO_PROP_BASE SPA_TYPE_IO__Prop ":"
/** An io area to exchange buffers with a port */
#define SPA_TYPE_IO__Buffers SPA_TYPE_IO_BASE "Buffers"
/** IO area with clock information */
#define SPA_TYPE_IO__Clock SPA_TYPE_IO_BASE "Clock"
/** IO area with latency information */
#define SPA_TYPE_IO__Latency SPA_TYPE_IO_BASE "Latency"
#include <spa/utils/defs.h>
/** Buffers IO area
*
* IO information for a port on a node. This is allocated
* by the host and configured on all ports for which IO is requested.
*/
struct spa_io_buffers {
#define SPA_STATUS_OK 0
#define SPA_STATUS_NEED_BUFFER (1<<0)
@ -65,9 +45,6 @@ struct spa_io_buffers {
#define SPA_IO_BUFFERS_INIT (struct spa_io_buffers) { SPA_STATUS_OK, SPA_ID_INVALID, }
/** Information about requested range */
#define SPA_TYPE_IO_CONTROL__Range SPA_TYPE_IO_CONTROL_BASE "Range"
/** A range, suitable for input ports that can suggest a range to output ports */
struct spa_io_control_range {
uint64_t offset; /**< offset in range */
@ -92,25 +69,6 @@ struct spa_io_latency {
uint64_t max; /**< max latency */
};
struct spa_type_io {
uint32_t Buffers;
uint32_t ControlRange;
uint32_t Prop;
uint32_t Clock;
uint32_t Latency;
};
static inline void spa_type_io_map(struct spa_type_map *map, struct spa_type_io *type)
{
if (type->Buffers == 0) {
type->Buffers = spa_type_map_get_id(map, SPA_TYPE_IO__Buffers);
type->ControlRange = spa_type_map_get_id(map, SPA_TYPE_IO_CONTROL__Range);
type->Prop = spa_type_map_get_id(map, SPA_TYPE_IO__Prop);
type->Clock = spa_type_map_get_id(map, SPA_TYPE_IO__Clock);
type->Latency = spa_type_map_get_id(map, SPA_TYPE_IO__Latency);
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View file

@ -0,0 +1,42 @@
/* Simple Plugin API
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_NODE_TYPES_H__
#define __SPA_NODE_TYPES_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/type-info.h>
#include <spa/node/node.h>
#define SPA_TYPE__Node SPA_TYPE_INTERFACE_BASE "Node"
#define SPA_TYPE_NODE_BASE SPA_TYPE__Node ":"
static const struct spa_type_info spa_type_node[] = {
{ SPA_ID_INTERFACE_Node, SPA_TYPE__Node, SPA_POD_TYPE_ID, },
{ 0, NULL, },
};
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_NODE_TYPES_H__ */

View file

@ -24,12 +24,10 @@
extern "C" {
#endif
#define SPA_TYPE__Node SPA_TYPE_INTERFACE_BASE "Node"
#define SPA_TYPE_NODE_BASE SPA_TYPE__Node ":"
struct spa_node;
#include <spa/utils/defs.h>
#include <spa/utils/type.h>
#include <spa/support/plugin.h>