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

@ -26,46 +26,19 @@ extern "C" {
#include <spa/utils/defs.h>
#include <spa/buffer/meta.h>
#include <spa/support/type-map.h>
/** \page page_buffer Buffers
*
* Buffers describe the data and metadata that is exchanged between
* ports of a node.
*/
#define SPA_TYPE__Buffer SPA_TYPE_POINTER_BASE "Buffer"
#define SPA_TYPE_BUFFER_BASE SPA_TYPE__Buffer ":"
/** Buffers contain data of a certain type */
#define SPA_TYPE__Data SPA_TYPE_ENUM_BASE "DataType"
#define SPA_TYPE_DATA_BASE SPA_TYPE__Data ":"
/** The data type for a plain memory pointer. The data member points to
* the memory. */
#define SPA_TYPE_DATA__MemPtr SPA_TYPE_DATA_BASE "MemPtr"
/** base type for fd based memory */
#define SPA_TYPE_DATA__Fd SPA_TYPE_DATA_BASE "Fd"
#define SPA_TYPE_DATA_FD_BASE SPA_TYPE_DATA__Fd ":"
#define SPA_TYPE_DATA_FD__MemFd SPA_TYPE_DATA_FD_BASE "MemFd"
#define SPA_TYPE_DATA_FD__DmaBuf SPA_TYPE_DATA_FD_BASE "DmaBuf"
struct spa_type_data {
uint32_t MemPtr; /**< system memory */
uint32_t MemFd; /**< memory accesible with an fd */
uint32_t DmaBuf; /**< dmabuf fd */
enum spa_data_type {
SPA_DATA_MemPtr,
SPA_DATA_MemFd,
SPA_DATA_DmaBuf,
};
static inline void spa_type_data_map(struct spa_type_map *map, struct spa_type_data *type)
{
if (type->MemPtr == 0) {
type->MemPtr = spa_type_map_get_id(map, SPA_TYPE_DATA__MemPtr);
type->MemFd = spa_type_map_get_id(map, SPA_TYPE_DATA_FD__MemFd);
type->DmaBuf = spa_type_map_get_id(map, SPA_TYPE_DATA_FD__DmaBuf);
}
}
/** Chunk of memory */
struct spa_chunk {
uint32_t offset; /**< offset of valid data. Should be taken
@ -79,7 +52,7 @@ struct spa_chunk {
/** Data for a buffer */
struct spa_data {
uint32_t type; /**< memory type */
uint32_t type; /**< memory type, one of enum spa_data_type */
uint32_t flags; /**< data flags */
int fd; /**< optional fd for data */
uint32_t mapoffset; /**< offset to map fd at */