implement set_format

Serialize the formats
Use SpaMemoryRef where we can
Add more debug
This commit is contained in:
Wim Taymans 2016-08-04 17:33:49 +02:00
parent 98679cbd53
commit 8f9222bf9e
19 changed files with 611 additions and 399 deletions

View file

@ -28,6 +28,7 @@ typedef struct _SpaBuffer SpaBuffer;
typedef struct _SpaBufferGroup SpaBufferGroup;
#include <spa/defs.h>
#include <spa/memory.h>
/**
* SpaMetaType:
@ -89,7 +90,7 @@ typedef struct {
/**
* SpaMeta:
* @type: metadata type
* @offset: offset of metadata
* @offset: offset of metadata in the buffer structure
* @size: size of metadata
*/
typedef struct {
@ -100,13 +101,13 @@ typedef struct {
/**
* SpaData:
* @mem_id: the memory id to use
* @offset: offset of memory
* @mem: reference to the memory to use
* @offset: ofset in memory
* @size: size of memory
* @stride: stride of memory if applicable
*/
typedef struct {
uint32_t mem_id;
SpaMemoryRef mem;
off_t offset;
size_t size;
size_t stride;
@ -115,9 +116,9 @@ 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
* @mem: reference to the memory for this buffer
* @offset: offset inside memory
* @size: of of memory
* @n_metas: number of metadata
* @metas: offset of array of @n_metas metadata
* @n_datas: number of data pointers
@ -125,7 +126,7 @@ typedef struct {
*/
struct _SpaBuffer {
uint32_t id;
uint32_t mem_id;
SpaMemoryRef mem;
off_t offset;
size_t size;
unsigned int n_metas;

View file

@ -144,8 +144,8 @@ typedef struct {
/* SPA_CONTROL_CMD_SET_FORMAT */
typedef struct {
uint32_t port_id;
const SpaFormat *format;
uint32_t port_id;
SpaFormat *format;
} SpaControlCmdSetFormat;
/* SPA_CONTROL_CMD_SET_PROPERTY */
@ -161,27 +161,27 @@ typedef struct {
/* SPA_CONTROL_CMD_ADD_MEM */
typedef struct {
uint32_t port_id;
uint32_t mem_id;
uint32_t mem_type;
uint32_t fd_index;
uint32_t flags;
uint64_t size;
uint32_t port_id;
SpaMemoryRef mem;
uint32_t mem_type;
uint32_t fd_index;
uint32_t flags;
uint64_t size;
} SpaControlCmdAddMem;
/* SPA_CONTROL_CMD_REMOVE_MEM */
typedef struct {
uint32_t port_id;
uint32_t mem_id;
SpaMemoryRef mem;
} SpaControlCmdRemoveMem;
/* SPA_CONTROL_CMD_ADD_BUFFER */
typedef struct {
uint32_t port_id;
uint32_t buffer_id;
uint32_t mem_id;
uint64_t offset;
uint64_t size;
uint32_t port_id;
uint32_t buffer_id;
SpaMemoryRef mem;
off_t offset;
size_t size;
} SpaControlCmdAddBuffer;
/* SPA_CONTROL_CMD_REMOVE_BUFFER */
@ -207,8 +207,6 @@ typedef struct {
} SpaControlCmdReuseBuffer;
struct _SpaControlIter {
/*< private >*/
size_t x[16];

View file

@ -27,10 +27,14 @@ extern "C" {
#include <spa/defs.h>
#include <spa/port.h>
#include <spa/buffer.h>
#include <spa/props.h>
#include <spa/format.h>
SpaResult spa_debug_port_info (const SpaPortInfo *info);
SpaResult spa_debug_buffer (const SpaBuffer *buffer);
SpaResult spa_debug_dump_mem (void *data, size_t size);
SpaResult spa_debug_props (const SpaProps *props, bool print_ranges);
SpaResult spa_debug_format (const SpaFormat *format);
SpaResult spa_debug_dump_mem (const void *data, size_t size);
#ifdef __cplusplus
} /* extern "C" */

View file

@ -73,6 +73,7 @@ typedef void (*SpaNotify) (void *data);
#define SPA_MAX(a,b) ((a)>(b) ? (a) : (b))
#define SPA_MEMBER(b,o,t) ((t*)((uint8_t*)(b) + (o)))
#define SPA_PTRDIFF(p1,p2) ((uint8_t*)(p1) - (uint8_t*)(p2))
#define SPA_PTR_TO_INT(p) ((int) ((intptr_t) (p)))
#define SPA_INT_TO_PTR(u) ((void*) ((intptr_t) (u)))

View file

@ -25,6 +25,7 @@ extern "C" {
#endif
typedef struct _SpaMemory SpaMemory;
typedef struct _SpaMemoryRef SpaMemoryRef;
typedef struct _SpaMemoryPool SpaMemoryPool;
#include <spa/defs.h>
@ -43,6 +44,16 @@ typedef enum {
#define SPA_MEMORY_FLAG_READWRITE (SPA_MEMORY_FLAG_READABLE|SPA_MEMORY_FLAG_WRITABLE)
/**
* SpaMemoryRef:
* @pool_id: the pool id
* @id: mem_id
*/
struct _SpaMemoryRef {
uint32_t pool_id;
uint32_t id;
};
/**
* SpaMemory:
* @refcount: a refcount
@ -58,8 +69,7 @@ typedef enum {
struct _SpaMemory {
int refcount;
SpaNotify notify;
uint32_t pool_id;
uint32_t id;
SpaMemoryRef mem;
SpaMemoryFlags flags;
const char *type;
int fd;
@ -75,10 +85,10 @@ 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);
SpaResult spa_memory_free (SpaMemoryRef *ref);
SpaMemory * spa_memory_import (SpaMemoryRef *ref);
SpaMemory * spa_memory_find (SpaMemoryRef *ref);
void * spa_memory_ensure_ptr (SpaMemory *mem);