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,62 @@
/* 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_TYPE_INFO_H__
#define __SPA_TYPE_INFO_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#define SPA_TYPE_BASE "Spa:"
#define SPA_TYPE__Enum SPA_TYPE_BASE "Enum"
#define SPA_TYPE_ENUM_BASE SPA_TYPE__Enum ":"
#define SPA_TYPE__Flags SPA_TYPE_BASE "Flags"
#define SPA_TYPE_FLAGS_BASE SPA_TYPE__Flags ":"
#define SPA_TYPE__Pointer SPA_TYPE_BASE "Pointer"
#define SPA_TYPE_POINTER_BASE SPA_TYPE__Pointer ":"
#define SPA_TYPE__Interface SPA_TYPE_BASE "Interface"
#define SPA_TYPE_INTERFACE_BASE SPA_TYPE__Interface ":"
#define SPA_TYPE__Object SPA_TYPE_BASE "Object"
#define SPA_TYPE_OBJECT_BASE SPA_TYPE__Object ":"
static inline bool spa_type_is_a(const char *type, const char *parent)
{
return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0;
}
struct spa_type_info {
uint32_t id;
const char *name;
uint32_t type;
const struct spa_type_info *values;
};
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_TYPE_INFO_H__ */

View file

@ -26,24 +26,78 @@ extern "C" {
#include <spa/utils/defs.h>
#define SPA_TYPE_BASE "Spa:"
enum {
SPA_ID_UNASSIGNED = 0,
/* Interfaces */
SPA_ID_INTERFACE_Handle,
SPA_ID_INTERFACE_HandleFactory,
SPA_ID_INTERFACE_Log,
SPA_ID_INTERFACE_Loop,
SPA_ID_INTERFACE_LoopControl,
SPA_ID_INTERFACE_LoopUtils,
SPA_ID_INTERFACE_DataLoop,
SPA_ID_INTERFACE_MainLoop,
SPA_ID_INTERFACE_DBus,
SPA_ID_INTERFACE_Monitor,
SPA_ID_INTERFACE_Node,
#define SPA_TYPE__Enum SPA_TYPE_BASE "Enum"
#define SPA_TYPE_ENUM_BASE SPA_TYPE__Enum ":"
/* Events */
SPA_ID_EVENT_BASE = 0x10000,
SPA_ID_EVENT_MONITOR_Added,
SPA_ID_EVENT_MONITOR_Removed,
SPA_ID_EVENT_MONITOR_Changed,
SPA_ID_EVENT_NODE_Error,
SPA_ID_EVENT_NODE_Buffering,
SPA_ID_EVENT_NODE_RequestRefresh,
#define SPA_TYPE__Pointer SPA_TYPE_BASE "Pointer"
#define SPA_TYPE_POINTER_BASE SPA_TYPE__Pointer ":"
/* Commands */
SPA_ID_COMMAND_BASE = 0x20000,
SPA_ID_COMMAND_NODE_Suspend,
SPA_ID_COMMAND_NODE_Pause,
SPA_ID_COMMAND_NODE_Start,
SPA_ID_COMMAND_NODE_Enable,
SPA_ID_COMMAND_NODE_Disable,
SPA_ID_COMMAND_NODE_Flush,
SPA_ID_COMMAND_NODE_Drain,
SPA_ID_COMMAND_NODE_Marker,
#define SPA_TYPE__Interface SPA_TYPE_BASE "Interface"
#define SPA_TYPE_INTERFACE_BASE SPA_TYPE__Interface ":"
/* Objects */
SPA_ID_OBJECT_BASE = 0x30000,
SPA_ID_OBJECT_MonitorItem,
#define SPA_TYPE__Object SPA_TYPE_BASE "Object"
#define SPA_TYPE_OBJECT_BASE SPA_TYPE__Object ":"
SPA_ID_OBJECT_ParamList,
SPA_ID_OBJECT_PropInfo,
SPA_ID_OBJECT_Props,
SPA_ID_OBJECT_Format,
SPA_ID_OBJECT_ParamBuffers,
SPA_ID_OBJECT_ParamMeta,
SPA_ID_OBJECT_ParamIO,
/* IO */
SPA_ID_IO_BASE = 0x40000,
SPA_ID_IO_Buffers,
SPA_ID_IO_ControlRange,
SPA_ID_IO_Clock,
SPA_ID_IO_Prop,
SPA_ID_IO_Latency,
/* Params */
SPA_ID_PARAM_BASE = 0x50000,
SPA_ID_PARAM_List, /**< available params */
SPA_ID_PARAM_PropInfo, /**< property information */
SPA_ID_PARAM_Props, /**< properties */
SPA_ID_PARAM_EnumFormat, /**< available formats */
SPA_ID_PARAM_Format, /**< configured format */
SPA_ID_PARAM_Buffers, /**< buffer configurations */
SPA_ID_PARAM_Meta, /**< allowed metadata for buffers */
SPA_ID_PARAM_IO, /**< configurable IO areas */
/* vendor extensions */
SPA_ID_VENDOR_PipeWire = 0x01000000,
SPA_ID_VENDOR_Other = 0x7f000000,
};
static inline bool spa_type_is_a(const char *type, const char *parent)
{
return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0;
}
#ifdef __cplusplus
} /* extern "C" */