Make done event on node

Replace the AsyncDone event with an explicit done callback in the node
to signal completion of an async operation.
Pass read and write fd together with the transport
This commit is contained in:
Wim Taymans 2017-06-09 17:24:18 +02:00
parent 0af8377d10
commit 34450ed7ed
24 changed files with 268 additions and 254 deletions

View file

@ -28,6 +28,12 @@ extern "C" {
#include <spa/meta.h>
#include <spa/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 ":"
@ -56,54 +62,34 @@ static inline void spa_type_data_map(struct spa_type_map *map, struct spa_type_d
}
}
/**
* spa_chunk:
* @offset: offset of valid data
* @size: size of valid data
* @stride: stride of data if applicable
*/
/** Chunk of memory */
struct spa_chunk {
uint32_t offset;
uint32_t size;
int32_t stride;
uint32_t offset; /**< offset of valid data */
uint32_t size; /**< size of valid data */
int32_t stride; /**< stride of valid data */
};
/**
* spa_data:
* @type: memory type
* @flags: memory flags
* @fd: file descriptor
* @mapoffset: start offset when mapping @fd
* @maxsize: maximum size of the memory
* @data: pointer to memory
* @chunk: pointer to chunk with valid offset
*/
/** Data for a buffer */
struct spa_data {
uint32_t type;
uint32_t flags;
int fd;
uint32_t mapoffset;
uint32_t maxsize;
void *data;
struct spa_chunk *chunk;
uint32_t type; /**< memory type */
uint32_t flags; /**< data flags */
int fd; /**< optional fd for data */
uint32_t mapoffset; /**< offset to map fd at */
uint32_t maxsize; /**< max size of data */
void *data; /**< optional data pointer */
struct spa_chunk *chunk; /**< valid chunk of memory */
};
/**
* spa_buffer:
* @id: buffer id
* @n_metas: number of metadata
* @metas: offset of array of @n_metas metadata
* @n_datas: number of data pointers
* @datas: offset of array of @n_datas data pointers
*/
/** A Buffer */
struct spa_buffer {
uint32_t id;
uint32_t n_metas;
struct spa_meta *metas;
uint32_t n_datas;
struct spa_data *datas;
uint32_t id; /**< the id of this buffer */
uint32_t n_metas; /**< number of metadata elements */
struct spa_meta *metas; /**< array of metadata */
uint32_t n_datas; /**< number of data members */
struct spa_data *datas; /**< array of data members */
};
/** Find metadata in a buffer */
static inline void *spa_buffer_find_meta(struct spa_buffer *b, uint32_t type)
{
uint32_t i;

View file

@ -32,14 +32,12 @@ extern "C" {
#define SPA_TYPE_EVENT__Node SPA_TYPE_EVENT_BASE "Node"
#define SPA_TYPE_EVENT_NODE_BASE SPA_TYPE_EVENT__Node ":"
#define SPA_TYPE_EVENT_NODE__AsyncComplete SPA_TYPE_EVENT_NODE_BASE "AsyncComplete"
#define SPA_TYPE_EVENT_NODE__Error SPA_TYPE_EVENT_NODE_BASE "Error"
#define SPA_TYPE_EVENT_NODE__Buffering SPA_TYPE_EVENT_NODE_BASE "Buffering"
#define SPA_TYPE_EVENT_NODE__RequestRefresh SPA_TYPE_EVENT_NODE_BASE "RequestRefresh"
#define SPA_TYPE_EVENT_NODE__RequestClockUpdate SPA_TYPE_EVENT_NODE_BASE "RequestClockUpdate"
struct spa_type_event_node {
uint32_t AsyncComplete;
uint32_t Error;
uint32_t Buffering;
uint32_t RequestRefresh;
@ -49,8 +47,7 @@ struct spa_type_event_node {
static inline void
spa_type_event_node_map(struct spa_type_map *map, struct spa_type_event_node *type)
{
if (type->AsyncComplete == 0) {
type->AsyncComplete = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__AsyncComplete);
if (type->Error == 0) {
type->Error = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__Error);
type->Buffering = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__Buffering);
type->RequestRefresh = spa_type_map_get_id(map, SPA_TYPE_EVENT_NODE__RequestRefresh);
@ -58,23 +55,6 @@ spa_type_event_node_map(struct spa_type_map *map, struct spa_type_event_node *ty
}
}
struct spa_event_node_async_complete_body {
struct spa_pod_object_body body;
struct spa_pod_int seq SPA_ALIGNED(8);
struct spa_pod_int res SPA_ALIGNED(8);
};
struct spa_event_node_async_complete {
struct spa_pod pod;
struct spa_event_node_async_complete_body body;
};
#define SPA_EVENT_NODE_ASYNC_COMPLETE_INIT(type,seq,res) \
SPA_EVENT_INIT_COMPLEX(struct spa_event_node_async_complete, \
sizeof(struct spa_event_node_async_complete_body), type, \
SPA_POD_INT_INIT(seq), \
SPA_POD_INT_INIT(res))
struct spa_event_node_request_clock_update_body {
struct spa_pod_object_body body;
#define SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_TIME (1 << 0)

View file

@ -81,6 +81,7 @@ struct spa_loop {
void (*remove_source) (struct spa_source *source);
/** invoke a function in the context of this loop */
int (*invoke) (struct spa_loop *loop,
spa_invoke_func_t func,
uint32_t seq,

View file

@ -28,6 +28,10 @@ extern "C" {
#include <spa/ringbuffer.h>
#include <spa/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 ":"
@ -56,76 +60,51 @@ static inline void spa_type_meta_map(struct spa_type_map *map, struct spa_type_m
}
}
/**
* spa_meta_header:
* @flags: extra flags
* @seq: sequence number. This monotonically increments and with the rate,
* it can be used to derive a media time.
* @pts: The MONOTONIC time for @seq.
* @dts_offset: offset relative to @pts to start decoding this buffer.
*/
/** Describes essential buffer header metadata */
struct spa_meta_header {
#define SPA_META_HEADER_FLAG_DISCONT (1 << 0) /* data is not continous with previous buffer */
#define SPA_META_HEADER_FLAG_CORRUPTED (1 << 1) /* data might be corrupted */
#define SPA_META_HEADER_FLAG_MARKER (1 << 2) /* media specific marker */
#define SPA_META_HEADER_FLAG_HEADER (1 << 3) /* data contains a codec specific header */
#define SPA_META_HEADER_FLAG_GAP (1 << 4) /* data contains media neutral data */
#define SPA_META_HEADER_FLAG_DELTA_UNIT (1 << 5) /* cannot be decoded independently */
uint32_t flags;
uint32_t seq;
int64_t pts;
int64_t dts_offset;
#define SPA_META_HEADER_FLAG_DISCONT (1 << 0) /**< data is not continous with previous buffer */
#define SPA_META_HEADER_FLAG_CORRUPTED (1 << 1) /**< data might be corrupted */
#define SPA_META_HEADER_FLAG_MARKER (1 << 2) /**< media specific marker */
#define SPA_META_HEADER_FLAG_HEADER (1 << 3) /**< data contains a codec specific header */
#define SPA_META_HEADER_FLAG_GAP (1 << 4) /**< data contains media neutral data */
#define SPA_META_HEADER_FLAG_DELTA_UNIT (1 << 5) /**< cannot be decoded independently */
uint32_t flags; /**< flags */
uint32_t seq; /**< sequence number, increments with a
* media specific frequency */
int64_t pts; /**< presentation timestamp */
int64_t dts_offset; /**< decoding timestamp and a difference with pts */
};
/** Pointer metadata */
struct spa_meta_pointer {
uint32_t type;
void *ptr;
uint32_t type; /**< the pointer type */
void *ptr; /**< the pointer */
};
/**
* spa_meta_video_crop:
* @x:
* @y:
* @width:
* @height
*/
/** Video cropping metadata */
struct spa_meta_video_crop {
int32_t x, y;
int32_t width, height;
int32_t x, y; /**< x and y offsets */
int32_t width, height; /**< width and height */
};
/**
* spa_meta_ringbuffer:
* @ringbuffer:
*/
/** Ringbuffer metadata */
struct spa_meta_ringbuffer {
struct spa_ringbuffer ringbuffer;
struct spa_ringbuffer ringbuffer; /**< the ringbuffer */
};
/**
* spa_meta_shared:
* @flags: flags
* @fd: the fd of the memory
* @offset: start offset of memory
* @size: size of the memory
*/
/** Describes the shared memory of a buffer is stored */
struct spa_meta_shared {
int32_t flags;
int fd;
int32_t offset;
uint32_t size;
int32_t flags; /**< flags */
int fd; /**< file descriptor of memory */
int32_t offset; /**< offset in memory */
uint32_t size; /**< size of memory */
};
/**
* spa_meta:
* @type: metadata type
* @data: pointer to metadata
* @size: size of metadata
*/
/** A metadata element */
struct spa_meta {
uint32_t type;
void *data;
uint32_t size;
uint32_t type; /**< metadata type */
void *data; /**< pointer to metadata */
uint32_t size; /**< size of metadata */
};
#ifdef __cplusplus

View file

@ -82,6 +82,7 @@ struct spa_port_info {
struct spa_node_callbacks {
void (*done) (struct spa_node *node, int seq, int res, void *user_data);
/**
* struct spa_node_callbacks::event:
* @node: a #struct spa_node
@ -133,7 +134,6 @@ struct spa_node_callbacks {
uint32_t port_id,
uint32_t buffer_id, void *user_data);
void (*done) (struct spa_node *node, int seq, int res, void *user_data);
};
/**