mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
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:
parent
e6977fa178
commit
fca3e1d85d
162 changed files with 5200 additions and 7461 deletions
52
spa/include/spa/buffer/buffer-types.h
Normal file
52
spa/include/spa/buffer/buffer-types.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/* 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_BUFFER_TYPES_H__
|
||||
#define __SPA_BUFFER_TYPES_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/buffer/buffer.h>
|
||||
#include <spa/utils/type-info.h>
|
||||
|
||||
#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 "Data"
|
||||
#define SPA_TYPE_DATA_BASE SPA_TYPE__Data ":"
|
||||
|
||||
/** 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 ":"
|
||||
|
||||
static const struct spa_type_info spa_type_data_type[] = {
|
||||
{ SPA_DATA_MemPtr, SPA_TYPE_DATA_BASE "MemPtr", SPA_POD_TYPE_INT, },
|
||||
{ SPA_DATA_MemFd, SPA_TYPE_DATA_FD_BASE "MemFd", SPA_POD_TYPE_INT, },
|
||||
{ SPA_DATA_DmaBuf, SPA_TYPE_DATA_FD_BASE "DmaBuf", SPA_POD_TYPE_INT, },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_BUFFER_TYPES_H__ */
|
||||
|
|
@ -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 */
|
||||
|
|
|
|||
50
spa/include/spa/buffer/meta-types.h
Normal file
50
spa/include/spa/buffer/meta-types.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2017 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_META_H__
|
||||
#define __SPA_META_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/type-info.h>
|
||||
|
||||
#define SPA_TYPE__Meta SPA_TYPE_POINTER_BASE "Meta"
|
||||
#define SPA_TYPE_META_BASE SPA_TYPE__Meta ":"
|
||||
|
||||
#define SPA_TYPE_META__Region SPA_TYPE_META_BASE "Region"
|
||||
#define SPA_TYPE_META_REGION_BASE SPA_TYPE_META__Region ":"
|
||||
|
||||
#define SPA_TYPE_META__RegionArray SPA_TYPE_META_BASE "RegionArray"
|
||||
#define SPA_TYPE_META_REGION_ARRAY_BASE SPA_TYPE_META__RegionArray ":"
|
||||
|
||||
static const struct spa_type_info spa_type_meta_type[] = {
|
||||
{ SPA_META_Header, SPA_TYPE_META_BASE "Header", SPA_POD_TYPE_INT, },
|
||||
{ SPA_META_VideoCrop, SPA_TYPE_META_REGION_BASE "VideoCrop", SPA_POD_TYPE_INT, },
|
||||
{ SPA_META_VideoDamage, SPA_TYPE_META_REGION_ARRAY_BASE "VideoDamage", SPA_POD_TYPE_INT, },
|
||||
{ 0, NULL, },
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_META_H__ */
|
||||
|
|
@ -25,24 +25,16 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/support/type-map.h>
|
||||
|
||||
/** \page page_meta Metadata
|
||||
*
|
||||
* Metadata contains extra information on a buffer.
|
||||
*/
|
||||
#define SPA_TYPE__Meta SPA_TYPE_POINTER_BASE "Meta"
|
||||
#define SPA_TYPE_META_BASE SPA_TYPE__Meta ":"
|
||||
|
||||
#define SPA_TYPE_META__Header SPA_TYPE_META_BASE "Header"
|
||||
#define SPA_TYPE_META__Region SPA_TYPE_META_BASE "Region"
|
||||
#define SPA_TYPE_META_REGION_BASE SPA_TYPE_META__Region ":"
|
||||
|
||||
#define SPA_TYPE_META__RegionArray SPA_TYPE_META_BASE "RegionArray"
|
||||
#define SPA_TYPE_META_REGION_ARRAY_BASE SPA_TYPE_META__RegionArray ":"
|
||||
|
||||
#define SPA_TYPE_META__VideoCrop SPA_TYPE_META_REGION_BASE "VideoCrop"
|
||||
#define SPA_TYPE_META__VideoDamage SPA_TYPE_META_REGION_ARRAY_BASE "VideoDamage"
|
||||
enum spa_meta_type {
|
||||
SPA_META_Header,
|
||||
SPA_META_VideoCrop,
|
||||
SPA_META_VideoDamage,
|
||||
};
|
||||
|
||||
/**
|
||||
* A metadata element.
|
||||
|
|
@ -52,7 +44,7 @@ extern "C" {
|
|||
* itself.
|
||||
*/
|
||||
struct spa_meta {
|
||||
uint32_t type; /**< metadata type */
|
||||
uint32_t type; /**< metadata type, one of enum spa_meta_type */
|
||||
void *data; /**< pointer to metadata */
|
||||
uint32_t size; /**< size of metadata */
|
||||
};
|
||||
|
|
@ -91,21 +83,6 @@ struct spa_meta_region {
|
|||
spa_meta_check(pos, meta); \
|
||||
(pos)++)
|
||||
|
||||
struct spa_type_meta {
|
||||
uint32_t Header;
|
||||
uint32_t VideoCrop;
|
||||
uint32_t VideoDamage;
|
||||
};
|
||||
|
||||
static inline void spa_type_meta_map(struct spa_type_map *map, struct spa_type_meta *type)
|
||||
{
|
||||
if (type->Header == 0) {
|
||||
type->Header = spa_type_map_get_id(map, SPA_TYPE_META__Header);
|
||||
type->VideoCrop = spa_type_map_get_id(map, SPA_TYPE_META__VideoCrop);
|
||||
type->VideoDamage = spa_type_map_get_id(map, SPA_TYPE_META__VideoDamage);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue