mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Cleanups
Make events and command specific to the node Remove some unused code Improve state changes Use easier fixate by just taking the element default value Fix reuse buffer in the proxy
This commit is contained in:
parent
ac3cd24d5c
commit
8ada6736c0
29 changed files with 686 additions and 708 deletions
|
|
@ -1,104 +0,0 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_EVENT_H__
|
||||
#define __SPA_EVENT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _SpaEvent SpaEvent;
|
||||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/poll.h>
|
||||
#include <spa/node.h>
|
||||
|
||||
/**
|
||||
* SpaEventType:
|
||||
* @SPA_EVENT_TYPE_INVALID: invalid event, should be ignored
|
||||
* @SPA_EVENT_TYPE_PORT_ADDED: a new port is added
|
||||
* @SPA_EVENT_TYPE_PORT_REMOVED: a port is removed
|
||||
* @SPA_EVENT_TYPE_STATE_CHANGE: emited when the state changes
|
||||
* @SPA_EVENT_TYPE_HAVE_OUTPUT: emited when an async node has output that can be pulled
|
||||
* @SPA_EVENT_TYPE_NEED_INPUT: emited when more data can be pushed to an async node
|
||||
* @SPA_EVENT_TYPE_REUSE_BUFFER: emited when a buffer can be reused
|
||||
* @SPA_EVENT_TYPE_ADD_POLL: emited when a pollfd should be added. data points to #SpaPollItem
|
||||
* @SPA_EVENT_TYPE_UPDATE_POLL: update the pollfd item
|
||||
* @SPA_EVENT_TYPE_REMOVE_POLL: emited when a pollfd should be removed. data points to #SpaPollItem
|
||||
* @SPA_EVENT_TYPE_DRAINED: emited when DRAIN command completed
|
||||
* @SPA_EVENT_TYPE_MARKER: emited when MARK command completed
|
||||
* @SPA_EVENT_TYPE_ERROR: emited when error occured
|
||||
* @SPA_EVENT_TYPE_BUFFERING: emited when buffering is in progress
|
||||
* @SPA_EVENT_TYPE_REQUEST_REFRESH: emited when a keyframe refresh is needed
|
||||
*/
|
||||
typedef enum {
|
||||
SPA_EVENT_TYPE_INVALID = 0,
|
||||
SPA_EVENT_TYPE_PORT_ADDED,
|
||||
SPA_EVENT_TYPE_PORT_REMOVED,
|
||||
SPA_EVENT_TYPE_STATE_CHANGE,
|
||||
SPA_EVENT_TYPE_HAVE_OUTPUT,
|
||||
SPA_EVENT_TYPE_NEED_INPUT,
|
||||
SPA_EVENT_TYPE_REUSE_BUFFER,
|
||||
SPA_EVENT_TYPE_ADD_POLL,
|
||||
SPA_EVENT_TYPE_UPDATE_POLL,
|
||||
SPA_EVENT_TYPE_REMOVE_POLL,
|
||||
SPA_EVENT_TYPE_DRAINED,
|
||||
SPA_EVENT_TYPE_MARKER,
|
||||
SPA_EVENT_TYPE_ERROR,
|
||||
SPA_EVENT_TYPE_BUFFERING,
|
||||
SPA_EVENT_TYPE_REQUEST_REFRESH,
|
||||
} SpaEventType;
|
||||
|
||||
struct _SpaEvent {
|
||||
SpaEventType type;
|
||||
void *data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaEventPortAdded;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaEventPortRemoved;
|
||||
|
||||
typedef struct {
|
||||
SpaNodeState state;
|
||||
} SpaEventStateChange;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaEventHaveOutput;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaEventNeedInput;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
uint32_t buffer_id;
|
||||
} SpaEventReuseBuffer;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_EVENT_H__ */
|
||||
|
|
@ -17,35 +17,35 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_COMMAND_H__
|
||||
#define __SPA_COMMAND_H__
|
||||
#ifndef __SPA_NODE_COMMAND_H__
|
||||
#define __SPA_NODE_COMMAND_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _SpaCommand SpaCommand;
|
||||
typedef struct _SpaNodeCommand SpaNodeCommand;
|
||||
|
||||
#include <spa/defs.h>
|
||||
|
||||
typedef enum {
|
||||
SPA_COMMAND_INVALID = 0,
|
||||
SPA_COMMAND_PAUSE,
|
||||
SPA_COMMAND_START,
|
||||
SPA_COMMAND_FLUSH,
|
||||
SPA_COMMAND_DRAIN,
|
||||
SPA_COMMAND_MARKER,
|
||||
} SpaCommandType;
|
||||
SPA_NODE_COMMAND_INVALID = 0,
|
||||
SPA_NODE_COMMAND_PAUSE,
|
||||
SPA_NODE_COMMAND_START,
|
||||
SPA_NODE_COMMAND_FLUSH,
|
||||
SPA_NODE_COMMAND_DRAIN,
|
||||
SPA_NODE_COMMAND_MARKER,
|
||||
} SpaNodeCommandType;
|
||||
|
||||
struct _SpaCommand {
|
||||
SpaCommandType type;
|
||||
uint32_t port_id;
|
||||
void *data;
|
||||
size_t size;
|
||||
struct _SpaNodeCommand {
|
||||
SpaNodeCommandType type;
|
||||
uint32_t port_id;
|
||||
void *data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_COMMAND_H__ */
|
||||
#endif /* __SPA_NODE_COMMAND_H__ */
|
||||
104
spa/include/spa/node-event.h
Normal file
104
spa/include/spa/node-event.h
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_NODE_EVENT_H__
|
||||
#define __SPA_NODE_EVENT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _SpaNodeEvent SpaNodeEvent;
|
||||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/poll.h>
|
||||
#include <spa/node.h>
|
||||
|
||||
/**
|
||||
* SpaEventType:
|
||||
* @SPA_NODE_EVENT_TYPE_INVALID: invalid event, should be ignored
|
||||
* @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
|
||||
* @SPA_NODE_EVENT_TYPE_ADD_POLL: emited when a pollfd should be added. data points to #SpaPollItem
|
||||
* @SPA_NODE_EVENT_TYPE_UPDATE_POLL: update the pollfd item
|
||||
* @SPA_NODE_EVENT_TYPE_REMOVE_POLL: emited when a pollfd should be removed. data points to #SpaPollItem
|
||||
* @SPA_NODE_EVENT_TYPE_DRAINED: emited when DRAIN command completed
|
||||
* @SPA_NODE_EVENT_TYPE_MARKER: emited when MARK command completed
|
||||
* @SPA_NODE_EVENT_TYPE_ERROR: emited when error occured
|
||||
* @SPA_NODE_EVENT_TYPE_BUFFERING: emited when buffering is in progress
|
||||
* @SPA_NODE_EVENT_TYPE_REQUEST_REFRESH: emited when a keyframe refresh is needed
|
||||
*/
|
||||
typedef enum {
|
||||
SPA_NODE_EVENT_TYPE_INVALID = 0,
|
||||
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,
|
||||
SPA_NODE_EVENT_TYPE_ADD_POLL,
|
||||
SPA_NODE_EVENT_TYPE_UPDATE_POLL,
|
||||
SPA_NODE_EVENT_TYPE_REMOVE_POLL,
|
||||
SPA_NODE_EVENT_TYPE_DRAINED,
|
||||
SPA_NODE_EVENT_TYPE_MARKER,
|
||||
SPA_NODE_EVENT_TYPE_ERROR,
|
||||
SPA_NODE_EVENT_TYPE_BUFFERING,
|
||||
SPA_NODE_EVENT_TYPE_REQUEST_REFRESH,
|
||||
} SpaNodeEventType;
|
||||
|
||||
struct _SpaNodeEvent {
|
||||
SpaNodeEventType type;
|
||||
void *data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaNodeEventPortAdded;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaNodeEventPortRemoved;
|
||||
|
||||
typedef struct {
|
||||
SpaNodeState state;
|
||||
} SpaNodeEventStateChange;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaNodeEventHaveOutput;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaNodeEventNeedInput;
|
||||
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
uint32_t buffer_id;
|
||||
} SpaNodeEventReuseBuffer;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_NODE_EVENT_H__ */
|
||||
|
|
@ -49,9 +49,9 @@ typedef enum {
|
|||
#include <spa/plugin.h>
|
||||
#include <spa/props.h>
|
||||
#include <spa/port.h>
|
||||
#include <spa/event.h>
|
||||
#include <spa/node-event.h>
|
||||
#include <spa/node-command.h>
|
||||
#include <spa/buffer.h>
|
||||
#include <spa/command.h>
|
||||
#include <spa/format.h>
|
||||
|
||||
/**
|
||||
|
|
@ -70,15 +70,15 @@ typedef enum {
|
|||
} SpaPortFormatFlags;
|
||||
|
||||
/**
|
||||
* SpaInputFlags:
|
||||
* SpaPortInputFlags:
|
||||
* @SPA_INPUT_FLAG_NONE: no flag
|
||||
*/
|
||||
typedef enum {
|
||||
SPA_INPUT_FLAG_NONE = 0,
|
||||
} SpaInputFlags;
|
||||
SPA_PORT_INPUT_FLAG_NONE = 0,
|
||||
} SpaPortInputFlags;
|
||||
|
||||
/**
|
||||
* SpaInputInfo:
|
||||
* SpaPortInputInfo:
|
||||
* @port_id: the port id
|
||||
* @flags: extra flags
|
||||
* @buffer_id: a buffer id
|
||||
|
|
@ -87,29 +87,29 @@ typedef enum {
|
|||
* Input information for a node.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
SpaInputFlags flags;
|
||||
uint32_t buffer_id;
|
||||
SpaResult status;
|
||||
} SpaInputInfo;
|
||||
uint32_t port_id;
|
||||
SpaPortInputFlags flags;
|
||||
uint32_t buffer_id;
|
||||
SpaResult status;
|
||||
} SpaPortInputInfo;
|
||||
|
||||
/**
|
||||
* SpaOutputFlags:
|
||||
* @SPA_OUTPUT_FLAG_NONE: no flag
|
||||
* @SPA_OUTPUT_FLAG_PULL: force a #SPA_EVENT_NEED_INPUT event on the
|
||||
* SpaPortOutputFlags:
|
||||
* @SPA_PORT_OUTPUT_FLAG_NONE: no flag
|
||||
* @SPA_PORT_OUTPUT_FLAG_PULL: force a #SPA_NODE_EVENT_NEED_INPUT event on the
|
||||
* peer input ports when no data is available.
|
||||
* @SPA_OUTPUT_FLAG_DISCARD: discard the buffer data
|
||||
* @SPA_OUTPUT_FLAG_NO_BUFFER: no buffer was produced on the port
|
||||
* @SPA_PORT_OUTPUT_FLAG_DISCARD: discard the buffer data
|
||||
* @SPA_PORT_OUTPUT_FLAG_NO_BUFFER: no buffer was produced on the port
|
||||
*/
|
||||
typedef enum {
|
||||
SPA_OUTPUT_FLAG_NONE = 0,
|
||||
SPA_OUTPUT_FLAG_PULL = (1 << 0),
|
||||
SPA_OUTPUT_FLAG_DISCARD = (1 << 1),
|
||||
SPA_OUTPUT_FLAG_NO_BUFFER = (1 << 2),
|
||||
} SpaOutputFlags;
|
||||
SPA_PORT_OUTPUT_FLAG_NONE = 0,
|
||||
SPA_PORT_OUTPUT_FLAG_PULL = (1 << 0),
|
||||
SPA_PORT_OUTPUT_FLAG_DISCARD = (1 << 1),
|
||||
SPA_PORT_OUTPUT_FLAG_NO_BUFFER = (1 << 2),
|
||||
} SpaPortOutputFlags;
|
||||
|
||||
/**
|
||||
* SpaOutputInfo:
|
||||
* SpaPortOutputInfo:
|
||||
* @port_id: the port id
|
||||
* @flags: extra flags
|
||||
* @buffer_id: a buffer id will be set
|
||||
|
|
@ -119,15 +119,15 @@ typedef enum {
|
|||
* Output information for a node.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
SpaOutputFlags flags;
|
||||
uint32_t buffer_id;
|
||||
SpaEvent *event;
|
||||
SpaResult status;
|
||||
} SpaOutputInfo;
|
||||
uint32_t port_id;
|
||||
SpaPortOutputFlags flags;
|
||||
uint32_t buffer_id;
|
||||
SpaNodeEvent *event;
|
||||
SpaResult status;
|
||||
} SpaPortOutputInfo;
|
||||
|
||||
/**
|
||||
* SpaEventCallback:
|
||||
* SpaNodeCallback:
|
||||
* @node: a #SpaNode emiting the event
|
||||
* @event: the event that was emited
|
||||
* @user_data: user data provided when registering the callback
|
||||
|
|
@ -135,9 +135,9 @@ typedef struct {
|
|||
* This will be called when an out-of-bound event is notified
|
||||
* on @node.
|
||||
*/
|
||||
typedef void (*SpaEventCallback) (SpaNode *node,
|
||||
SpaEvent *event,
|
||||
void *user_data);
|
||||
typedef void (*SpaNodeEventCallback) (SpaNode *node,
|
||||
SpaNodeEvent *event,
|
||||
void *user_data);
|
||||
|
||||
#define SPA_INTERFACE_ID_NODE 0
|
||||
#define SPA_INTERFACE_ID_NODE_NAME "Node interface"
|
||||
|
|
@ -205,7 +205,7 @@ struct _SpaNode {
|
|||
/**
|
||||
* SpaNode::send_command:
|
||||
* @node: a #SpaNode
|
||||
* @command: a #SpaCommand
|
||||
* @command: a #SpaNodeCommand
|
||||
*
|
||||
* Send a command to @node.
|
||||
*
|
||||
|
|
@ -215,7 +215,7 @@ struct _SpaNode {
|
|||
* #SPA_RESULT_INVALID_COMMAND @command is an invalid command
|
||||
*/
|
||||
SpaResult (*send_command) (SpaNode *node,
|
||||
SpaCommand *command);
|
||||
SpaNodeCommand *command);
|
||||
/**
|
||||
* SpaNode::set_event_callback:
|
||||
* @node: a #SpaNode
|
||||
|
|
@ -231,9 +231,9 @@ struct _SpaNode {
|
|||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL
|
||||
*/
|
||||
SpaResult (*set_event_callback) (SpaNode *node,
|
||||
SpaEventCallback callback,
|
||||
void *user_data);
|
||||
SpaResult (*set_event_callback) (SpaNode *node,
|
||||
SpaNodeEventCallback callback,
|
||||
void *user_data);
|
||||
/**
|
||||
* SpaNode::get_n_ports:
|
||||
* @node: a #SpaNode
|
||||
|
|
@ -450,8 +450,8 @@ struct _SpaNode {
|
|||
/**
|
||||
* SpaNode::port_push_input:
|
||||
* @node: a #SpaNode
|
||||
* @n_info: number of #SpaInputInfo in @info
|
||||
* @info: array of #SpaInputInfo
|
||||
* @n_info: number of #SpaPortInputInfo in @info
|
||||
* @info: array of #SpaPortInputInfo
|
||||
*
|
||||
* Push a buffer id into one or more input ports of @node.
|
||||
*
|
||||
|
|
@ -464,12 +464,12 @@ struct _SpaNode {
|
|||
*/
|
||||
SpaResult (*port_push_input) (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaInputInfo *info);
|
||||
SpaPortInputInfo *info);
|
||||
/**
|
||||
* SpaNode::port_pull_output:
|
||||
* @node: a #SpaNode
|
||||
* @n_info: number of #SpaOutputInfo in @info
|
||||
* @info: array of #SpaOutputInfo
|
||||
* @n_info: number of #SpaPortOutputInfo in @info
|
||||
* @info: array of #SpaPortOutputInfo
|
||||
*
|
||||
* Pull a buffer id from one or more output ports of @node.
|
||||
*
|
||||
|
|
@ -486,13 +486,13 @@ struct _SpaNode {
|
|||
* #SPA_RESULT_NEED_MORE_INPUT when no output can be produced
|
||||
* because more input is needed.
|
||||
*/
|
||||
SpaResult (*port_pull_output) (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaOutputInfo *info);
|
||||
SpaResult (*port_pull_output) (SpaNode *node,
|
||||
unsigned int n_info,
|
||||
SpaPortOutputInfo *info);
|
||||
|
||||
SpaResult (*port_push_event) (SpaNode *node,
|
||||
uint32_t port_id,
|
||||
SpaEvent *event);
|
||||
SpaNodeEvent *event);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ typedef int (*SpaPollNotify) (SpaPollNotifyData *data);
|
|||
* @fds: array of file descriptors to watch
|
||||
* @n_fds: number of elements in @fds
|
||||
* @idle_cb: callback called when there is no other work
|
||||
* @idle_cb: callback called before starting the poll
|
||||
* @idle_cb: callback called after the poll loop
|
||||
* @before_cb: callback called before starting the poll
|
||||
* @after_cb: callback called after the poll loop
|
||||
* @user_data: user data pass to callbacks
|
||||
*/
|
||||
typedef struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue