simplify events and commands

This commit is contained in:
Wim Taymans 2016-10-24 15:30:15 +02:00
parent 0373f73bac
commit d3dd90bb05
25 changed files with 220 additions and 252 deletions

View file

@ -33,6 +33,25 @@ typedef struct _SpaMonitor SpaMonitor;
#include <spa/dict.h>
#include <spa/plugin.h>
/**
* SpaMonitorEventType:
* @SPA_MONITOR_EVENT_TYPE_INVALID: invalid event
* @SPA_MONITOR_EVENT_TYPE_ADDED: an item was added, data points to #SpaMonitorItem
* @SPA_MONITOR_EVENT_TYPE_REMOVED: an item was removed, data points to #SpaMonitorItem
* @SPA_MONITOR_EVENT_TYPE_CHANGED: an item was changed, data points to #SpaMonitorItem
*/
typedef enum {
SPA_MONITOR_EVENT_TYPE_INVALID = 0,
SPA_MONITOR_EVENT_TYPE_ADDED,
SPA_MONITOR_EVENT_TYPE_REMOVED,
SPA_MONITOR_EVENT_TYPE_CHANGED,
} SpaMonitorEventType;
typedef struct {
SpaMonitorEventType type;
size_t size;
} SpaMonitorEvent;
typedef enum {
SPA_MONITOR_ITEM_FLAG_NONE = 0,
} SpaMonitorItemFlags;
@ -50,6 +69,7 @@ typedef enum {
} SpaMonitorItemState;
typedef struct {
SpaMonitorEvent event;
const char *id;
SpaMonitorItemFlags flags;
SpaMonitorItemState state;
@ -59,26 +79,6 @@ typedef struct {
const SpaHandleFactory *factory;
} SpaMonitorItem;
/**
* SpaMonitorEventType:
* @SPA_MONITOR_EVENT_TYPE_INVALID: invalid event
* @SPA_MONITOR_EVENT_TYPE_ADDED: an item was added, data points to #SpaMonitorItem
* @SPA_MONITOR_EVENT_TYPE_REMOVED: an item was removed, data points to #SpaMonitorItem
* @SPA_MONITOR_EVENT_TYPE_CHANGED: an item was changed, data points to #SpaMonitorItem
*/
typedef enum {
SPA_MONITOR_EVENT_TYPE_INVALID = 0,
SPA_MONITOR_EVENT_TYPE_ADDED,
SPA_MONITOR_EVENT_TYPE_REMOVED,
SPA_MONITOR_EVENT_TYPE_CHANGED,
} SpaMonitorEventType;
typedef struct {
SpaMonitorEventType type;
void *data;
size_t size;
} SpaMonitorEvent;
/**
* SpaMonitorCallback:
* @node: a #SpaMonitor emiting the event

View file

@ -51,7 +51,6 @@ typedef enum {
struct _SpaNodeCommand {
SpaNodeCommandType type;
void *data;
size_t size;
};
@ -68,20 +67,21 @@ struct _SpaNodeCommand {
* @state: the new clock state, when @change_mask = 1<<2
*/
typedef struct {
SpaNodeCommand command;
#define SPA_NODE_COMMAND_CLOCK_UPDATE_TIME (1 << 0)
#define SPA_NODE_COMMAND_CLOCK_UPDATE_SCALE (1 << 1)
#define SPA_NODE_COMMAND_CLOCK_UPDATE_STATE (1 << 2)
#define SPA_NODE_COMMAND_CLOCK_UPDATE_LATENCY (1 << 3)
uint32_t change_mask;
int32_t rate;
int64_t ticks;
int64_t monotonic_time;
int64_t offset;
int32_t scale;
SpaClockState state;
uint32_t change_mask;
int32_t rate;
int64_t ticks;
int64_t monotonic_time;
int64_t offset;
int32_t scale;
SpaClockState state;
#define SPA_NODE_COMMAND_CLOCK_UPDATE_FLAG_LIVE (1 << 0)
uint32_t flags;
int64_t latency;
uint32_t flags;
int64_t latency;
} SpaNodeCommandClockUpdate;
#ifdef __cplusplus

View file

@ -68,29 +68,33 @@ typedef enum {
struct _SpaNodeEvent {
SpaNodeEventType type;
void *data;
size_t size;
};
typedef struct {
SpaNodeEvent event;
uint32_t seq;
SpaResult res;
} SpaNodeEventAsyncComplete;
typedef struct {
SpaNodeEvent event;
uint32_t port_id;
} SpaNodeEventHaveOutput;
typedef struct {
SpaNodeEvent event;
uint32_t port_id;
} SpaNodeEventNeedInput;
typedef struct {
SpaNodeEvent event;
uint32_t port_id;
uint32_t buffer_id;
} SpaNodeEventReuseBuffer;
typedef struct {
SpaNodeEvent event;
#define SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_TIME (1 << 0)
#define SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_SCALE (1 << 1)
#define SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_STATE (1 << 2)

View file

@ -88,6 +88,7 @@ typedef struct {
typedef SpaResult (*SpaPollInvokeFunc) (SpaPoll *poll,
bool async,
uint32_t seq,
size_t size,
void *data,
@ -131,7 +132,6 @@ struct _SpaPoll {
SpaResult (*remove_item) (SpaPoll *poll,
SpaPollItem *item);
SpaResult (*invoke) (SpaPoll *poll,
SpaPollInvokeFunc func,
uint32_t seq,