summaryrefslogtreecommitdiff
path: root/spa
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2019-10-23 13:13:01 +0200
committerWim Taymans <wtaymans@redhat.com>2019-10-23 13:13:01 +0200
commit54f6834de4494deb725e33e436eb820803fe7a05 (patch)
treed157dbdc93452e3978be5a3d3bfcaee80de96614 /spa
parent2ac8be4ac7f693aaf3be7912d20717fd2f185c39 (diff)
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
Diffstat (limited to 'spa')
-rw-r--r--spa/include/spa/node/io.h7
-rw-r--r--spa/include/spa/node/node.h2
-rw-r--r--spa/include/spa/node/utils.h2
-rw-r--r--spa/include/spa/utils/hook.h1
-rw-r--r--spa/tests/meson.build1
-rw-r--r--spa/tests/test-node.c209
6 files changed, 218 insertions, 4 deletions
diff --git a/spa/include/spa/node/io.h b/spa/include/spa/node/io.h
index 14555744..bb8434a7 100644
--- a/spa/include/spa/node/io.h
+++ b/spa/include/spa/node/io.h
@@ -121,8 +121,10 @@ struct spa_io_range {
* since the provider was last started.
*/
struct spa_io_clock {
- uint32_t id; /**< unique clock id, set by application */
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 count; /**< a media specific counter. Can be used to detect
* gaps in the media. It usually represents the amount
@@ -175,7 +177,7 @@ struct spa_io_segment_video {
uint32_t seconds;
uint32_t frames;
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 */
#define SPA_IO_RATE_MATCH_FLAG_ACTIVE (1 << 0)
uint32_t flags; /**< extra flags */
+ uint32_t padding[7];
};
#ifdef __cplusplus
diff --git a/spa/include/spa/node/node.h b/spa/include/spa/node/node.h
index 65273d93..9cba84cc 100644
--- a/spa/include/spa/node/node.h
+++ b/spa/include/spa/node/node.h
@@ -34,7 +34,6 @@ extern "C" {
#include <spa/utils/type.h>
#include <spa/utils/hook.h>
-
/**
* 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/pod/builder.h>
#include <spa/buffer/buffer.h>
#include <spa/node/event.h>
#include <spa/node/command.h>
diff --git a/spa/include/spa/node/utils.h b/spa/include/spa/node/utils.h
index 9506cc3e..237a9fa9 100644
--- a/spa/include/spa/node/utils.h
+++ b/spa/include/spa/node/utils.h
@@ -29,6 +29,8 @@
extern "C" {
#endif
+#include <spa/pod/builder.h>
+
#include <spa/node/node.h>
struct spa_result_node_params_data {
diff --git a/spa/include/spa/utils/hook.h b/spa/include/spa/utils/hook.h
index b1f32890..24bad6fd 100644
--- a/spa/include/spa/utils/hook.h
+++ b/spa/include/spa/utils/hook.h
@@ -29,6 +29,7 @@
extern "C" {
#endif
+#include <spa/utils/defs.h>
#include <spa/utils/list.h>
/** \class spa_hook
diff --git a/spa/tests/meson.build b/spa/tests/meson.build
index 7ab28172..e6f9c68d 100644
--- a/spa/tests/meson.build
+++ b/spa/tests/meson.build
@@ -1,5 +1,6 @@
test_apps = [
'test-buffer',
+ 'test-node',
'test-pod',
'test-utils',
]
diff --git a/spa/tests/test-node.c b/spa/tests/test-node.c
new file mode 100644
index 00000000..c67243e7
--- /dev/null
+++ b/spa/tests/test-node.c
@@ -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;
+}