data: clean up fd and data management

Do not send the offset and size in the add_mem call, just send the
fd and the flags. The area that we need to map from this to find the
meta, chunk and data are sent in a separate call. This should make
it possible to truncate the memory to a larger size to dynamically
allocate more shared memory for a client.
Remove the Id data type, it's not needed.
Don't automatically map memory in remote.c
Pass the original memory type from server to client.
Handle DmaBuf mem in video-play now that the server passed it on.
This commit is contained in:
Wim Taymans 2017-12-01 09:34:53 +01:00
parent 541553be1c
commit 08814bd808
7 changed files with 100 additions and 119 deletions

View file

@ -32,33 +32,37 @@ extern "C" {
*
* 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"
#define SPA_TYPE_DATA__MemFd SPA_TYPE_DATA_BASE "MemFd"
#define SPA_TYPE_DATA__DmaBuf SPA_TYPE_DATA_BASE "DmaBuf"
#define SPA_TYPE_DATA__Id SPA_TYPE_DATA_BASE "Id"
/** 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;
uint32_t MemFd;
uint32_t DmaBuf;
uint32_t Id;
uint32_t MemPtr; /**< system memory */
uint32_t MemFd; /**< memory accesible with an fd */
uint32_t DmaBuf; /**< dmabuf fd */
};
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__MemFd);
type->DmaBuf = spa_type_map_get_id(map, SPA_TYPE_DATA__DmaBuf);
type->Id = spa_type_map_get_id(map, SPA_TYPE_DATA__Id);
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);
}
}