mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-18 07:00:06 -05:00
Add support for async results
Add an async result code and an event to signal the completion. Use async return values to signal completion of a method and potential state change. Add selected format to port update message. Make it possible to parse into a custom copy of the command memory. Remove state change events from the elements, we now just update the state. Implement async results in the proxy element Add support for removing buffers in the client. Fix up pinossink Deal with async return in the links.
This commit is contained in:
parent
27acab7532
commit
68148188fa
25 changed files with 456 additions and 406 deletions
|
|
@ -35,6 +35,7 @@ typedef struct _SpaControlBuilder SpaControlBuilder;
|
|||
#include <spa/format.h>
|
||||
#include <spa/port.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/memory.h>
|
||||
|
||||
struct _SpaControl {
|
||||
size_t x[16];
|
||||
|
|
@ -59,8 +60,9 @@ typedef enum {
|
|||
SPA_CONTROL_CMD_NODE_UPDATE = 1,
|
||||
SPA_CONTROL_CMD_PORT_UPDATE = 2,
|
||||
SPA_CONTROL_CMD_PORT_REMOVED = 3,
|
||||
SPA_CONTROL_CMD_NODE_STATE_CHANGE = 4,
|
||||
|
||||
SPA_CONTROL_CMD_PORT_STATUS_CHANGE = 4,
|
||||
SPA_CONTROL_CMD_PORT_STATUS_CHANGE = 5,
|
||||
|
||||
/* server to client */
|
||||
SPA_CONTROL_CMD_ADD_PORT = 32,
|
||||
|
|
@ -92,16 +94,17 @@ typedef struct {
|
|||
const SpaProps *props;
|
||||
} SpaControlCmdNodeUpdate;
|
||||
|
||||
|
||||
/* SPA_CONTROL_CMD_PORT_UPDATE */
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_PROPS (1 << 1)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_INFO (1 << 2)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_FORMAT (1 << 1)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_PROPS (1 << 2)
|
||||
#define SPA_CONTROL_CMD_PORT_UPDATE_INFO (1 << 3)
|
||||
uint32_t change_mask;
|
||||
unsigned int n_possible_formats;
|
||||
SpaFormat **possible_formats;
|
||||
SpaFormat *format;
|
||||
const SpaProps *props;
|
||||
const SpaPortInfo *info;
|
||||
} SpaControlCmdPortUpdate;
|
||||
|
|
@ -113,25 +116,34 @@ typedef struct {
|
|||
|
||||
/* SPA_CONTROL_CMD_PORT_STATUS_CHANGE */
|
||||
|
||||
/* SPA_CONTROL_CMD_NODE_STATE_CHANGE */
|
||||
typedef struct {
|
||||
SpaNodeState state;
|
||||
} SpaControlCmdNodeStateChange;
|
||||
|
||||
/* SPA_CONTROL_CMD_ADD_PORT */
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
uint32_t seq;
|
||||
uint32_t port_id;
|
||||
} SpaControlCmdAddPort;
|
||||
|
||||
/* SPA_CONTROL_CMD_REMOVE_PORT */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
uint32_t port_id;
|
||||
} SpaControlCmdRemovePort;
|
||||
|
||||
|
||||
/* SPA_CONTROL_CMD_SET_FORMAT */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
uint32_t port_id;
|
||||
SpaFormat *format;
|
||||
} SpaControlCmdSetFormat;
|
||||
|
||||
/* SPA_CONTROL_CMD_SET_PROPERTY */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
uint32_t port_id;
|
||||
uint32_t id;
|
||||
size_t size;
|
||||
|
|
@ -140,11 +152,13 @@ typedef struct {
|
|||
|
||||
/* SPA_CONTROL_CMD_NODE_COMMAND */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
SpaNodeCommand *command;
|
||||
} SpaControlCmdNodeCommand;
|
||||
|
||||
/* SPA_CONTROL_CMD_ADD_MEM */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
uint32_t port_id;
|
||||
SpaMemoryRef mem;
|
||||
uint32_t mem_type;
|
||||
|
|
@ -155,12 +169,14 @@ typedef struct {
|
|||
|
||||
/* SPA_CONTROL_CMD_REMOVE_MEM */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
uint32_t port_id;
|
||||
SpaMemoryRef mem;
|
||||
} SpaControlCmdRemoveMem;
|
||||
|
||||
/* SPA_CONTROL_CMD_USE_BUFFERS */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
uint32_t port_id;
|
||||
unsigned int n_buffers;
|
||||
SpaBuffer **buffers;
|
||||
|
|
@ -192,7 +208,10 @@ SpaResult spa_control_iter_end (SpaControlIter *iter);
|
|||
|
||||
SpaControlCmd spa_control_iter_get_cmd (SpaControlIter *iter);
|
||||
void * spa_control_iter_get_data (SpaControlIter *iter,
|
||||
size_t *size);
|
||||
size_t *size);
|
||||
SpaResult spa_control_iter_set_data (SpaControlIter *iter,
|
||||
void *data,
|
||||
size_t size);
|
||||
|
||||
SpaResult spa_control_iter_parse_cmd (SpaControlIter *iter,
|
||||
void *command);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ extern "C" {
|
|||
#include <stddef.h>
|
||||
|
||||
typedef enum {
|
||||
SPA_RESULT_ASYNC = (1 << 30),
|
||||
SPA_RESULT_MODIFIED = 1,
|
||||
SPA_RESULT_OK = 0,
|
||||
SPA_RESULT_ERROR = -1,
|
||||
SPA_RESULT_INACTIVE = -2,
|
||||
|
|
@ -59,8 +61,17 @@ typedef enum {
|
|||
SPA_RESULT_NO_BUFFERS = -27,
|
||||
SPA_RESULT_INVALID_BUFFER_ID = -28,
|
||||
SPA_RESULT_WRONG_STATE = -29,
|
||||
SPA_RESULT_ASYNC_BUSY = -30,
|
||||
} SpaResult;
|
||||
|
||||
#define SPA_RESULT_IS_OK(res) ((res) >= 0)
|
||||
#define SPA_RESULT_IS_ERROR(res) ((res) < 0)
|
||||
#define SPA_RESULT_IS_ASYNC(res) (((res) & SPA_RESULT_ASYNC) == SPA_RESULT_ASYNC)
|
||||
|
||||
#define SPA_ASYNC_SEQ_MASK (SPA_RESULT_ASYNC - 1)
|
||||
#define SPA_RESULT_ASYNC_SEQ(res) ((res) & SPA_ASYNC_SEQ_MASK)
|
||||
#define SPA_RESULT_RETURN_ASYNC(seq) (SPA_RESULT_ASYNC | ((seq) & SPA_ASYNC_SEQ_MASK))
|
||||
|
||||
typedef void (*SpaNotify) (void *data);
|
||||
|
||||
#define SPA_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ typedef struct _SpaNodeEvent SpaNodeEvent;
|
|||
/**
|
||||
* SpaEventType:
|
||||
* @SPA_NODE_EVENT_TYPE_INVALID: invalid event, should be ignored
|
||||
* @SPA_NODE_EVENT_TYPE_ASYNC_COMPLETE: an async operation completed
|
||||
* @SPA_NODE_EVENT_TYPE_PORT_ADDED: a new port is added
|
||||
* @SPA_NODE_EVENT_TYPE_PORT_REMOVED: a port is removed
|
||||
* @SPA_NODE_EVENT_TYPE_STATE_CHANGE: emited when the state changes
|
||||
* @SPA_NODE_EVENT_TYPE_HAVE_OUTPUT: emited when an async node has output that can be pulled
|
||||
* @SPA_NODE_EVENT_TYPE_NEED_INPUT: emited when more data can be pushed to an async node
|
||||
* @SPA_NODE_EVENT_TYPE_REUSE_BUFFER: emited when a buffer can be reused
|
||||
|
|
@ -50,9 +50,9 @@ typedef struct _SpaNodeEvent SpaNodeEvent;
|
|||
*/
|
||||
typedef enum {
|
||||
SPA_NODE_EVENT_TYPE_INVALID = 0,
|
||||
SPA_NODE_EVENT_TYPE_ASYNC_COMPLETE,
|
||||
SPA_NODE_EVENT_TYPE_PORT_ADDED,
|
||||
SPA_NODE_EVENT_TYPE_PORT_REMOVED,
|
||||
SPA_NODE_EVENT_TYPE_STATE_CHANGE,
|
||||
SPA_NODE_EVENT_TYPE_HAVE_OUTPUT,
|
||||
SPA_NODE_EVENT_TYPE_NEED_INPUT,
|
||||
SPA_NODE_EVENT_TYPE_REUSE_BUFFER,
|
||||
|
|
@ -73,6 +73,11 @@ struct _SpaNodeEvent {
|
|||
size_t size;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
SpaResult res;
|
||||
} SpaNodeEventAsyncComplete;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaNodeEventPortAdded;
|
||||
|
|
|
|||
|
|
@ -215,10 +215,13 @@ struct _SpaNode {
|
|||
*
|
||||
* Send a command to @node.
|
||||
*
|
||||
* Upon completion, a command might change the state of a node.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node or command is %NULL
|
||||
* #SPA_RESULT_NOT_IMPLEMENTED when this node can't process commands
|
||||
* #SPA_RESULT_INVALID_COMMAND @command is an invalid command
|
||||
* #SPA_RESULT_ASYNC @command is executed asynchronously
|
||||
*/
|
||||
SpaResult (*send_command) (SpaNode *node,
|
||||
SpaNodeCommand *command);
|
||||
|
|
@ -339,14 +342,20 @@ struct _SpaNode {
|
|||
*
|
||||
* This function takes a copy of the format.
|
||||
*
|
||||
* Upon completion, this function might change the state of a node to
|
||||
* the READY state or to CONFIGURE when @format is NULL.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_OK_RECHECK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL
|
||||
* #SPA_RESULT_INVALID_PORT when port_id is not valid
|
||||
* #SPA_RESULT_INVALID_MEDIA_TYPE when the media type is not valid
|
||||
* #SPA_RESULT_INVALID_FORMAT_PROPERTIES when one of the mandatory format
|
||||
* properties is not specified.
|
||||
* properties is not specified and #SPA_PORT_FORMAT_FLAG_FIXATE was
|
||||
* not set in @flags.
|
||||
* #SPA_RESULT_WRONG_PROPERTY_TYPE when the type or size of a property
|
||||
* is not correct.
|
||||
* #SPA_RESULT_ASYNC the function is executed asynchronously
|
||||
*/
|
||||
SpaResult (*port_set_format) (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
|
|
@ -401,7 +410,12 @@ struct _SpaNode {
|
|||
* Passing %NULL as @buffers will remove the reference that the port has
|
||||
* on the buffers.
|
||||
*
|
||||
* Upon completion, this function might change the state of the
|
||||
* node to PAUSED, when the node has enough buffers, or READY when
|
||||
* @buffers are %NULL.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_ASYNC the function is executed asynchronously
|
||||
*/
|
||||
SpaResult (*port_use_buffers) (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue