mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-12 13:30:15 -05:00
Make buffer data point to memory blocks
Make buffer data point to a registered memory block by its mem_id. Add some more helpers to allocate memfd backed memory. Allocate buffers in memfd so that we easily share them between client and server. Update pts and seq in v4l2 now that this change will actually be visible at the client.
This commit is contained in:
parent
98993c680b
commit
1169c2419b
19 changed files with 383 additions and 356 deletions
|
|
@ -98,39 +98,15 @@ typedef struct {
|
|||
size_t size;
|
||||
} SpaMeta;
|
||||
|
||||
/**
|
||||
* SpaDataType:
|
||||
* @SPA_DATA_TYPE_INVALID: invalid data type, is ignored
|
||||
* @SPA_DATA_TYPE_MEMPTR: data and size point to memory accessible by the
|
||||
* CPU.
|
||||
* @SPA_DATA_TYPE_FD: data points to an int file descriptor that can be
|
||||
* mmapped.
|
||||
* @SPA_DATA_TYPE_MEMID: data points to the id of the memory block to use
|
||||
* @SPA_DATA_TYPE_POINTER: data points to some other datastructure, the
|
||||
* type can be found in ptr_type
|
||||
*/
|
||||
typedef enum {
|
||||
SPA_DATA_TYPE_INVALID = 0,
|
||||
SPA_DATA_TYPE_MEMPTR,
|
||||
SPA_DATA_TYPE_FD,
|
||||
SPA_DATA_TYPE_MEMID,
|
||||
SPA_DATA_TYPE_POINTER,
|
||||
} SpaDataType;
|
||||
|
||||
/**
|
||||
* SpaData:
|
||||
* @id: user id
|
||||
* @type: the type of data
|
||||
* @ptr_type: more info about the type of @ptr
|
||||
* @ptr: pointer to data or fd
|
||||
* @offset: offset of data
|
||||
* @size: size of data
|
||||
* @stride: stride of data if applicable
|
||||
* @mem_id: the memory id to use
|
||||
* @offset: offset of memory
|
||||
* @size: size of memory
|
||||
* @stride: stride of memory if applicable
|
||||
*/
|
||||
typedef struct {
|
||||
SpaDataType type;
|
||||
const char *ptr_type;
|
||||
void *ptr;
|
||||
uint32_t mem_id;
|
||||
off_t offset;
|
||||
size_t size;
|
||||
size_t stride;
|
||||
|
|
@ -139,6 +115,8 @@ typedef struct {
|
|||
/**
|
||||
* SpaBuffer:
|
||||
* @id: buffer id
|
||||
* @mem_id: memory id of the buffer
|
||||
* @offset: offset into the memory
|
||||
* @size: total size of the buffer structure
|
||||
* @n_metas: number of metadata
|
||||
* @metas: offset of array of @n_metas metadata
|
||||
|
|
@ -147,6 +125,8 @@ typedef struct {
|
|||
*/
|
||||
struct _SpaBuffer {
|
||||
uint32_t id;
|
||||
uint32_t mem_id;
|
||||
off_t offset;
|
||||
size_t size;
|
||||
unsigned int n_metas;
|
||||
off_t metas;
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ typedef struct {
|
|||
uint32_t mem_id;
|
||||
uint32_t mem_type;
|
||||
uint32_t fd_index;
|
||||
uint64_t offset;
|
||||
uint32_t flags;
|
||||
uint64_t size;
|
||||
} SpaControlCmdAddMem;
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
uint32_t port_id;
|
||||
uint32_t buffer_id;
|
||||
int fd_index;
|
||||
uint32_t mem_id;
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
} SpaControlCmdAddBuffer;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ typedef enum {
|
|||
SPA_MEMORY_FLAG_WRITABLE = (1 << 1),
|
||||
} SpaMemoryFlags;
|
||||
|
||||
#define SPA_MEMORY_FLAG_READWRITE (SPA_MEMORY_FLAG_READABLE|SPA_MEMORY_FLAG_WRITABLE)
|
||||
|
||||
/**
|
||||
* SpaMemory:
|
||||
* @refcount: a refcount
|
||||
|
|
@ -65,15 +67,21 @@ struct _SpaMemory {
|
|||
size_t size;
|
||||
};
|
||||
|
||||
void spa_memory_init (void);
|
||||
|
||||
uint32_t spa_memory_pool_get (uint32_t type);
|
||||
uint32_t spa_memory_pool_new (void);
|
||||
void spa_memory_pool_free (uint32_t);
|
||||
|
||||
SpaMemory * spa_memory_alloc (uint32_t pool_id);
|
||||
SpaMemory * spa_memory_alloc_with_fd (uint32_t pool_id, void *data, size_t size);
|
||||
SpaResult spa_memory_free (uint32_t pool_id, uint32_t id);
|
||||
SpaMemory * spa_memory_import (uint32_t pool_id, uint32_t id);
|
||||
|
||||
SpaMemory * spa_memory_find (uint32_t pool_id, uint32_t id);
|
||||
|
||||
void * spa_memory_ensure_ptr (SpaMemory *mem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue