mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-08 13:30:08 -05:00
Add suport for clocks
Add a clock interface to get raw clocking information from an element Make events and commands to request and configure clock updates. Add support for passing events and commands in control Set the size of the buffers in pinossrc
This commit is contained in:
parent
a5f21576fa
commit
0b380dd43e
20 changed files with 712 additions and 268 deletions
122
spa/include/spa/clock.h
Normal file
122
spa/include/spa/clock.h
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/* 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_CLOCK_H__
|
||||
#define __SPA_CLOCK_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _SpaClock SpaClock;
|
||||
|
||||
/**
|
||||
* SpaClockState:
|
||||
* @SPA_CLOCK_STATE_STOPPED: the clock is stopped
|
||||
* @SPA_CLOCK_STATE_PAUSED: the clock is paused
|
||||
* @SPA_CLOCK_STATE_RUNNING: the clock is running
|
||||
*/
|
||||
typedef enum {
|
||||
SPA_CLOCK_STATE_STOPPED,
|
||||
SPA_CLOCK_STATE_PAUSED,
|
||||
SPA_CLOCK_STATE_RUNNING,
|
||||
} SpaClockState;
|
||||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/plugin.h>
|
||||
#include <spa/props.h>
|
||||
|
||||
#define SPA_INTERFACE_ID_CLOCK 1
|
||||
#define SPA_INTERFACE_ID_CLOCK_NAME "Clock interface"
|
||||
#define SPA_INTERFACE_ID_CLOCK_DESCRIPTION "Clock interface"
|
||||
|
||||
/**
|
||||
* SpaClock:
|
||||
*
|
||||
* The main processing clocks.
|
||||
*/
|
||||
struct _SpaClock {
|
||||
/* pointer to the handle owning this interface */
|
||||
SpaHandle *handle;
|
||||
/* the total size of this clock. This can be used to expand this
|
||||
* structure in the future */
|
||||
size_t size;
|
||||
/**
|
||||
* SpaClock::state:
|
||||
*
|
||||
* The current state of the clock
|
||||
*/
|
||||
SpaClockState state;
|
||||
/**
|
||||
* SpaClock::get_props:
|
||||
* @clock: a #SpaClock
|
||||
* @props: a location for a #SpaProps pointer
|
||||
*
|
||||
* Get the configurable properties of @clock.
|
||||
*
|
||||
* The returned @props is a snapshot of the current configuration and
|
||||
* can be modified. The modifications will take effect after a call
|
||||
* to SpaClock::set_props.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when clock or props are %NULL
|
||||
* #SPA_RESULT_NOT_IMPLEMENTED when there are no properties
|
||||
* implemented on @clock
|
||||
*/
|
||||
SpaResult (*get_props) (SpaClock *clock,
|
||||
SpaProps **props);
|
||||
/**
|
||||
* SpaClock::set_props:
|
||||
* @clock: a #SpaClock
|
||||
* @props: a #SpaProps
|
||||
*
|
||||
* Set the configurable properties in @clock.
|
||||
*
|
||||
* Usually, @props will be obtained from SpaClock::get_props and then
|
||||
* modified but it is also possible to set another #SpaProps object
|
||||
* as long as its keys and types match those of SpaProps::get_props.
|
||||
*
|
||||
* Properties with keys that are not known are ignored.
|
||||
*
|
||||
* If @props is NULL, all the properties are reset to their defaults.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when clock is %NULL
|
||||
* #SPA_RESULT_NOT_IMPLEMENTED when no properties can be
|
||||
* modified on @clock.
|
||||
* #SPA_RESULT_WRONG_PROPERTY_TYPE when a property has the wrong
|
||||
* type.
|
||||
*/
|
||||
SpaResult (*set_props) (SpaClock *clock,
|
||||
const SpaProps *props);
|
||||
|
||||
SpaResult (*get_time) (SpaClock *clock,
|
||||
int64_t *clock_time,
|
||||
int64_t *monotonic_time);
|
||||
};
|
||||
|
||||
#define spa_clock_get_props(n,...) (n)->get_props((n),__VA_ARGS__)
|
||||
#define spa_clock_set_props(n,...) (n)->set_props((n),__VA_ARGS__)
|
||||
#define spa_clock_get_time(n,...) (n)->get_time((n),__VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_CLOCK_H__ */
|
||||
|
|
@ -60,12 +60,7 @@ typedef enum {
|
|||
SPA_CONTROL_CMD_PORT_UPDATE = 2,
|
||||
SPA_CONTROL_CMD_PORT_REMOVED = 3,
|
||||
|
||||
SPA_CONTROL_CMD_STATE_CHANGE = 4,
|
||||
|
||||
SPA_CONTROL_CMD_PORT_STATUS_CHANGE = 5,
|
||||
|
||||
SPA_CONTROL_CMD_NEED_INPUT = 6,
|
||||
SPA_CONTROL_CMD_HAVE_OUTPUT = 7,
|
||||
SPA_CONTROL_CMD_PORT_STATUS_CHANGE = 4,
|
||||
|
||||
/* server to client */
|
||||
SPA_CONTROL_CMD_ADD_PORT = 32,
|
||||
|
|
@ -74,8 +69,7 @@ typedef enum {
|
|||
SPA_CONTROL_CMD_SET_FORMAT = 34,
|
||||
SPA_CONTROL_CMD_SET_PROPERTY = 35,
|
||||
|
||||
SPA_CONTROL_CMD_START = 36,
|
||||
SPA_CONTROL_CMD_PAUSE = 37,
|
||||
SPA_CONTROL_CMD_NODE_COMMAND = 36,
|
||||
|
||||
/* both */
|
||||
SPA_CONTROL_CMD_ADD_MEM = 64,
|
||||
|
|
@ -83,25 +77,28 @@ typedef enum {
|
|||
|
||||
SPA_CONTROL_CMD_USE_BUFFERS = 66,
|
||||
SPA_CONTROL_CMD_PROCESS_BUFFER = 67,
|
||||
SPA_CONTROL_CMD_REUSE_BUFFER = 68,
|
||||
|
||||
SPA_CONTROL_CMD_NODE_EVENT = 68,
|
||||
} SpaControlCmd;
|
||||
|
||||
/* SPA_CONTROL_CMD_NODE_UPDATE */
|
||||
typedef struct {
|
||||
#define SPA_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS (1 << 0)
|
||||
#define SPA_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS (1 << 1)
|
||||
#define SPA_CONTROL_CMD_NODE_UPDATE_PROPS (1 << 2)
|
||||
uint32_t change_mask;
|
||||
unsigned int max_input_ports;
|
||||
unsigned int max_output_ports;
|
||||
const SpaProps *props;
|
||||
} SpaControlCmdNodeUpdate;
|
||||
|
||||
#define SPA_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS (1 << 0)
|
||||
#define SPA_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS (1 << 1)
|
||||
#define SPA_CONTROL_CMD_NODE_UPDATE_PROPS (1 << 2)
|
||||
|
||||
/* 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)
|
||||
uint32_t change_mask;
|
||||
unsigned int n_possible_formats;
|
||||
SpaFormat **possible_formats;
|
||||
|
|
@ -109,33 +106,13 @@ typedef struct {
|
|||
const SpaPortInfo *info;
|
||||
} SpaControlCmdPortUpdate;
|
||||
|
||||
#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)
|
||||
|
||||
/* SPA_CONTROL_CMD_PORT_REMOVED */
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaControlCmdPortRemoved;
|
||||
|
||||
/* SPA_CONTROL_CMD_STATE_CHANGE */
|
||||
typedef struct {
|
||||
SpaNodeState state;
|
||||
} SpaControlCmdStateChange;
|
||||
|
||||
/* SPA_CONTROL_CMD_PORT_STATUS_CHANGE */
|
||||
|
||||
/* SPA_CONTROL_CMD_NEED_INPUT */
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaControlCmdNeedInput;
|
||||
|
||||
/* SPA_CONTROL_CMD_HAVE_OUTPUT */
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
} SpaControlCmdHaveOutput;
|
||||
|
||||
|
||||
/* SPA_CONTROL_CMD_ADD_PORT */
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
|
|
@ -161,8 +138,10 @@ typedef struct {
|
|||
void *value;
|
||||
} SpaControlCmdSetProperty;
|
||||
|
||||
/* SPA_CONTROL_CMD_PAUSE */
|
||||
/* SPA_CONTROL_CMD_START */
|
||||
/* SPA_CONTROL_CMD_NODE_COMMAND */
|
||||
typedef struct {
|
||||
SpaNodeCommand *command;
|
||||
} SpaControlCmdNodeCommand;
|
||||
|
||||
/* SPA_CONTROL_CMD_ADD_MEM */
|
||||
typedef struct {
|
||||
|
|
@ -193,12 +172,10 @@ typedef struct {
|
|||
uint32_t buffer_id;
|
||||
} SpaControlCmdProcessBuffer;
|
||||
|
||||
/* SPA_CONTROL_CMD_REUSE_BUFFER */
|
||||
/* SPA_CONTROL_CMD_NODE_EVENT */
|
||||
typedef struct {
|
||||
uint32_t port_id;
|
||||
uint32_t buffer_id;
|
||||
} SpaControlCmdReuseBuffer;
|
||||
|
||||
SpaNodeEvent *event;
|
||||
} SpaControlCmdNodeEvent;
|
||||
|
||||
struct _SpaControlIter {
|
||||
/*< private >*/
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ typedef void (*SpaNotify) (void *data);
|
|||
#define SPA_PTR_TO_UINT32(p) ((uint32_t) ((uintptr_t) (p)))
|
||||
#define SPA_UINT32_TO_PTR(u) ((void*) ((uintptr_t) (u)))
|
||||
|
||||
#define SPA_TIME_INVALID ((uint64_t)-1)
|
||||
#define SPA_IDX_INVALID ((unsigned int)-1)
|
||||
#define SPA_ID_INVALID ((uint32_t)0xffffffff)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ extern "C" {
|
|||
typedef struct _SpaNodeCommand SpaNodeCommand;
|
||||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/clock.h>
|
||||
|
||||
typedef enum {
|
||||
SPA_NODE_COMMAND_INVALID = 0,
|
||||
|
|
@ -35,15 +36,38 @@ typedef enum {
|
|||
SPA_NODE_COMMAND_FLUSH,
|
||||
SPA_NODE_COMMAND_DRAIN,
|
||||
SPA_NODE_COMMAND_MARKER,
|
||||
SPA_NODE_COMMAND_CLOCK_UPDATE
|
||||
} SpaNodeCommandType;
|
||||
|
||||
struct _SpaNodeCommand {
|
||||
SpaNodeCommandType type;
|
||||
uint32_t port_id;
|
||||
void *data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
/**
|
||||
* SpaNodeCommandClockUpdate:
|
||||
* @change_mask: marks which fields are updated
|
||||
* @timestamp: the new timestamp, when @change_mask = 1<<0
|
||||
* @monotonic_time: the new monotonic time associated with @timestamp, when
|
||||
* @change_mask = 1<<0
|
||||
* @offset: the difference between the time when this update was generated
|
||||
* and @monotonic_time
|
||||
* @scale: update to the speed stored as Q16.16, @change_mask = 1<<1
|
||||
* @state: the new clock state, when @change_mask = 1<<2
|
||||
*/
|
||||
typedef struct {
|
||||
#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)
|
||||
uint32_t change_mask;
|
||||
int64_t timestamp;
|
||||
int64_t monotonic_time;
|
||||
int64_t offset;
|
||||
int32_t scale;
|
||||
SpaClockState state;
|
||||
} SpaNodeCommandClockUpdate;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ typedef enum {
|
|||
SPA_NODE_EVENT_TYPE_ERROR,
|
||||
SPA_NODE_EVENT_TYPE_BUFFERING,
|
||||
SPA_NODE_EVENT_TYPE_REQUEST_REFRESH,
|
||||
SPA_NODE_EVENT_TYPE_REQUEST_CLOCK_UPDATE,
|
||||
} SpaNodeEventType;
|
||||
|
||||
struct _SpaNodeEvent {
|
||||
|
|
@ -97,6 +98,15 @@ typedef struct {
|
|||
uint32_t buffer_id;
|
||||
} SpaNodeEventReuseBuffer;
|
||||
|
||||
typedef struct {
|
||||
#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)
|
||||
uint32_t update_mask;
|
||||
int64_t timestamp;
|
||||
int64_t offset;
|
||||
} SpaNodeEventRequestClockUpdate;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue