mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
io: add clock_id to clock
Can be used to determine if we need to slave or not. Add node abi test Fix some headers
This commit is contained in:
parent
2ac8be4ac7
commit
54f6834de4
7 changed files with 219 additions and 4 deletions
|
|
@ -121,8 +121,10 @@ struct spa_io_range {
|
||||||
* since the provider was last started.
|
* since the provider was last started.
|
||||||
*/
|
*/
|
||||||
struct spa_io_clock {
|
struct spa_io_clock {
|
||||||
uint32_t id; /**< unique clock id, set by application */
|
|
||||||
uint32_t flags; /**< clock flags */
|
uint32_t flags; /**< clock flags */
|
||||||
|
uint32_t id; /**< unique clock id, set by application */
|
||||||
|
uint32_t api; /**< api of the clock */
|
||||||
|
uint32_t clock_id; /**< api specific clock id */
|
||||||
uint64_t nsec; /**< time in nanoseconds against monotonic clock */
|
uint64_t nsec; /**< time in nanoseconds against monotonic clock */
|
||||||
uint64_t count; /**< a media specific counter. Can be used to detect
|
uint64_t count; /**< a media specific counter. Can be used to detect
|
||||||
* gaps in the media. It usually represents the amount
|
* gaps in the media. It usually represents the amount
|
||||||
|
|
@ -175,7 +177,7 @@ struct spa_io_segment_video {
|
||||||
uint32_t seconds;
|
uint32_t seconds;
|
||||||
uint32_t frames;
|
uint32_t frames;
|
||||||
uint32_t field_count; /**< 0 for progressive, 1 and 2 for interlaced */
|
uint32_t field_count; /**< 0 for progressive, 1 and 2 for interlaced */
|
||||||
uint32_t padding[17];
|
uint32_t padding[15];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -267,6 +269,7 @@ struct spa_io_rate_match {
|
||||||
double rate; /**< rate for resampler */
|
double rate; /**< rate for resampler */
|
||||||
#define SPA_IO_RATE_MATCH_FLAG_ACTIVE (1 << 0)
|
#define SPA_IO_RATE_MATCH_FLAG_ACTIVE (1 << 0)
|
||||||
uint32_t flags; /**< extra flags */
|
uint32_t flags; /**< extra flags */
|
||||||
|
uint32_t padding[7];
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ extern "C" {
|
||||||
#include <spa/utils/type.h>
|
#include <spa/utils/type.h>
|
||||||
#include <spa/utils/hook.h>
|
#include <spa/utils/hook.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A spa_node is a component that can consume and produce buffers.
|
* A spa_node is a component that can consume and produce buffers.
|
||||||
*/
|
*/
|
||||||
|
|
@ -43,7 +42,6 @@ struct spa_node { struct spa_interface iface; };
|
||||||
|
|
||||||
#include <spa/support/plugin.h>
|
#include <spa/support/plugin.h>
|
||||||
|
|
||||||
#include <spa/pod/builder.h>
|
|
||||||
#include <spa/buffer/buffer.h>
|
#include <spa/buffer/buffer.h>
|
||||||
#include <spa/node/event.h>
|
#include <spa/node/event.h>
|
||||||
#include <spa/node/command.h>
|
#include <spa/node/command.h>
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <spa/pod/builder.h>
|
||||||
|
|
||||||
#include <spa/node/node.h>
|
#include <spa/node/node.h>
|
||||||
|
|
||||||
struct spa_result_node_params_data {
|
struct spa_result_node_params_data {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <spa/utils/defs.h>
|
||||||
#include <spa/utils/list.h>
|
#include <spa/utils/list.h>
|
||||||
|
|
||||||
/** \class spa_hook
|
/** \class spa_hook
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
test_apps = [
|
test_apps = [
|
||||||
'test-buffer',
|
'test-buffer',
|
||||||
|
'test-node',
|
||||||
'test-pod',
|
'test-pod',
|
||||||
'test-utils',
|
'test-utils',
|
||||||
]
|
]
|
||||||
|
|
|
||||||
209
spa/tests/test-node.c
Normal file
209
spa/tests/test-node.c
Normal file
|
|
@ -0,0 +1,209 @@
|
||||||
|
/* Simple Plugin API
|
||||||
|
*
|
||||||
|
* Copyright © 2019 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the next
|
||||||
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <spa/utils/defs.h>
|
||||||
|
#include <spa/node/io.h>
|
||||||
|
#include <spa/node/command.h>
|
||||||
|
#include <spa/node/event.h>
|
||||||
|
|
||||||
|
static void test_io_abi(void)
|
||||||
|
{
|
||||||
|
/* io */
|
||||||
|
spa_assert(SPA_IO_Invalid == 0);
|
||||||
|
spa_assert(SPA_IO_Buffers == 1);
|
||||||
|
spa_assert(SPA_IO_Range == 2);
|
||||||
|
spa_assert(SPA_IO_Clock == 3);
|
||||||
|
spa_assert(SPA_IO_Latency == 4);
|
||||||
|
spa_assert(SPA_IO_Control == 5);
|
||||||
|
spa_assert(SPA_IO_Notify == 6);
|
||||||
|
spa_assert(SPA_IO_Position == 7);
|
||||||
|
spa_assert(SPA_IO_RateMatch == 8);
|
||||||
|
spa_assert(SPA_IO_Memory == 9);
|
||||||
|
|
||||||
|
spa_assert(sizeof(struct spa_io_buffers) == 8);
|
||||||
|
spa_assert(sizeof(struct spa_io_memory) == 16);
|
||||||
|
spa_assert(sizeof(struct spa_io_range) == 16);
|
||||||
|
spa_assert(sizeof(struct spa_io_clock) == 80);
|
||||||
|
spa_assert(sizeof(struct spa_io_latency) == 24);
|
||||||
|
spa_assert(sizeof(struct spa_io_sequence) == 16);
|
||||||
|
spa_assert(sizeof(struct spa_io_segment_bar) == 96);
|
||||||
|
spa_assert(sizeof(struct spa_io_segment_video) == 96);
|
||||||
|
spa_assert(sizeof(struct spa_io_segment) == 232);
|
||||||
|
|
||||||
|
/* position state */
|
||||||
|
spa_assert(SPA_IO_POSITION_STATE_STOPPED == 0);
|
||||||
|
spa_assert(SPA_IO_POSITION_STATE_STARTING == 1);
|
||||||
|
spa_assert(SPA_IO_POSITION_STATE_RUNNING == 2);
|
||||||
|
|
||||||
|
spa_assert(sizeof(struct spa_io_position) == 1952);
|
||||||
|
spa_assert(sizeof(struct spa_io_rate_match) == 48);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_command_abi(void)
|
||||||
|
{
|
||||||
|
spa_assert(SPA_NODE_COMMAND_Suspend == 0);
|
||||||
|
spa_assert(SPA_NODE_COMMAND_Pause == 1);
|
||||||
|
spa_assert(SPA_NODE_COMMAND_Start == 2);
|
||||||
|
spa_assert(SPA_NODE_COMMAND_Enable == 3);
|
||||||
|
spa_assert(SPA_NODE_COMMAND_Disable == 4);
|
||||||
|
spa_assert(SPA_NODE_COMMAND_Flush == 5);
|
||||||
|
spa_assert(SPA_NODE_COMMAND_Drain == 6);
|
||||||
|
spa_assert(SPA_NODE_COMMAND_Marker == 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_event_abi(void)
|
||||||
|
{
|
||||||
|
spa_assert(SPA_NODE_EVENT_Error == 0);
|
||||||
|
spa_assert(SPA_NODE_EVENT_Buffering == 1);
|
||||||
|
spa_assert(SPA_NODE_EVENT_RequestRefresh == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TEST_FUNC(a,b,func, id) \
|
||||||
|
do { \
|
||||||
|
off_t diff = SPA_PTRDIFF(&a.func, &a); \
|
||||||
|
a.func = b.func; \
|
||||||
|
spa_assert(diff == SPA_PTRDIFF(&b.func, &b)); \
|
||||||
|
spa_assert(diff == 0 || (diff-1)/sizeof(void*) == id); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
static void test_node_abi(void)
|
||||||
|
{
|
||||||
|
struct spa_node_events e;
|
||||||
|
struct spa_node_callbacks c;
|
||||||
|
struct spa_node_methods m;
|
||||||
|
struct {
|
||||||
|
uint32_t version;
|
||||||
|
void (*info) (void *data, const struct spa_node_info *info);
|
||||||
|
void (*port_info) (void *data,
|
||||||
|
enum spa_direction direction, uint32_t port,
|
||||||
|
const struct spa_port_info *info);
|
||||||
|
void (*result) (void *data, int seq, int res,
|
||||||
|
uint32_t type, const void *result);
|
||||||
|
void (*event) (void *data, const struct spa_event *event);
|
||||||
|
} events = { SPA_VERSION_NODE_EVENTS, };
|
||||||
|
struct {
|
||||||
|
uint32_t version;
|
||||||
|
int (*ready) (void *data, int state);
|
||||||
|
int (*reuse_buffer) (void *data,
|
||||||
|
uint32_t port_id,
|
||||||
|
uint32_t buffer_id);
|
||||||
|
int (*xrun) (void *data, uint64_t trigger, uint64_t delay,
|
||||||
|
struct spa_pod *info);
|
||||||
|
} callbacks = { SPA_VERSION_NODE_CALLBACKS, };
|
||||||
|
struct {
|
||||||
|
uint32_t version;
|
||||||
|
int (*add_listener) (void *object,
|
||||||
|
struct spa_hook *listener,
|
||||||
|
const struct spa_node_events *events,
|
||||||
|
void *data);
|
||||||
|
int (*set_callbacks) (void *object,
|
||||||
|
const struct spa_node_callbacks *callbacks,
|
||||||
|
void *data);
|
||||||
|
int (*sync) (void *object, int seq);
|
||||||
|
int (*enum_params) (void *object, int seq,
|
||||||
|
uint32_t id, uint32_t start, uint32_t max,
|
||||||
|
const struct spa_pod *filter);
|
||||||
|
int (*set_param) (void *object,
|
||||||
|
uint32_t id, uint32_t flags,
|
||||||
|
const struct spa_pod *param);
|
||||||
|
int (*set_io) (void *object,
|
||||||
|
uint32_t id, void *data, size_t size);
|
||||||
|
int (*send_command) (void *object, const struct spa_command *command);
|
||||||
|
int (*add_port) (void *object,
|
||||||
|
enum spa_direction direction, uint32_t port_id,
|
||||||
|
const struct spa_dict *props);
|
||||||
|
int (*remove_port) (void *object,
|
||||||
|
enum spa_direction direction, uint32_t port_id);
|
||||||
|
int (*port_enum_params) (void *object, int seq,
|
||||||
|
enum spa_direction direction, uint32_t port_id,
|
||||||
|
uint32_t id, uint32_t start, uint32_t max,
|
||||||
|
const struct spa_pod *filter);
|
||||||
|
int (*port_set_param) (void *object,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id,
|
||||||
|
uint32_t id, uint32_t flags,
|
||||||
|
const struct spa_pod *param);
|
||||||
|
int (*port_use_buffers) (void *object,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id,
|
||||||
|
uint32_t flags,
|
||||||
|
struct spa_buffer **buffers,
|
||||||
|
uint32_t n_buffers);
|
||||||
|
int (*port_set_io) (void *object,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id,
|
||||||
|
uint32_t id,
|
||||||
|
void *data, size_t size);
|
||||||
|
int (*port_reuse_buffer) (void *object, uint32_t port_id, uint32_t buffer_id);
|
||||||
|
int (*process) (void *object);
|
||||||
|
} methods = { SPA_VERSION_NODE_METHODS, 0 };
|
||||||
|
|
||||||
|
TEST_FUNC(e, events, version, 0);
|
||||||
|
TEST_FUNC(e, events, info, SPA_NODE_EVENT_INFO);
|
||||||
|
TEST_FUNC(e, events, port_info, SPA_NODE_EVENT_PORT_INFO);
|
||||||
|
TEST_FUNC(e, events, result, SPA_NODE_EVENT_RESULT);
|
||||||
|
TEST_FUNC(e, events, event, SPA_NODE_EVENT_EVENT);
|
||||||
|
spa_assert(SPA_NODE_EVENT_NUM == 4);
|
||||||
|
spa_assert(sizeof(e) == sizeof(events));
|
||||||
|
|
||||||
|
TEST_FUNC(c, callbacks, version, 0);
|
||||||
|
TEST_FUNC(c, callbacks, ready, SPA_NODE_CALLBACK_READY);
|
||||||
|
TEST_FUNC(c, callbacks, reuse_buffer, SPA_NODE_CALLBACK_REUSE_BUFFER);
|
||||||
|
TEST_FUNC(c, callbacks, xrun, SPA_NODE_CALLBACK_XRUN);
|
||||||
|
spa_assert(SPA_NODE_CALLBACK_NUM == 3);
|
||||||
|
spa_assert(sizeof(c) == sizeof(callbacks));
|
||||||
|
|
||||||
|
TEST_FUNC(m, methods, version, 0);
|
||||||
|
TEST_FUNC(m, methods, add_listener, SPA_NODE_METHOD_ADD_LISTENER);
|
||||||
|
TEST_FUNC(m, methods, set_callbacks, SPA_NODE_METHOD_SET_CALLBACKS);
|
||||||
|
TEST_FUNC(m, methods, sync, SPA_NODE_METHOD_SYNC);
|
||||||
|
TEST_FUNC(m, methods, enum_params, SPA_NODE_METHOD_ENUM_PARAMS);
|
||||||
|
TEST_FUNC(m, methods, set_param, SPA_NODE_METHOD_SET_PARAM);
|
||||||
|
TEST_FUNC(m, methods, set_io, SPA_NODE_METHOD_SET_IO);
|
||||||
|
TEST_FUNC(m, methods, send_command, SPA_NODE_METHOD_SEND_COMMAND);
|
||||||
|
TEST_FUNC(m, methods, add_port, SPA_NODE_METHOD_ADD_PORT);
|
||||||
|
TEST_FUNC(m, methods, remove_port, SPA_NODE_METHOD_REMOVE_PORT);
|
||||||
|
TEST_FUNC(m, methods, port_enum_params, SPA_NODE_METHOD_PORT_ENUM_PARAMS);
|
||||||
|
TEST_FUNC(m, methods, port_use_buffers, SPA_NODE_METHOD_PORT_USE_BUFFERS);
|
||||||
|
TEST_FUNC(m, methods, port_set_io, SPA_NODE_METHOD_PORT_SET_IO);
|
||||||
|
TEST_FUNC(m, methods, port_reuse_buffer, SPA_NODE_METHOD_PORT_REUSE_BUFFER);
|
||||||
|
TEST_FUNC(m, methods, process, SPA_NODE_METHOD_PROCESS);
|
||||||
|
spa_assert(SPA_NODE_METHOD_NUM == 15);
|
||||||
|
spa_assert(sizeof(m) == sizeof(methods));
|
||||||
|
|
||||||
|
spa_assert(sizeof(struct spa_node_info) == 48);
|
||||||
|
spa_assert(sizeof(struct spa_port_info) == 48);
|
||||||
|
|
||||||
|
spa_assert(sizeof(struct spa_result_node_error) == 8);
|
||||||
|
spa_assert(sizeof(struct spa_result_node_params) == 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
test_io_abi();
|
||||||
|
test_command_abi();
|
||||||
|
test_event_abi();
|
||||||
|
test_node_abi();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -41,6 +41,7 @@ extern "C" {
|
||||||
#include "pipewire/stream.h"
|
#include "pipewire/stream.h"
|
||||||
#include "pipewire/log.h"
|
#include "pipewire/log.h"
|
||||||
|
|
||||||
|
#include <spa/pod/builder.h>
|
||||||
#include <spa/utils/type-info.h>
|
#include <spa/utils/type-info.h>
|
||||||
|
|
||||||
#ifndef spa_debug
|
#ifndef spa_debug
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue