mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Add versions to structures
Use versions instead of size Remove user_data from callbacks, we can simply pass the callback struct.
This commit is contained in:
parent
4a219e81dd
commit
c3b73ba47d
45 changed files with 344 additions and 303 deletions
|
|
@ -43,15 +43,17 @@ enum spa_clock_state {
|
|||
#include <spa/plugin.h>
|
||||
#include <spa/props.h>
|
||||
|
||||
#define SPA_VERSION_CLOCK 0
|
||||
|
||||
/**
|
||||
* spa_clock:
|
||||
*
|
||||
* A time provider.
|
||||
*/
|
||||
struct spa_clock {
|
||||
/* the total size of this clock. This can be used to expand this
|
||||
/* the version of this clock. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
|
||||
const struct spa_dict *info;
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ struct { \
|
|||
} name
|
||||
|
||||
#define SPA_LOG_IMPL_INIT \
|
||||
{ { sizeof(struct spa_log), \
|
||||
{ { SPA_VERSION_LOG, \
|
||||
NULL, \
|
||||
SPA_LOG_LEVEL_INFO, \
|
||||
spa_log_impl_log, \
|
||||
|
|
|
|||
|
|
@ -42,15 +42,17 @@ enum spa_log_level {
|
|||
SPA_LOG_LEVEL_TRACE,
|
||||
};
|
||||
|
||||
#define SPA_VERSION_LOG 0
|
||||
|
||||
/**
|
||||
* struct spa_log:
|
||||
*
|
||||
* The Log interface
|
||||
*/
|
||||
struct spa_log {
|
||||
/* the total size of this log. This can be used to expand this
|
||||
/* the version of this log. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
/**
|
||||
* struct spa_log::info
|
||||
*
|
||||
|
|
|
|||
|
|
@ -65,15 +65,18 @@ typedef int (*spa_invoke_func_t) (struct spa_loop *loop,
|
|||
size_t size,
|
||||
void *data,
|
||||
void *user_data);
|
||||
|
||||
#define SPA_VERSION_LOOP 0
|
||||
|
||||
/**
|
||||
* spa_loop:
|
||||
*
|
||||
* Register sources and work items to an event loop
|
||||
*/
|
||||
struct spa_loop {
|
||||
/* the total size of this structure. This can be used to expand this
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
|
||||
int (*add_source) (struct spa_loop *loop,
|
||||
struct spa_source *source);
|
||||
|
|
@ -96,24 +99,31 @@ struct spa_loop {
|
|||
#define spa_loop_remove_source(l,...) (l)->remove_source(__VA_ARGS__)
|
||||
#define spa_loop_invoke(l,...) (l)->invoke((l),__VA_ARGS__)
|
||||
|
||||
#define SPA_VERSION_LOOP_CONTROL_HOOKS 0
|
||||
|
||||
/** Control hooks */
|
||||
struct spa_loop_control_hooks {
|
||||
uint32_t version;
|
||||
|
||||
struct spa_list link;
|
||||
|
||||
/** Executed right before waiting for events */
|
||||
void (*before) (const struct spa_loop_control_hooks *hooks);
|
||||
/** Executed right after waiting for events */
|
||||
void (*after) (const struct spa_loop_control_hooks *hooks);
|
||||
};
|
||||
|
||||
#define SPA_VERSION_LOOP_CONTROL 0
|
||||
|
||||
/**
|
||||
* spa_loop_control:
|
||||
*
|
||||
* Control an event loop
|
||||
*/
|
||||
struct spa_loop_control {
|
||||
/* the total size of this structure. This can be used to expand this
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
|
||||
int (*get_fd) (struct spa_loop_control *ctrl);
|
||||
|
||||
|
|
@ -150,15 +160,17 @@ typedef void (*spa_source_signal_func_t) (struct spa_loop_utils *utils,
|
|||
struct spa_source *source,
|
||||
int signal_number, void *data);
|
||||
|
||||
#define SPA_VERSION_LOOP_UTILS 0
|
||||
|
||||
/**
|
||||
* struct spa_loop_utils:
|
||||
*
|
||||
* Create sources for an event loop
|
||||
*/
|
||||
struct spa_loop_utils {
|
||||
/* the total size of this structure. This can be used to expand this
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
|
||||
struct spa_source *(*add_io) (struct spa_loop_utils *utils,
|
||||
int fd,
|
||||
|
|
|
|||
|
|
@ -104,19 +104,31 @@ enum spa_monitor_item_state {
|
|||
SPA_MONITOR_ITEM_STATE_UNAVAILABLE,
|
||||
};
|
||||
|
||||
#define SPA_VERSION_MONITOR_CALLBACKS 0
|
||||
|
||||
/**
|
||||
* spa_monitor_callbacks:
|
||||
*/
|
||||
struct spa_monitor_callbacks {
|
||||
void (*event) (struct spa_monitor *monitor, struct spa_event *event, void *user_data);
|
||||
uint32_t version; /**< version of the structure */
|
||||
|
||||
void (*event) (const struct spa_monitor_callbacks *callbacks,
|
||||
struct spa_monitor *monitor,
|
||||
struct spa_event *event);
|
||||
};
|
||||
|
||||
#define SPA_VERSION_MONITOR 0
|
||||
|
||||
/**
|
||||
* spa_monitor:
|
||||
*
|
||||
* The device monitor interface.
|
||||
*/
|
||||
struct spa_monitor {
|
||||
/* the version of this monitor. This can be used to expand this
|
||||
* structure in the future */
|
||||
uint32_t version;
|
||||
|
||||
/**
|
||||
* spa_monitor::info
|
||||
*
|
||||
|
|
@ -124,15 +136,10 @@ struct spa_monitor {
|
|||
*/
|
||||
const struct spa_dict *info;
|
||||
|
||||
/* the total size of this monitor. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
|
||||
/**
|
||||
* spa_monitor::set_callbacks:
|
||||
* @monitor: a #spa_monitor
|
||||
* @callback: a #callbacks
|
||||
* @user_data: extra user data
|
||||
*
|
||||
* Set callbacks to receive asynchronous notifications from
|
||||
* the monitor.
|
||||
|
|
@ -140,8 +147,7 @@ struct spa_monitor {
|
|||
* Returns: #SPA_RESULT_OK on success
|
||||
*/
|
||||
int (*set_callbacks) (struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
size_t callbacks_size, void *user_data);
|
||||
const struct spa_monitor_callbacks *callbacks);
|
||||
|
||||
int (*enum_items) (struct spa_monitor *monitor,
|
||||
struct spa_monitor_item **item, uint32_t index);
|
||||
|
|
|
|||
|
|
@ -78,23 +78,27 @@ struct spa_port_info {
|
|||
const struct spa_dict *props; /**< extra port properties */
|
||||
};
|
||||
|
||||
#define SPA_VERSION_NODE_CALLBACKS 0
|
||||
|
||||
struct spa_node_callbacks {
|
||||
void (*done) (struct spa_node *node, int seq, int res, void *user_data);
|
||||
uint32_t version; /**< version of this structure */
|
||||
|
||||
/** Emited when an async operation completed */
|
||||
void (*done) (const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, int seq, int res);
|
||||
/**
|
||||
* struct spa_node_callbacks::event:
|
||||
* @node: a #struct spa_node
|
||||
* @event: the event that was emited
|
||||
* @user_data: user data provided when registering the callbacks
|
||||
*
|
||||
* This will be called when an out-of-bound event is notified
|
||||
* on @node. the callback can be called from any thread.
|
||||
*/
|
||||
void (*event) (struct spa_node *node, struct spa_event *event, void *user_data);
|
||||
void (*event) (const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node, struct spa_event *event);
|
||||
/**
|
||||
* struct spa_node_callbacks::need_input:
|
||||
* @node: a #struct spa_node
|
||||
* @user_data: user data provided when registering the callbacks
|
||||
*
|
||||
* The node needs more input. This callback is called from the
|
||||
* data thread.
|
||||
|
|
@ -102,11 +106,11 @@ struct spa_node_callbacks {
|
|||
* When this function is NULL, synchronous operation is requested
|
||||
* on the input ports.
|
||||
*/
|
||||
void (*need_input) (struct spa_node *node, void *user_data);
|
||||
void (*need_input) (const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node);
|
||||
/**
|
||||
* struct spa_node_callbacks::have_output:
|
||||
* @node: a #struct spa_node
|
||||
* @user_data: user data provided when registering the callbacks
|
||||
*
|
||||
* The node has output input. This callback is called from the
|
||||
* data thread.
|
||||
|
|
@ -114,13 +118,13 @@ struct spa_node_callbacks {
|
|||
* When this function is NULL, synchronous operation is requested
|
||||
* on the output ports.
|
||||
*/
|
||||
void (*have_output) (struct spa_node *node, void *user_data);
|
||||
void (*have_output) (const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node);
|
||||
/**
|
||||
* struct spa_node_callbacks::reuse_buffer:
|
||||
* @node: a #struct spa_node
|
||||
* @port_id: an input port_id
|
||||
* @buffer_id: the buffer id to be reused
|
||||
* @user_data: user data provided when registering the callbacks
|
||||
*
|
||||
* The node has a buffer that can be reused. This callback is called
|
||||
* from the data thread.
|
||||
|
|
@ -128,12 +132,15 @@ struct spa_node_callbacks {
|
|||
* When this function is NULL, the buffers to reuse will be set in
|
||||
* the io area or the input ports.
|
||||
*/
|
||||
void (*reuse_buffer) (struct spa_node *node,
|
||||
void (*reuse_buffer) (const struct spa_node_callbacks *callbacks,
|
||||
struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id, void *user_data);
|
||||
uint32_t buffer_id);
|
||||
|
||||
};
|
||||
|
||||
#define SPA_VERSION_NODE 0
|
||||
|
||||
/**
|
||||
* struct spa_node:
|
||||
*
|
||||
|
|
@ -143,9 +150,9 @@ struct spa_node_callbacks {
|
|||
*
|
||||
*/
|
||||
struct spa_node {
|
||||
/* the total size of this node. This can be used to expand this
|
||||
/* the version of this node. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
/**
|
||||
* spa_node::info
|
||||
*
|
||||
|
|
@ -218,8 +225,6 @@ struct spa_node {
|
|||
* struct spa_node::set_event_callback:
|
||||
* @node: a #struct spa_node
|
||||
* @callbacks: callbacks to set
|
||||
* @callbacks_size: size of the callbacks structure
|
||||
* @user_data: user data passed to the callback functions
|
||||
*
|
||||
* Set callbacks to receive events and scheduling callbacks from @node.
|
||||
* if @callbacks is %NULL, the current callbacks are removed.
|
||||
|
|
@ -230,9 +235,7 @@ struct spa_node {
|
|||
* #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL
|
||||
*/
|
||||
int (*set_callbacks) (struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data);
|
||||
const struct spa_node_callbacks *callbacks);
|
||||
/**
|
||||
* struct spa_node::get_n_ports:
|
||||
* @node: a #struct spa_node
|
||||
|
|
|
|||
|
|
@ -30,7 +30,12 @@ extern "C" {
|
|||
#define SPA_TYPE__Handle SPA_TYPE_INTERFACE_BASE "Handle"
|
||||
#define SPA_TYPE__HandleFactory SPA_TYPE_INTERFACE_BASE "HandleFactory"
|
||||
|
||||
#define SPA_VERSION_HANDLE 0
|
||||
|
||||
struct spa_handle {
|
||||
/** Version of this struct */
|
||||
uint32_t version;
|
||||
|
||||
/* user_data that can be set by the application */
|
||||
void *user_data;
|
||||
/**
|
||||
|
|
@ -98,7 +103,11 @@ static inline void *spa_support_find(const struct spa_support *support,
|
|||
|
||||
#define SPA_SUPPORT_INIT(type,data) (struct spa_support) { (type), (data) }
|
||||
|
||||
#define SPA_VERSION_HANDLE_FACTORY 0
|
||||
|
||||
struct spa_handle_factory {
|
||||
/** The version of this structure */
|
||||
uint32_t version;
|
||||
/**
|
||||
* spa_handle_factory::name
|
||||
*
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ struct { \
|
|||
} name
|
||||
|
||||
#define SPA_TYPE_MAP_IMPL_INIT \
|
||||
{ { sizeof(struct spa_type_map), \
|
||||
{ { SPA_VERSION_TYPE_MAP, \
|
||||
NULL, \
|
||||
spa_type_map_impl_get_id, \
|
||||
spa_type_map_impl_get_type, \
|
||||
|
|
|
|||
|
|
@ -30,15 +30,17 @@ extern "C" {
|
|||
|
||||
#define SPA_TYPE__TypeMap SPA_TYPE_INTERFACE_BASE "TypeMap"
|
||||
|
||||
#define SPA_VERSION_TYPE_MAP 0
|
||||
|
||||
/**
|
||||
* spa_type_map:
|
||||
*
|
||||
* Maps between string types and their type id
|
||||
*/
|
||||
struct spa_type_map {
|
||||
/* the total size of this structure. This can be used to expand this
|
||||
/* the version of this structure. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
uint32_t version;
|
||||
/**
|
||||
* spa_type_map::info
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue