add per type API defines

This commit is contained in:
Wim Taymans 2024-11-21 11:50:12 +01:00
parent b03f2f7afa
commit 31802d4994
85 changed files with 1137 additions and 509 deletions

View file

@ -11,6 +11,14 @@ extern "C" {
#include <spa/buffer/buffer.h> #include <spa/buffer/buffer.h>
#ifndef SPA_API_BUFFER_ALLOC
#ifdef SPA_API_IMPL
#define SPA_API_BUFFER_ALLOC SPA_API_IMPL
#else
#define SPA_API_BUFFER_ALLOC static inline
#endif
#endif
/** /**
* \addtogroup spa_buffer * \addtogroup spa_buffer
* \{ * \{
@ -58,7 +66,7 @@ struct spa_buffer_alloc_info {
* \param data_aligns \a n_datas alignments * \param data_aligns \a n_datas alignments
* \return 0 on success. * \return 0 on success.
* */ * */
SPA_API_IMPL int spa_buffer_alloc_fill_info(struct spa_buffer_alloc_info *info, SPA_API_BUFFER_ALLOC int spa_buffer_alloc_fill_info(struct spa_buffer_alloc_info *info,
uint32_t n_metas, struct spa_meta metas[], uint32_t n_metas, struct spa_meta metas[],
uint32_t n_datas, struct spa_data datas[], uint32_t n_datas, struct spa_data datas[],
uint32_t data_aligns[]) uint32_t data_aligns[])
@ -179,7 +187,7 @@ SPA_API_IMPL int spa_buffer_alloc_fill_info(struct spa_buffer_alloc_info *info,
* \param data_mem memory to hold the meta, chunk and memory * \param data_mem memory to hold the meta, chunk and memory
* \return a struct \ref spa_buffer in \a skel_mem * \return a struct \ref spa_buffer in \a skel_mem
*/ */
SPA_API_IMPL struct spa_buffer * SPA_API_BUFFER_ALLOC struct spa_buffer *
spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info, spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
void *skel_mem, void *data_mem) void *skel_mem, void *data_mem)
{ {
@ -257,7 +265,7 @@ spa_buffer_alloc_layout(struct spa_buffer_alloc_info *info,
* \return 0 on success. * \return 0 on success.
* *
*/ */
SPA_API_IMPL int SPA_API_BUFFER_ALLOC int
spa_buffer_alloc_layout_array(struct spa_buffer_alloc_info *info, spa_buffer_alloc_layout_array(struct spa_buffer_alloc_info *info,
uint32_t n_buffers, struct spa_buffer *buffers[], uint32_t n_buffers, struct spa_buffer *buffers[],
void *skel_mem, void *data_mem) void *skel_mem, void *data_mem)
@ -292,7 +300,7 @@ spa_buffer_alloc_layout_array(struct spa_buffer_alloc_info *info,
* allocation failed. * allocation failed.
* *
*/ */
SPA_API_IMPL struct spa_buffer ** SPA_API_BUFFER_ALLOC struct spa_buffer **
spa_buffer_alloc_array(uint32_t n_buffers, uint32_t flags, spa_buffer_alloc_array(uint32_t n_buffers, uint32_t flags,
uint32_t n_metas, struct spa_meta metas[], uint32_t n_metas, struct spa_meta metas[],
uint32_t n_datas, struct spa_data datas[], uint32_t n_datas, struct spa_data datas[],

View file

@ -12,6 +12,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#include <spa/buffer/meta.h> #include <spa/buffer/meta.h>
#ifndef SPA_API_BUFFER
#ifdef SPA_API_IMPL
#define SPA_API_BUFFER SPA_API_IMPL
#else
#define SPA_API_BUFFER static inline
#endif
#endif
/** \defgroup spa_buffer Buffers /** \defgroup spa_buffer Buffers
* *
* Buffers describe the data and metadata that is exchanged between * Buffers describe the data and metadata that is exchanged between
@ -91,7 +99,7 @@ struct spa_buffer {
}; };
/** Find metadata in a buffer */ /** Find metadata in a buffer */
SPA_API_IMPL struct spa_meta *spa_buffer_find_meta(const struct spa_buffer *b, uint32_t type) SPA_API_BUFFER struct spa_meta *spa_buffer_find_meta(const struct spa_buffer *b, uint32_t type)
{ {
uint32_t i; uint32_t i;
@ -102,7 +110,7 @@ SPA_API_IMPL struct spa_meta *spa_buffer_find_meta(const struct spa_buffer *b, u
return NULL; return NULL;
} }
SPA_API_IMPL void *spa_buffer_find_meta_data(const struct spa_buffer *b, uint32_t type, size_t size) SPA_API_BUFFER void *spa_buffer_find_meta_data(const struct spa_buffer *b, uint32_t type, size_t size)
{ {
struct spa_meta *m; struct spa_meta *m;
if ((m = spa_buffer_find_meta(b, type)) && m->size >= size) if ((m = spa_buffer_find_meta(b, type)) && m->size >= size)

View file

@ -12,6 +12,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#include <spa/pod/pod.h> #include <spa/pod/pod.h>
#ifndef SPA_API_META
#ifdef SPA_API_IMPL
#define SPA_API_META SPA_API_IMPL
#else
#define SPA_API_META static inline
#endif
#endif
/** /**
* \addtogroup spa_buffer * \addtogroup spa_buffer
* \{ * \{
@ -46,11 +54,11 @@ struct spa_meta {
void *data; /**< pointer to metadata */ void *data; /**< pointer to metadata */
}; };
SPA_API_IMPL void *spa_meta_first(const struct spa_meta *m) { SPA_API_META void *spa_meta_first(const struct spa_meta *m) {
return m->data; return m->data;
} }
#define spa_meta_first spa_meta_first #define spa_meta_first spa_meta_first
SPA_API_IMPL void *spa_meta_end(const struct spa_meta *m) { SPA_API_META void *spa_meta_end(const struct spa_meta *m) {
return SPA_PTROFF(m->data,m->size,void); return SPA_PTROFF(m->data,m->size,void);
} }
#define spa_meta_end spa_meta_end #define spa_meta_end spa_meta_end
@ -80,7 +88,7 @@ struct spa_meta_region {
struct spa_region region; struct spa_region region;
}; };
SPA_API_IMPL bool spa_meta_region_is_valid(const struct spa_meta_region *m) { SPA_API_META bool spa_meta_region_is_valid(const struct spa_meta_region *m) {
return m->region.size.width != 0 && m->region.size.height != 0; return m->region.size.width != 0 && m->region.size.height != 0;
} }
#define spa_meta_region_is_valid spa_meta_region_is_valid #define spa_meta_region_is_valid spa_meta_region_is_valid

View file

@ -13,12 +13,19 @@ extern "C" {
#include <errno.h> #include <errno.h>
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#ifndef SPA_API_CONTROL_UMP_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_CONTROL_UMP_UTILS SPA_API_IMPL
#else
#define SPA_API_CONTROL_UMP_UTILS static inline
#endif
#endif
/** /**
* \addtogroup spa_control * \addtogroup spa_control
* \{ * \{
*/ */
SPA_API_IMPL size_t spa_ump_message_size(uint8_t message_type) SPA_API_CONTROL_UMP_UTILS size_t spa_ump_message_size(uint8_t message_type)
{ {
static const uint32_t ump_sizes[] = { static const uint32_t ump_sizes[] = {
[0x0] = 1, /* Utility messages */ [0x0] = 1, /* Utility messages */
@ -41,7 +48,7 @@ SPA_API_IMPL size_t spa_ump_message_size(uint8_t message_type)
return ump_sizes[message_type & 0xf]; return ump_sizes[message_type & 0xf];
} }
SPA_API_IMPL int spa_ump_to_midi(uint32_t *ump, size_t ump_size, SPA_API_CONTROL_UMP_UTILS int spa_ump_to_midi(uint32_t *ump, size_t ump_size,
uint8_t *midi, size_t midi_maxsize) uint8_t *midi, size_t midi_maxsize)
{ {
int size = 0; int size = 0;
@ -102,7 +109,7 @@ SPA_API_IMPL int spa_ump_to_midi(uint32_t *ump, size_t ump_size,
return size; return size;
} }
SPA_API_IMPL int spa_ump_from_midi(uint8_t **midi, size_t *midi_size, SPA_API_CONTROL_UMP_UTILS int spa_ump_from_midi(uint8_t **midi, size_t *midi_size,
uint32_t *ump, size_t ump_maxsize, uint8_t group, uint64_t *state) uint32_t *ump, size_t ump_maxsize, uint8_t group, uint64_t *state)
{ {
int size = 0; int size = 0;

View file

@ -23,7 +23,15 @@ extern "C" {
#include <spa/debug/types.h> #include <spa/debug/types.h>
#include <spa/buffer/type-info.h> #include <spa/buffer/type-info.h>
SPA_API_IMPL int spa_debugc_buffer(struct spa_debug_context *ctx, int indent, const struct spa_buffer *buffer) #ifndef SPA_API_DEBUG_BUFFER
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_BUFFER SPA_API_IMPL
#else
#define SPA_API_DEBUG_BUFFER static inline
#endif
#endif
SPA_API_DEBUG_BUFFER int spa_debugc_buffer(struct spa_debug_context *ctx, int indent, const struct spa_buffer *buffer)
{ {
uint32_t i; uint32_t i;
@ -98,7 +106,7 @@ SPA_API_IMPL int spa_debugc_buffer(struct spa_debug_context *ctx, int indent, co
return 0; return 0;
} }
SPA_API_IMPL int spa_debug_buffer(int indent, const struct spa_buffer *buffer) SPA_API_DEBUG_BUFFER int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
{ {
return spa_debugc_buffer(NULL, indent, buffer); return spa_debugc_buffer(NULL, indent, buffer);
} }

View file

@ -26,13 +26,22 @@ extern "C" {
#define spa_debug(_fmt,...) spa_debugn(_fmt"\n", ## __VA_ARGS__) #define spa_debug(_fmt,...) spa_debugn(_fmt"\n", ## __VA_ARGS__)
#endif #endif
#ifndef SPA_API_DEBUG_CONTEXT
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_CONTEXT SPA_API_IMPL
#else
#define SPA_API_DEBUG_CONTEXT static inline
#endif
#endif
struct spa_debug_context { struct spa_debug_context {
void (*log) (struct spa_debug_context *ctx, const char *fmt, ...) SPA_PRINTF_FUNC(2, 3); void (*log) (struct spa_debug_context *ctx, const char *fmt, ...) SPA_PRINTF_FUNC(2, 3);
}; };
#define spa_debugc(_c,_fmt,...) (_c)?((_c)->log((_c),_fmt, ## __VA_ARGS__)):(void)spa_debug(_fmt, ## __VA_ARGS__) #define spa_debugc(_c,_fmt,...) (_c)?((_c)->log((_c),_fmt, ## __VA_ARGS__)):(void)spa_debug(_fmt, ## __VA_ARGS__)
SPA_API_IMPL void spa_debugc_error_location(struct spa_debug_context *c, SPA_API_DEBUG_CONTEXT void spa_debugc_error_location(struct spa_debug_context *c,
struct spa_error_location *loc) struct spa_error_location *loc)
{ {
int i, skip = loc->col > 80 ? loc->col - 40 : 0, lc = loc->col-skip-1; int i, skip = loc->col > 80 ? loc->col - 40 : 0, lc = loc->col-skip-1;

View file

@ -17,7 +17,15 @@ extern "C" {
#include <spa/debug/context.h> #include <spa/debug/context.h>
#include <spa/utils/dict.h> #include <spa/utils/dict.h>
SPA_API_IMPL int spa_debugc_dict(struct spa_debug_context *ctx, int indent, const struct spa_dict *dict) #ifndef SPA_API_DEBUG_DICT
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_DICT SPA_API_IMPL
#else
#define SPA_API_DEBUG_DICT static inline
#endif
#endif
SPA_API_DEBUG_DICT int spa_debugc_dict(struct spa_debug_context *ctx, int indent, const struct spa_dict *dict)
{ {
const struct spa_dict_item *item; const struct spa_dict_item *item;
spa_debugc(ctx, "%*sflags:%08x n_items:%d", indent, "", dict->flags, dict->n_items); spa_debugc(ctx, "%*sflags:%08x n_items:%d", indent, "", dict->flags, dict->n_items);
@ -27,7 +35,7 @@ SPA_API_IMPL int spa_debugc_dict(struct spa_debug_context *ctx, int indent, cons
return 0; return 0;
} }
SPA_API_IMPL int spa_debug_dict(int indent, const struct spa_dict *dict) SPA_API_DEBUG_DICT int spa_debug_dict(int indent, const struct spa_dict *dict)
{ {
return spa_debugc_dict(NULL, indent, dict); return spa_debugc_dict(NULL, indent, dict);
} }

View file

@ -26,13 +26,21 @@ extern "C" {
* \{ * \{
*/ */
#ifndef SPA_API_DEBUG_FILE
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_FILE SPA_API_IMPL
#else
#define SPA_API_DEBUG_FILE static inline
#endif
#endif
struct spa_debug_file_ctx { struct spa_debug_file_ctx {
struct spa_debug_context ctx; struct spa_debug_context ctx;
FILE *f; FILE *f;
}; };
SPA_PRINTF_FUNC(2,3) SPA_PRINTF_FUNC(2,3)
SPA_API_IMPL void spa_debug_file_log(struct spa_debug_context *ctx, const char *fmt, ...) SPA_API_DEBUG_FILE void spa_debug_file_log(struct spa_debug_context *ctx, const char *fmt, ...)
{ {
struct spa_debug_file_ctx *c = SPA_CONTAINER_OF(ctx, struct spa_debug_file_ctx, ctx); struct spa_debug_file_ctx *c = SPA_CONTAINER_OF(ctx, struct spa_debug_file_ctx, ctx);
va_list args; va_list args;

View file

@ -21,7 +21,16 @@ extern "C" {
#include <spa/param/type-info.h> #include <spa/param/type-info.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_DEBUG_FORMAT
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_FORMAT SPA_API_IMPL
#else
#define SPA_API_DEBUG_FORMAT static inline
#endif
#endif
SPA_API_DEBUG_FORMAT int
spa_debug_strbuf_format_value(struct spa_strbuf *buffer, const struct spa_type_info *info, spa_debug_strbuf_format_value(struct spa_strbuf *buffer, const struct spa_type_info *info,
uint32_t type, void *body, uint32_t size) uint32_t type, void *body, uint32_t size)
{ {
@ -96,7 +105,7 @@ spa_debug_strbuf_format_value(struct spa_strbuf *buffer, const struct spa_type_i
return 0; return 0;
} }
SPA_API_IMPL int SPA_API_DEBUG_FORMAT int
spa_debug_format_value(const struct spa_type_info *info, spa_debug_format_value(const struct spa_type_info *info,
uint32_t type, void *body, uint32_t size) uint32_t type, void *body, uint32_t size)
{ {
@ -108,7 +117,7 @@ spa_debug_format_value(const struct spa_type_info *info,
return 0; return 0;
} }
SPA_API_IMPL int spa_debugc_format(struct spa_debug_context *ctx, int indent, SPA_API_DEBUG_FORMAT int spa_debugc_format(struct spa_debug_context *ctx, int indent,
const struct spa_type_info *info, const struct spa_pod *format) const struct spa_type_info *info, const struct spa_pod *format)
{ {
const char *media_type; const char *media_type;
@ -198,7 +207,7 @@ SPA_API_IMPL int spa_debugc_format(struct spa_debug_context *ctx, int indent,
return 0; return 0;
} }
SPA_API_IMPL int spa_debug_format(int indent, SPA_API_DEBUG_FORMAT int spa_debug_format(int indent,
const struct spa_type_info *info, const struct spa_pod *format) const struct spa_type_info *info, const struct spa_pod *format)
{ {
return spa_debugc_format(NULL, indent, info, format); return spa_debugc_format(NULL, indent, info, format);

View file

@ -20,6 +20,14 @@ extern "C" {
#include <spa/debug/mem.h> #include <spa/debug/mem.h>
#include <spa/debug/pod.h> #include <spa/debug/pod.h>
#ifndef SPA_API_DEBUG_LOG
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_LOG SPA_API_IMPL
#else
#define SPA_API_DEBUG_LOG static inline
#endif
#endif
/** /**
* \addtogroup spa_debug * \addtogroup spa_debug
* \{ * \{
@ -36,7 +44,7 @@ struct spa_debug_log_ctx {
}; };
SPA_PRINTF_FUNC(2,3) SPA_PRINTF_FUNC(2,3)
SPA_API_IMPL void spa_debug_log_log(struct spa_debug_context *ctx, const char *fmt, ...) SPA_API_DEBUG_LOG void spa_debug_log_log(struct spa_debug_context *ctx, const char *fmt, ...)
{ {
struct spa_debug_log_ctx *c = SPA_CONTAINER_OF(ctx, struct spa_debug_log_ctx, ctx); struct spa_debug_log_ctx *c = SPA_CONTAINER_OF(ctx, struct spa_debug_log_ctx, ctx);
va_list args; va_list args;

View file

@ -18,7 +18,15 @@ extern "C" {
#include <spa/debug/context.h> #include <spa/debug/context.h>
SPA_API_IMPL int spa_debugc_mem(struct spa_debug_context *ctx, int indent, const void *data, size_t size) #ifndef SPA_API_DEBUG_MEM
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_MEM SPA_API_IMPL
#else
#define SPA_API_DEBUG_MEM static inline
#endif
#endif
SPA_API_DEBUG_MEM int spa_debugc_mem(struct spa_debug_context *ctx, int indent, const void *data, size_t size)
{ {
const uint8_t *t = (const uint8_t*)data; const uint8_t *t = (const uint8_t*)data;
char buffer[512]; char buffer[512];
@ -36,7 +44,7 @@ SPA_API_IMPL int spa_debugc_mem(struct spa_debug_context *ctx, int indent, const
return 0; return 0;
} }
SPA_API_IMPL int spa_debug_mem(int indent, const void *data, size_t size) SPA_API_DEBUG_MEM int spa_debug_mem(int indent, const void *data, size_t size)
{ {
return spa_debugc_mem(NULL, indent, data, size); return spa_debugc_mem(NULL, indent, data, size);
} }

View file

@ -18,7 +18,15 @@ extern "C" {
#include <spa/debug/context.h> #include <spa/debug/context.h>
#include <spa/debug/dict.h> #include <spa/debug/dict.h>
SPA_API_IMPL int spa_debugc_port_info(struct spa_debug_context *ctx, int indent, const struct spa_port_info *info) #ifndef SPA_API_DEBUG_NODE
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_NODE SPA_API_IMPL
#else
#define SPA_API_DEBUG_NODE static inline
#endif
#endif
SPA_API_DEBUG_NODE int spa_debugc_port_info(struct spa_debug_context *ctx, int indent, const struct spa_port_info *info)
{ {
spa_debugc(ctx, "%*s" "struct spa_port_info %p:", indent, "", info); spa_debugc(ctx, "%*s" "struct spa_port_info %p:", indent, "", info);
spa_debugc(ctx, "%*s" " flags: \t%08" PRIx64, indent, "", info->flags); spa_debugc(ctx, "%*s" " flags: \t%08" PRIx64, indent, "", info->flags);
@ -31,7 +39,7 @@ SPA_API_IMPL int spa_debugc_port_info(struct spa_debug_context *ctx, int indent,
return 0; return 0;
} }
SPA_API_IMPL int spa_debug_port_info(int indent, const struct spa_port_info *info) SPA_API_DEBUG_NODE int spa_debug_port_info(int indent, const struct spa_port_info *info)
{ {
return spa_debugc_port_info(NULL, indent, info); return spa_debugc_port_info(NULL, indent, info);
} }

View file

@ -20,7 +20,15 @@ extern "C" {
#include <spa/pod/pod.h> #include <spa/pod/pod.h>
#include <spa/pod/iter.h> #include <spa/pod/iter.h>
SPA_API_IMPL int #ifndef SPA_API_DEBUG_POD
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_POD SPA_API_IMPL
#else
#define SPA_API_DEBUG_POD static inline
#endif
#endif
SPA_API_DEBUG_POD int
spa_debugc_pod_value(struct spa_debug_context *ctx, int indent, const struct spa_type_info *info, spa_debugc_pod_value(struct spa_debug_context *ctx, int indent, const struct spa_type_info *info,
uint32_t type, void *body, uint32_t size) uint32_t type, void *body, uint32_t size)
{ {
@ -174,7 +182,7 @@ spa_debugc_pod_value(struct spa_debug_context *ctx, int indent, const struct spa
return 0; return 0;
} }
SPA_API_IMPL int spa_debugc_pod(struct spa_debug_context *ctx, int indent, SPA_API_DEBUG_POD int spa_debugc_pod(struct spa_debug_context *ctx, int indent,
const struct spa_type_info *info, const struct spa_pod *pod) const struct spa_type_info *info, const struct spa_pod *pod)
{ {
return spa_debugc_pod_value(ctx, indent, info ? info : SPA_TYPE_ROOT, return spa_debugc_pod_value(ctx, indent, info ? info : SPA_TYPE_ROOT,
@ -183,14 +191,14 @@ SPA_API_IMPL int spa_debugc_pod(struct spa_debug_context *ctx, int indent,
SPA_POD_BODY_SIZE(pod)); SPA_POD_BODY_SIZE(pod));
} }
SPA_API_IMPL int SPA_API_DEBUG_POD int
spa_debug_pod_value(int indent, const struct spa_type_info *info, spa_debug_pod_value(int indent, const struct spa_type_info *info,
uint32_t type, void *body, uint32_t size) uint32_t type, void *body, uint32_t size)
{ {
return spa_debugc_pod_value(NULL, indent, info, type, body, size); return spa_debugc_pod_value(NULL, indent, info, type, body, size);
} }
SPA_API_IMPL int spa_debug_pod(int indent, SPA_API_DEBUG_POD int spa_debug_pod(int indent,
const struct spa_type_info *info, const struct spa_pod *pod) const struct spa_type_info *info, const struct spa_pod *pod)
{ {
return spa_debugc_pod(NULL, indent, info, pod); return spa_debugc_pod(NULL, indent, info, pod);

View file

@ -18,7 +18,16 @@ extern "C" {
#include <string.h> #include <string.h>
SPA_API_IMPL const struct spa_type_info *spa_debug_type_find(const struct spa_type_info *info, uint32_t type) #ifndef SPA_API_DEBUG_TYPES
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_TYPES SPA_API_IMPL
#else
#define SPA_API_DEBUG_TYPES static inline
#endif
#endif
SPA_API_DEBUG_TYPES const struct spa_type_info *spa_debug_type_find(const struct spa_type_info *info, uint32_t type)
{ {
const struct spa_type_info *res; const struct spa_type_info *res;
@ -37,19 +46,19 @@ SPA_API_IMPL const struct spa_type_info *spa_debug_type_find(const struct spa_ty
return NULL; return NULL;
} }
SPA_API_IMPL const char *spa_debug_type_short_name(const char *name) SPA_API_DEBUG_TYPES const char *spa_debug_type_short_name(const char *name)
{ {
return spa_type_short_name(name); return spa_type_short_name(name);
} }
SPA_API_IMPL const char *spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type) SPA_API_DEBUG_TYPES const char *spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
{ {
if ((info = spa_debug_type_find(info, type)) == NULL) if ((info = spa_debug_type_find(info, type)) == NULL)
return NULL; return NULL;
return info->name; return info->name;
} }
SPA_API_IMPL const char *spa_debug_type_find_short_name(const struct spa_type_info *info, uint32_t type) SPA_API_DEBUG_TYPES const char *spa_debug_type_find_short_name(const struct spa_type_info *info, uint32_t type)
{ {
const char *str; const char *str;
if ((str = spa_debug_type_find_name(info, type)) == NULL) if ((str = spa_debug_type_find_name(info, type)) == NULL)
@ -57,7 +66,7 @@ SPA_API_IMPL const char *spa_debug_type_find_short_name(const struct spa_type_in
return spa_debug_type_short_name(str); return spa_debug_type_short_name(str);
} }
SPA_API_IMPL uint32_t spa_debug_type_find_type(const struct spa_type_info *info, const char *name) SPA_API_DEBUG_TYPES uint32_t spa_debug_type_find_type(const struct spa_type_info *info, const char *name)
{ {
if (info == NULL) if (info == NULL)
info = SPA_TYPE_ROOT; info = SPA_TYPE_ROOT;
@ -73,7 +82,7 @@ SPA_API_IMPL uint32_t spa_debug_type_find_type(const struct spa_type_info *info,
return SPA_ID_INVALID; return SPA_ID_INVALID;
} }
SPA_API_IMPL const struct spa_type_info *spa_debug_type_find_short(const struct spa_type_info *info, const char *name) SPA_API_DEBUG_TYPES const struct spa_type_info *spa_debug_type_find_short(const struct spa_type_info *info, const char *name)
{ {
while (info && info->name) { while (info && info->name) {
if (strcmp(spa_debug_type_short_name(info->name), name) == 0) if (strcmp(spa_debug_type_short_name(info->name), name) == 0)
@ -87,7 +96,7 @@ SPA_API_IMPL const struct spa_type_info *spa_debug_type_find_short(const struct
return NULL; return NULL;
} }
SPA_API_IMPL uint32_t spa_debug_type_find_type_short(const struct spa_type_info *info, const char *name) SPA_API_DEBUG_TYPES uint32_t spa_debug_type_find_type_short(const struct spa_type_info *info, const char *name)
{ {
if ((info = spa_debug_type_find_short(info, name)) == NULL) if ((info = spa_debug_type_find_short(info, name)) == NULL)
return SPA_ID_INVALID; return SPA_ID_INVALID;

View file

@ -15,6 +15,14 @@ extern "C" {
#include <spa/utils/hook.h> #include <spa/utils/hook.h>
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#ifndef SPA_API_FILTER_GRAPH
#ifdef SPA_API_IMPL
#define SPA_API_FILTER_GRAPH SPA_API_IMPL
#else
#define SPA_API_FILTER_GRAPH static inline
#endif
#endif
/** \defgroup spa_filter_graph Filter Graph /** \defgroup spa_filter_graph Filter Graph
* a graph of filters * a graph of filters
*/ */
@ -83,7 +91,7 @@ struct spa_filter_graph_methods {
struct spa_filter_graph_chunk out[], uint32_t n_out); struct spa_filter_graph_chunk out[], uint32_t n_out);
}; };
SPA_API_IMPL int spa_filter_graph_add_listener(struct spa_filter_graph *object, SPA_API_FILTER_GRAPH int spa_filter_graph_add_listener(struct spa_filter_graph *object,
struct spa_hook *listener, struct spa_hook *listener,
const struct spa_filter_graph_events *events, void *data) const struct spa_filter_graph_events *events, void *data)
{ {
@ -92,44 +100,44 @@ SPA_API_IMPL int spa_filter_graph_add_listener(struct spa_filter_graph *object,
events, data); events, data);
} }
SPA_API_IMPL int spa_filter_graph_enum_prop_info(struct spa_filter_graph *object, SPA_API_FILTER_GRAPH int spa_filter_graph_enum_prop_info(struct spa_filter_graph *object,
uint32_t idx, struct spa_pod_builder *b) uint32_t idx, struct spa_pod_builder *b)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, enum_prop_info, 0, idx, b); spa_filter_graph, &object->iface, enum_prop_info, 0, idx, b);
} }
SPA_API_IMPL int spa_filter_graph_get_props(struct spa_filter_graph *object, SPA_API_FILTER_GRAPH int spa_filter_graph_get_props(struct spa_filter_graph *object,
struct spa_pod_builder *b, const struct spa_pod **props) struct spa_pod_builder *b, const struct spa_pod **props)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, get_props, 0, b, props); spa_filter_graph, &object->iface, get_props, 0, b, props);
} }
SPA_API_IMPL int spa_filter_graph_set_props(struct spa_filter_graph *object, SPA_API_FILTER_GRAPH int spa_filter_graph_set_props(struct spa_filter_graph *object,
enum spa_direction direction, const struct spa_pod *props) enum spa_direction direction, const struct spa_pod *props)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, set_props, 0, direction, props); spa_filter_graph, &object->iface, set_props, 0, direction, props);
} }
SPA_API_IMPL int spa_filter_graph_activate(struct spa_filter_graph *object, const struct spa_fraction *rate) SPA_API_FILTER_GRAPH int spa_filter_graph_activate(struct spa_filter_graph *object, const struct spa_fraction *rate)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, activate, 0, rate); spa_filter_graph, &object->iface, activate, 0, rate);
} }
SPA_API_IMPL int spa_filter_graph_deactivate(struct spa_filter_graph *object) SPA_API_FILTER_GRAPH int spa_filter_graph_deactivate(struct spa_filter_graph *object)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, deactivate, 0); spa_filter_graph, &object->iface, deactivate, 0);
} }
SPA_API_IMPL int spa_filter_graph_reset(struct spa_filter_graph *object) SPA_API_FILTER_GRAPH int spa_filter_graph_reset(struct spa_filter_graph *object)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, reset, 0); spa_filter_graph, &object->iface, reset, 0);
} }
SPA_API_IMPL int spa_filter_graph_process(struct spa_filter_graph *object, SPA_API_FILTER_GRAPH int spa_filter_graph_process(struct spa_filter_graph *object,
const struct spa_filter_graph_chunk in[], uint32_t n_in, const struct spa_filter_graph_chunk in[], uint32_t n_in,
struct spa_filter_graph_chunk out[], uint32_t n_out) struct spa_filter_graph_chunk out[], uint32_t n_out)
{ {

View file

@ -25,6 +25,15 @@ extern "C" {
#include <spa/node/node.h> #include <spa/node/node.h>
#include <spa/node/io.h> #include <spa/node/io.h>
#ifndef SPA_API_GRAPH
#ifdef SPA_API_IMPL
#define SPA_API_GRAPH SPA_API_IMPL
#else
#define SPA_API_GRAPH static inline
#endif
#endif
#ifndef spa_debug #ifndef spa_debug
#define spa_debug(...) #define spa_debug(...)
#endif #endif
@ -40,7 +49,7 @@ struct spa_graph_state {
int32_t pending; /**< number of pending signals */ int32_t pending; /**< number of pending signals */
}; };
SPA_API_IMPL void spa_graph_state_reset(struct spa_graph_state *state) SPA_API_GRAPH void spa_graph_state_reset(struct spa_graph_state *state)
{ {
state->pending = state->required; state->pending = state->required;
} }
@ -56,7 +65,7 @@ struct spa_graph_link {
#define spa_graph_state_dec(s) (SPA_ATOMIC_DEC(s->pending) == 0) #define spa_graph_state_dec(s) (SPA_ATOMIC_DEC(s->pending) == 0)
SPA_API_IMPL int spa_graph_link_trigger(struct spa_graph_link *link) SPA_API_GRAPH int spa_graph_link_trigger(struct spa_graph_link *link)
{ {
struct spa_graph_state *state = link->state; struct spa_graph_state *state = link->state;
@ -118,7 +127,7 @@ struct spa_graph_port {
struct spa_graph_port *peer; /**< peer */ struct spa_graph_port *peer; /**< peer */
}; };
SPA_API_IMPL int spa_graph_node_trigger(struct spa_graph_node *node) SPA_API_GRAPH int spa_graph_node_trigger(struct spa_graph_node *node)
{ {
struct spa_graph_link *l; struct spa_graph_link *l;
spa_debug("node %p trigger", node); spa_debug("node %p trigger", node);
@ -127,7 +136,7 @@ SPA_API_IMPL int spa_graph_node_trigger(struct spa_graph_node *node)
return 0; return 0;
} }
SPA_API_IMPL int spa_graph_run(struct spa_graph *graph) SPA_API_GRAPH int spa_graph_run(struct spa_graph *graph)
{ {
struct spa_graph_node *n, *t; struct spa_graph_node *n, *t;
struct spa_list pending; struct spa_list pending;
@ -152,27 +161,27 @@ SPA_API_IMPL int spa_graph_run(struct spa_graph *graph)
return 0; return 0;
} }
SPA_API_IMPL int spa_graph_finish(struct spa_graph *graph) SPA_API_GRAPH int spa_graph_finish(struct spa_graph *graph)
{ {
spa_debug("graph %p finish", graph); spa_debug("graph %p finish", graph);
if (graph->parent) if (graph->parent)
return spa_graph_node_trigger(graph->parent); return spa_graph_node_trigger(graph->parent);
return 0; return 0;
} }
SPA_API_IMPL int spa_graph_link_signal_node(void *data) SPA_API_GRAPH int spa_graph_link_signal_node(void *data)
{ {
struct spa_graph_node *node = (struct spa_graph_node *)data; struct spa_graph_node *node = (struct spa_graph_node *)data;
spa_debug("node %p call process", node); spa_debug("node %p call process", node);
return spa_graph_node_process(node); return spa_graph_node_process(node);
} }
SPA_API_IMPL int spa_graph_link_signal_graph(void *data) SPA_API_GRAPH int spa_graph_link_signal_graph(void *data)
{ {
struct spa_graph_node *node = (struct spa_graph_node *)data; struct spa_graph_node *node = (struct spa_graph_node *)data;
return spa_graph_finish(node->graph); return spa_graph_finish(node->graph);
} }
SPA_API_IMPL void spa_graph_init(struct spa_graph *graph, struct spa_graph_state *state) SPA_API_GRAPH void spa_graph_init(struct spa_graph *graph, struct spa_graph_state *state)
{ {
spa_list_init(&graph->nodes); spa_list_init(&graph->nodes);
graph->flags = 0; graph->flags = 0;
@ -180,7 +189,7 @@ SPA_API_IMPL void spa_graph_init(struct spa_graph *graph, struct spa_graph_state
spa_debug("graph %p init state %p", graph, state); spa_debug("graph %p init state %p", graph, state);
} }
SPA_API_IMPL void SPA_API_GRAPH void
spa_graph_link_add(struct spa_graph_node *out, spa_graph_link_add(struct spa_graph_node *out,
struct spa_graph_state *state, struct spa_graph_state *state,
struct spa_graph_link *link) struct spa_graph_link *link)
@ -191,14 +200,14 @@ spa_graph_link_add(struct spa_graph_node *out,
spa_list_append(&out->links, &link->link); spa_list_append(&out->links, &link->link);
} }
SPA_API_IMPL void spa_graph_link_remove(struct spa_graph_link *link) SPA_API_GRAPH void spa_graph_link_remove(struct spa_graph_link *link)
{ {
link->state->required--; link->state->required--;
spa_debug("link %p state %p remove %d", link, link->state, link->state->required); spa_debug("link %p state %p remove %d", link, link->state, link->state->required);
spa_list_remove(&link->link); spa_list_remove(&link->link);
} }
SPA_API_IMPL void SPA_API_GRAPH void
spa_graph_node_init(struct spa_graph_node *node, struct spa_graph_state *state) spa_graph_node_init(struct spa_graph_node *node, struct spa_graph_state *state)
{ {
spa_list_init(&node->ports[SPA_DIRECTION_INPUT]); spa_list_init(&node->ports[SPA_DIRECTION_INPUT]);
@ -215,7 +224,7 @@ spa_graph_node_init(struct spa_graph_node *node, struct spa_graph_state *state)
} }
SPA_API_IMPL int spa_graph_node_impl_sub_process(void *data SPA_UNUSED, struct spa_graph_node *node) SPA_API_GRAPH int spa_graph_node_impl_sub_process(void *data SPA_UNUSED, struct spa_graph_node *node)
{ {
struct spa_graph *graph = node->subgraph; struct spa_graph *graph = node->subgraph;
spa_debug("node %p: sub process %p", node, graph); spa_debug("node %p: sub process %p", node, graph);
@ -227,7 +236,7 @@ static const struct spa_graph_node_callbacks spa_graph_node_sub_impl_default = {
.process = spa_graph_node_impl_sub_process, .process = spa_graph_node_impl_sub_process,
}; };
SPA_API_IMPL void spa_graph_node_set_subgraph(struct spa_graph_node *node, SPA_API_GRAPH void spa_graph_node_set_subgraph(struct spa_graph_node *node,
struct spa_graph *subgraph) struct spa_graph *subgraph)
{ {
node->subgraph = subgraph; node->subgraph = subgraph;
@ -235,7 +244,7 @@ SPA_API_IMPL void spa_graph_node_set_subgraph(struct spa_graph_node *node,
spa_debug("node %p set subgraph %p", node, subgraph); spa_debug("node %p set subgraph %p", node, subgraph);
} }
SPA_API_IMPL void SPA_API_GRAPH void
spa_graph_node_set_callbacks(struct spa_graph_node *node, spa_graph_node_set_callbacks(struct spa_graph_node *node,
const struct spa_graph_node_callbacks *callbacks, const struct spa_graph_node_callbacks *callbacks,
void *data) void *data)
@ -243,7 +252,7 @@ spa_graph_node_set_callbacks(struct spa_graph_node *node,
node->callbacks = SPA_CALLBACKS_INIT(callbacks, data); node->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
} }
SPA_API_IMPL void SPA_API_GRAPH void
spa_graph_node_add(struct spa_graph *graph, spa_graph_node_add(struct spa_graph *graph,
struct spa_graph_node *node) struct spa_graph_node *node)
{ {
@ -255,7 +264,7 @@ spa_graph_node_add(struct spa_graph *graph,
spa_graph_link_add(node, graph->state, &node->graph_link); spa_graph_link_add(node, graph->state, &node->graph_link);
} }
SPA_API_IMPL void spa_graph_node_remove(struct spa_graph_node *node) SPA_API_GRAPH void spa_graph_node_remove(struct spa_graph_node *node)
{ {
spa_debug("node %p remove from graph %p, state %p required %d", spa_debug("node %p remove from graph %p, state %p required %d",
node, node->graph, node->state, node->state->required); node, node->graph, node->state, node->state->required);
@ -265,7 +274,7 @@ SPA_API_IMPL void spa_graph_node_remove(struct spa_graph_node *node)
} }
SPA_API_IMPL void SPA_API_GRAPH void
spa_graph_port_init(struct spa_graph_port *port, spa_graph_port_init(struct spa_graph_port *port,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
@ -277,7 +286,7 @@ spa_graph_port_init(struct spa_graph_port *port,
port->flags = flags; port->flags = flags;
} }
SPA_API_IMPL void SPA_API_GRAPH void
spa_graph_port_add(struct spa_graph_node *node, spa_graph_port_add(struct spa_graph_node *node,
struct spa_graph_port *port) struct spa_graph_port *port)
{ {
@ -286,13 +295,13 @@ spa_graph_port_add(struct spa_graph_node *node,
spa_list_append(&node->ports[port->direction], &port->link); spa_list_append(&node->ports[port->direction], &port->link);
} }
SPA_API_IMPL void spa_graph_port_remove(struct spa_graph_port *port) SPA_API_GRAPH void spa_graph_port_remove(struct spa_graph_port *port)
{ {
spa_debug("port %p remove", port); spa_debug("port %p remove", port);
spa_list_remove(&port->link); spa_list_remove(&port->link);
} }
SPA_API_IMPL void SPA_API_GRAPH void
spa_graph_port_link(struct spa_graph_port *out, struct spa_graph_port *in) spa_graph_port_link(struct spa_graph_port *out, struct spa_graph_port *in)
{ {
spa_debug("port %p link to %p %p %p", out, in, in->node, in->node->state); spa_debug("port %p link to %p %p %p", out, in, in->node, in->node->state);
@ -300,7 +309,7 @@ spa_graph_port_link(struct spa_graph_port *out, struct spa_graph_port *in)
in->peer = out; in->peer = out;
} }
SPA_API_IMPL void SPA_API_GRAPH void
spa_graph_port_unlink(struct spa_graph_port *port) spa_graph_port_unlink(struct spa_graph_port *port)
{ {
spa_debug("port %p unlink from %p", port, port->peer); spa_debug("port %p unlink from %p", port, port->peer);
@ -310,7 +319,7 @@ spa_graph_port_unlink(struct spa_graph_port *port)
} }
} }
SPA_API_IMPL int spa_graph_node_impl_process(void *data, struct spa_graph_node *node) SPA_API_GRAPH int spa_graph_node_impl_process(void *data, struct spa_graph_node *node)
{ {
struct spa_node *n = (struct spa_node *)data; struct spa_node *n = (struct spa_node *)data;
struct spa_graph_state *state = node->state; struct spa_graph_state *state = node->state;
@ -322,7 +331,7 @@ SPA_API_IMPL int spa_graph_node_impl_process(void *data, struct spa_graph_node *
return state->status; return state->status;
} }
SPA_API_IMPL int spa_graph_node_impl_reuse_buffer(void *data, struct spa_graph_node *node SPA_UNUSED, SPA_API_GRAPH int spa_graph_node_impl_reuse_buffer(void *data, struct spa_graph_node *node SPA_UNUSED,
uint32_t port_id, uint32_t buffer_id) uint32_t port_id, uint32_t buffer_id)
{ {
struct spa_node *n = (struct spa_node *)data; struct spa_node *n = (struct spa_node *)data;

View file

@ -14,6 +14,14 @@
extern "C" { extern "C" {
#endif #endif
#ifndef SPA_API_AUDIO_AEC
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_AEC SPA_API_IMPL
#else
#define SPA_API_AUDIO_AEC static inline
#endif
#endif
#define SPA_TYPE_INTERFACE_AUDIO_AEC SPA_TYPE_INFO_INTERFACE_BASE "Audio:AEC" #define SPA_TYPE_INTERFACE_AUDIO_AEC SPA_TYPE_INFO_INTERFACE_BASE "Audio:AEC"
#define SPA_VERSION_AUDIO_AEC 1 #define SPA_VERSION_AUDIO_AEC 1
@ -68,7 +76,7 @@ struct spa_audio_aec_methods {
struct spa_audio_info_raw *out_info); struct spa_audio_info_raw *out_info);
}; };
SPA_API_IMPL int spa_audio_aec_add_listener(struct spa_audio_aec *object, SPA_API_AUDIO_AEC int spa_audio_aec_add_listener(struct spa_audio_aec *object,
struct spa_hook *listener, struct spa_hook *listener,
const struct spa_audio_aec_events *events, const struct spa_audio_aec_events *events,
void *data) void *data)
@ -77,52 +85,52 @@ SPA_API_IMPL int spa_audio_aec_add_listener(struct spa_audio_aec *object,
spa_audio_aec, &object->iface, add_listener, 0, listener, events, data); spa_audio_aec, &object->iface, add_listener, 0, listener, events, data);
} }
SPA_API_IMPL int spa_audio_aec_init(struct spa_audio_aec *object, SPA_API_AUDIO_AEC int spa_audio_aec_init(struct spa_audio_aec *object,
const struct spa_dict *args, const struct spa_audio_info_raw *info) const struct spa_dict *args, const struct spa_audio_info_raw *info)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, init, 0, args, info); spa_audio_aec, &object->iface, init, 0, args, info);
} }
SPA_API_IMPL int spa_audio_aec_run(struct spa_audio_aec *object, SPA_API_AUDIO_AEC int spa_audio_aec_run(struct spa_audio_aec *object,
const float *rec[], const float *play[], float *out[], uint32_t n_samples) const float *rec[], const float *play[], float *out[], uint32_t n_samples)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, run, 0, rec, play, out, n_samples); spa_audio_aec, &object->iface, run, 0, rec, play, out, n_samples);
} }
SPA_API_IMPL int spa_audio_aec_set_props(struct spa_audio_aec *object, const struct spa_dict *args) SPA_API_AUDIO_AEC int spa_audio_aec_set_props(struct spa_audio_aec *object, const struct spa_dict *args)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, set_props, 0, args); spa_audio_aec, &object->iface, set_props, 0, args);
} }
SPA_API_IMPL int spa_audio_aec_activate(struct spa_audio_aec *object) SPA_API_AUDIO_AEC int spa_audio_aec_activate(struct spa_audio_aec *object)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, activate, 1); spa_audio_aec, &object->iface, activate, 1);
} }
SPA_API_IMPL int spa_audio_aec_deactivate(struct spa_audio_aec *object) SPA_API_AUDIO_AEC int spa_audio_aec_deactivate(struct spa_audio_aec *object)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, deactivate, 1); spa_audio_aec, &object->iface, deactivate, 1);
} }
SPA_API_IMPL int spa_audio_aec_enum_props(struct spa_audio_aec *object, SPA_API_AUDIO_AEC int spa_audio_aec_enum_props(struct spa_audio_aec *object,
int index, struct spa_pod_builder* builder) int index, struct spa_pod_builder* builder)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, enum_props, 2, index, builder); spa_audio_aec, &object->iface, enum_props, 2, index, builder);
} }
SPA_API_IMPL int spa_audio_aec_get_params(struct spa_audio_aec *object, SPA_API_AUDIO_AEC int spa_audio_aec_get_params(struct spa_audio_aec *object,
struct spa_pod_builder* builder) struct spa_pod_builder* builder)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, get_params, 2, builder); spa_audio_aec, &object->iface, get_params, 2, builder);
} }
SPA_API_IMPL int spa_audio_aec_set_params(struct spa_audio_aec *object, SPA_API_AUDIO_AEC int spa_audio_aec_set_params(struct spa_audio_aec *object,
const struct spa_pod *args) const struct spa_pod *args)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, set_params, 2, args); spa_audio_aec, &object->iface, set_params, 2, args);
} }
SPA_API_IMPL int spa_audio_aec_init2(struct spa_audio_aec *object, SPA_API_AUDIO_AEC int spa_audio_aec_init2(struct spa_audio_aec *object,
const struct spa_dict *args, const struct spa_dict *args,
struct spa_audio_info_raw *play_info, struct spa_audio_info_raw *play_info,
struct spa_audio_info_raw *rec_info, struct spa_audio_info_raw *rec_info,

View file

@ -14,6 +14,14 @@ extern "C" {
#include <spa/utils/dict.h> #include <spa/utils/dict.h>
#include <spa/pod/event.h> #include <spa/pod/event.h>
#ifndef SPA_API_DEVICE
#ifdef SPA_API_IMPL
#define SPA_API_DEVICE SPA_API_IMPL
#else
#define SPA_API_DEVICE static inline
#endif
#endif
/** /**
* \defgroup spa_device Device * \defgroup spa_device Device
* *
@ -220,7 +228,7 @@ struct spa_device_methods {
const struct spa_pod *param); const struct spa_pod *param);
}; };
SPA_API_IMPL int spa_device_add_listener(struct spa_device *object, SPA_API_DEVICE int spa_device_add_listener(struct spa_device *object,
struct spa_hook *listener, struct spa_hook *listener,
const struct spa_device_events *events, const struct spa_device_events *events,
void *data) void *data)
@ -229,19 +237,19 @@ SPA_API_IMPL int spa_device_add_listener(struct spa_device *object,
listener, events, data); listener, events, data);
} }
SPA_API_IMPL int spa_device_sync(struct spa_device *object, int seq) SPA_API_DEVICE int spa_device_sync(struct spa_device *object, int seq)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, sync, 0, return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, sync, 0,
seq); seq);
} }
SPA_API_IMPL int spa_device_enum_params(struct spa_device *object, int seq, SPA_API_DEVICE int spa_device_enum_params(struct spa_device *object, int seq,
uint32_t id, uint32_t index, uint32_t max, uint32_t id, uint32_t index, uint32_t max,
const struct spa_pod *filter) const struct spa_pod *filter)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, enum_params, 0, return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, enum_params, 0,
seq, id, index, max, filter); seq, id, index, max, filter);
} }
SPA_API_IMPL int spa_device_set_param(struct spa_device *object, SPA_API_DEVICE int spa_device_set_param(struct spa_device *object,
uint32_t id, uint32_t flags, uint32_t id, uint32_t flags,
const struct spa_pod *param) const struct spa_pod *param)
{ {

View file

@ -12,6 +12,14 @@ extern "C" {
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#include <spa/monitor/device.h> #include <spa/monitor/device.h>
#ifndef SPA_API_DEVICE_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_DEVICE_UTILS SPA_API_IMPL
#else
#define SPA_API_DEVICE_UTILS static inline
#endif
#endif
/** /**
* \addtogroup spa_device * \addtogroup spa_device
* \{ * \{
@ -22,7 +30,7 @@ struct spa_result_device_params_data {
struct spa_result_device_params data; struct spa_result_device_params data;
}; };
SPA_API_IMPL void spa_result_func_device_params(void *data, int seq SPA_UNUSED, int res SPA_UNUSED, SPA_API_DEVICE_UTILS void spa_result_func_device_params(void *data, int seq SPA_UNUSED, int res SPA_UNUSED,
uint32_t type SPA_UNUSED, const void *result) uint32_t type SPA_UNUSED, const void *result)
{ {
struct spa_result_device_params_data *d = struct spa_result_device_params_data *d =
@ -36,7 +44,7 @@ SPA_API_IMPL void spa_result_func_device_params(void *data, int seq SPA_UNUSED,
d->data.param = spa_pod_builder_deref(d->builder, offset); d->data.param = spa_pod_builder_deref(d->builder, offset);
} }
SPA_API_IMPL int spa_device_enum_params_sync(struct spa_device *device, SPA_API_DEVICE_UTILS int spa_device_enum_params_sync(struct spa_device *device,
uint32_t id, uint32_t *index, uint32_t id, uint32_t *index,
const struct spa_pod *filter, const struct spa_pod *filter,
struct spa_pod **param, struct spa_pod **param,

View file

@ -27,6 +27,14 @@ extern "C" {
#include <spa/node/event.h> #include <spa/node/event.h>
#include <spa/node/command.h> #include <spa/node/command.h>
#ifndef SPA_API_NODE
#ifdef SPA_API_IMPL
#define SPA_API_NODE SPA_API_IMPL
#else
#define SPA_API_NODE static inline
#endif
#endif
#define SPA_TYPE_INTERFACE_Node SPA_TYPE_INFO_INTERFACE_BASE "Node" #define SPA_TYPE_INTERFACE_Node SPA_TYPE_INFO_INTERFACE_BASE "Node"
@ -634,7 +642,7 @@ struct spa_node_methods {
}; };
SPA_API_IMPL int spa_node_add_listener(struct spa_node *object, SPA_API_NODE int spa_node_add_listener(struct spa_node *object,
struct spa_hook *listener, struct spa_hook *listener,
const struct spa_node_events *events, const struct spa_node_events *events,
void *data) void *data)
@ -642,58 +650,58 @@ SPA_API_IMPL int spa_node_add_listener(struct spa_node *object,
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, add_listener, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, add_listener, 0,
listener, events, data); listener, events, data);
} }
SPA_API_IMPL int spa_node_set_callbacks(struct spa_node *object, SPA_API_NODE int spa_node_set_callbacks(struct spa_node *object,
const struct spa_node_callbacks *callbacks, const struct spa_node_callbacks *callbacks,
void *data) void *data)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, set_callbacks, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, set_callbacks, 0,
callbacks, data); callbacks, data);
} }
SPA_API_IMPL int spa_node_sync(struct spa_node *object, int seq) SPA_API_NODE int spa_node_sync(struct spa_node *object, int seq)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, sync, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, sync, 0,
seq); seq);
} }
SPA_API_IMPL int spa_node_enum_params(struct spa_node *object, int seq, SPA_API_NODE int spa_node_enum_params(struct spa_node *object, int seq,
uint32_t id, uint32_t start, uint32_t max, uint32_t id, uint32_t start, uint32_t max,
const struct spa_pod *filter) const struct spa_pod *filter)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, enum_params, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, enum_params, 0,
seq, id, start, max, filter); seq, id, start, max, filter);
} }
SPA_API_IMPL int spa_node_set_param(struct spa_node *object, SPA_API_NODE int spa_node_set_param(struct spa_node *object,
uint32_t id, uint32_t flags, uint32_t id, uint32_t flags,
const struct spa_pod *param) const struct spa_pod *param)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, set_param, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, set_param, 0,
id, flags, param); id, flags, param);
} }
SPA_API_IMPL int spa_node_set_io(struct spa_node *object, SPA_API_NODE int spa_node_set_io(struct spa_node *object,
uint32_t id, void *data, size_t size) uint32_t id, void *data, size_t size)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, set_io, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, set_io, 0,
id, data, size); id, data, size);
} }
SPA_API_IMPL int spa_node_send_command(struct spa_node *object, SPA_API_NODE int spa_node_send_command(struct spa_node *object,
const struct spa_command *command) const struct spa_command *command)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, send_command, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, send_command, 0,
command); command);
} }
SPA_API_IMPL int spa_node_add_port(struct spa_node *object, SPA_API_NODE int spa_node_add_port(struct spa_node *object,
enum spa_direction direction, uint32_t port_id, enum spa_direction direction, uint32_t port_id,
const struct spa_dict *props) const struct spa_dict *props)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, add_port, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, add_port, 0,
direction, port_id, props); direction, port_id, props);
} }
SPA_API_IMPL int spa_node_remove_port(struct spa_node *object, SPA_API_NODE int spa_node_remove_port(struct spa_node *object,
enum spa_direction direction, uint32_t port_id) enum spa_direction direction, uint32_t port_id)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, remove_port, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, remove_port, 0,
direction, port_id); direction, port_id);
} }
SPA_API_IMPL int spa_node_port_enum_params(struct spa_node *object, int seq, SPA_API_NODE int spa_node_port_enum_params(struct spa_node *object, int seq,
enum spa_direction direction, uint32_t port_id, enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t start, uint32_t max, uint32_t id, uint32_t start, uint32_t max,
const struct spa_pod *filter) const struct spa_pod *filter)
@ -701,7 +709,7 @@ SPA_API_IMPL int spa_node_port_enum_params(struct spa_node *object, int seq,
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_enum_params, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_enum_params, 0,
seq, direction, port_id, id, start, max, filter); seq, direction, port_id, id, start, max, filter);
} }
SPA_API_IMPL int spa_node_port_set_param(struct spa_node *object, SPA_API_NODE int spa_node_port_set_param(struct spa_node *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t id, uint32_t flags, uint32_t id, uint32_t flags,
@ -710,7 +718,7 @@ SPA_API_IMPL int spa_node_port_set_param(struct spa_node *object,
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_set_param, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_set_param, 0,
direction, port_id, id, flags, param); direction, port_id, id, flags, param);
} }
SPA_API_IMPL int spa_node_port_use_buffers(struct spa_node *object, SPA_API_NODE int spa_node_port_use_buffers(struct spa_node *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t flags, uint32_t flags,
@ -720,7 +728,7 @@ SPA_API_IMPL int spa_node_port_use_buffers(struct spa_node *object,
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_use_buffers, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_use_buffers, 0,
direction, port_id, flags, buffers, n_buffers); direction, port_id, flags, buffers, n_buffers);
} }
SPA_API_IMPL int spa_node_port_set_io(struct spa_node *object, SPA_API_NODE int spa_node_port_set_io(struct spa_node *object,
enum spa_direction direction, enum spa_direction direction,
uint32_t port_id, uint32_t port_id,
uint32_t id, void *data, size_t size) uint32_t id, void *data, size_t size)
@ -729,21 +737,21 @@ SPA_API_IMPL int spa_node_port_set_io(struct spa_node *object,
direction, port_id, id, data, size); direction, port_id, id, data, size);
} }
SPA_API_IMPL int spa_node_port_reuse_buffer(struct spa_node *object, uint32_t port_id, uint32_t buffer_id) SPA_API_NODE int spa_node_port_reuse_buffer(struct spa_node *object, uint32_t port_id, uint32_t buffer_id)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_reuse_buffer, 0, return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_reuse_buffer, 0,
port_id, buffer_id); port_id, buffer_id);
} }
SPA_API_IMPL int spa_node_port_reuse_buffer_fast(struct spa_node *object, uint32_t port_id, uint32_t buffer_id) SPA_API_NODE int spa_node_port_reuse_buffer_fast(struct spa_node *object, uint32_t port_id, uint32_t buffer_id)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_node, &object->iface, port_reuse_buffer, 0, return spa_api_method_fast_r(int, -ENOTSUP, spa_node, &object->iface, port_reuse_buffer, 0,
port_id, buffer_id); port_id, buffer_id);
} }
SPA_API_IMPL int spa_node_process(struct spa_node *object) SPA_API_NODE int spa_node_process(struct spa_node *object)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, process, 0); return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, process, 0);
} }
SPA_API_IMPL int spa_node_process_fast(struct spa_node *object) SPA_API_NODE int spa_node_process_fast(struct spa_node *object)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_node, &object->iface, process, 0); return spa_api_method_fast_r(int, -ENOTSUP, spa_node, &object->iface, process, 0);
} }

View file

@ -18,12 +18,20 @@ extern "C" {
#include <spa/node/node.h> #include <spa/node/node.h>
#ifndef SPA_API_NODE_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_NODE_UTILS SPA_API_IMPL
#else
#define SPA_API_NODE_UTILS static inline
#endif
#endif
struct spa_result_node_params_data { struct spa_result_node_params_data {
struct spa_pod_builder *builder; struct spa_pod_builder *builder;
struct spa_result_node_params data; struct spa_result_node_params data;
}; };
SPA_API_IMPL void spa_result_func_node_params(void *data, SPA_API_NODE_UTILS void spa_result_func_node_params(void *data,
int seq SPA_UNUSED, int res SPA_UNUSED, uint32_t type SPA_UNUSED, const void *result) int seq SPA_UNUSED, int res SPA_UNUSED, uint32_t type SPA_UNUSED, const void *result)
{ {
struct spa_result_node_params_data *d = struct spa_result_node_params_data *d =
@ -37,7 +45,7 @@ SPA_API_IMPL void spa_result_func_node_params(void *data,
d->data.param = spa_pod_builder_deref(d->builder, offset); d->data.param = spa_pod_builder_deref(d->builder, offset);
} }
SPA_API_IMPL int spa_node_enum_params_sync(struct spa_node *node, SPA_API_NODE_UTILS int spa_node_enum_params_sync(struct spa_node *node,
uint32_t id, uint32_t *index, uint32_t id, uint32_t *index,
const struct spa_pod *filter, const struct spa_pod *filter,
struct spa_pod **param, struct spa_pod **param,
@ -70,7 +78,7 @@ SPA_API_IMPL int spa_node_enum_params_sync(struct spa_node *node,
return res; return res;
} }
SPA_API_IMPL int spa_node_port_enum_params_sync(struct spa_node *node, SPA_API_NODE_UTILS int spa_node_port_enum_params_sync(struct spa_node *node,
enum spa_direction direction, uint32_t port_id, enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t *index, uint32_t id, uint32_t *index,
const struct spa_pod *filter, const struct spa_pod *filter,

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_AAC_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_AAC_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_AAC_UTILS static inline
#endif
#endif
SPA_API_AUDIO_AAC_UTILS int
spa_format_audio_aac_parse(const struct spa_pod *format, struct spa_audio_info_aac *info) spa_format_audio_aac_parse(const struct spa_pod *format, struct spa_audio_info_aac *info)
{ {
int res; int res;
@ -33,7 +41,7 @@ spa_format_audio_aac_parse(const struct spa_pod *format, struct spa_audio_info_a
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_AAC_UTILS struct spa_pod *
spa_format_audio_aac_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_aac_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_aac *info) const struct spa_audio_info_aac *info)
{ {

View file

@ -19,7 +19,16 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_ALAC_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_ALAC_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_ALAC_UTILS static inline
#endif
#endif
SPA_API_AUDIO_ALAC_UTILS int
spa_format_audio_alac_parse(const struct spa_pod *format, struct spa_audio_info_alac *info) spa_format_audio_alac_parse(const struct spa_pod *format, struct spa_audio_info_alac *info)
{ {
int res; int res;
@ -30,7 +39,7 @@ spa_format_audio_alac_parse(const struct spa_pod *format, struct spa_audio_info_
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_ALAC_UTILS struct spa_pod *
spa_format_audio_alac_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_alac_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_alac *info) const struct spa_audio_info_alac *info)
{ {

View file

@ -19,7 +19,16 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_AMR_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_AMR_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_AMR_UTILS static inline
#endif
#endif
SPA_API_AUDIO_AMR_UTILS int
spa_format_audio_amr_parse(const struct spa_pod *format, struct spa_audio_info_amr *info) spa_format_audio_amr_parse(const struct spa_pod *format, struct spa_audio_info_amr *info)
{ {
int res; int res;
@ -31,7 +40,7 @@ spa_format_audio_amr_parse(const struct spa_pod *format, struct spa_audio_info_a
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_AMR_UTILS struct spa_pod *
spa_format_audio_amr_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_amr_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_amr *info) const struct spa_audio_info_amr *info)
{ {

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_APE_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_APE_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_APE_UTILS static inline
#endif
#endif
SPA_API_AUDIO_APE_UTILS int
spa_format_audio_ape_parse(const struct spa_pod *format, struct spa_audio_info_ape *info) spa_format_audio_ape_parse(const struct spa_pod *format, struct spa_audio_info_ape *info)
{ {
int res; int res;
@ -30,7 +38,7 @@ spa_format_audio_ape_parse(const struct spa_pod *format, struct spa_audio_info_a
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_APE_UTILS struct spa_pod *
spa_format_audio_ape_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_ape_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_ape *info) const struct spa_audio_info_ape *info)
{ {

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_DSD_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_DSD_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_DSD_UTILS static inline
#endif
#endif
SPA_API_AUDIO_DSD_UTILS int
spa_format_audio_dsd_parse(const struct spa_pod *format, struct spa_audio_info_dsd *info) spa_format_audio_dsd_parse(const struct spa_pod *format, struct spa_audio_info_dsd *info)
{ {
struct spa_pod *position = NULL; struct spa_pod *position = NULL;
@ -39,7 +47,7 @@ spa_format_audio_dsd_parse(const struct spa_pod *format, struct spa_audio_info_d
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_DSD_UTILS struct spa_pod *
spa_format_audio_dsd_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_dsd_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_dsd *info) const struct spa_audio_info_dsd *info)
{ {

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_DSP_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_DSP_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_DSP_UTILS static inline
#endif
#endif
SPA_API_AUDIO_DSP_UTILS int
spa_format_audio_dsp_parse(const struct spa_pod *format, struct spa_audio_info_dsp *info) spa_format_audio_dsp_parse(const struct spa_pod *format, struct spa_audio_info_dsp *info)
{ {
int res; int res;
@ -29,7 +37,7 @@ spa_format_audio_dsp_parse(const struct spa_pod *format, struct spa_audio_info_d
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_DSP_UTILS struct spa_pod *
spa_format_audio_dsp_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_dsp_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_dsp *info) const struct spa_audio_info_dsp *info)
{ {

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_FLAC_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_FLAC_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_FLAC_UTILS static inline
#endif
#endif
SPA_API_AUDIO_FLAC_UTILS int
spa_format_audio_flac_parse(const struct spa_pod *format, struct spa_audio_info_flac *info) spa_format_audio_flac_parse(const struct spa_pod *format, struct spa_audio_info_flac *info)
{ {
int res; int res;
@ -30,7 +38,7 @@ spa_format_audio_flac_parse(const struct spa_pod *format, struct spa_audio_info_
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_FLAC_UTILS struct spa_pod *
spa_format_audio_flac_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_flac_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_flac *info) const struct spa_audio_info_flac *info)
{ {

View file

@ -34,7 +34,15 @@ extern "C" {
* \{ * \{
*/ */
SPA_API_IMPL int #ifndef SPA_API_AUDIO_FORMAT_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_FORMAT_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_FORMAT_UTILS static inline
#endif
#endif
SPA_API_AUDIO_FORMAT_UTILS int
spa_format_audio_parse(const struct spa_pod *format, struct spa_audio_info *info) spa_format_audio_parse(const struct spa_pod *format, struct spa_audio_info *info)
{ {
int res; int res;
@ -76,7 +84,7 @@ spa_format_audio_parse(const struct spa_pod *format, struct spa_audio_info *info
return -ENOTSUP; return -ENOTSUP;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_FORMAT_UTILS struct spa_pod *
spa_format_audio_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info *info) const struct spa_audio_info *info)
{ {

View file

@ -17,6 +17,14 @@ extern "C" {
* \{ * \{
*/ */
#ifndef SPA_API_AUDIO_IEC958_TYPES
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_IEC958_TYPES SPA_API_IMPL
#else
#define SPA_API_AUDIO_IEC958_TYPES static inline
#endif
#endif
#define SPA_TYPE_INFO_AudioIEC958Codec SPA_TYPE_INFO_ENUM_BASE "AudioIEC958Codec" #define SPA_TYPE_INFO_AudioIEC958Codec SPA_TYPE_INFO_ENUM_BASE "AudioIEC958Codec"
#define SPA_TYPE_INFO_AUDIO_IEC958_CODEC_BASE SPA_TYPE_INFO_AudioIEC958Codec ":" #define SPA_TYPE_INFO_AUDIO_IEC958_CODEC_BASE SPA_TYPE_INFO_AudioIEC958Codec ":"
@ -33,11 +41,11 @@ static const struct spa_type_info spa_type_audio_iec958_codec[] = {
{ 0, 0, NULL, NULL }, { 0, 0, NULL, NULL },
}; };
SPA_API_IMPL uint32_t spa_type_audio_iec958_codec_from_short_name(const char *name) SPA_API_AUDIO_IEC958_TYPES uint32_t spa_type_audio_iec958_codec_from_short_name(const char *name)
{ {
return spa_type_from_short_name(name, spa_type_audio_iec958_codec, SPA_AUDIO_IEC958_CODEC_UNKNOWN); return spa_type_from_short_name(name, spa_type_audio_iec958_codec, SPA_AUDIO_IEC958_CODEC_UNKNOWN);
} }
SPA_API_IMPL const char * spa_type_audio_iec958_codec_to_short_name(uint32_t type) SPA_API_AUDIO_IEC958_TYPES const char * spa_type_audio_iec958_codec_to_short_name(uint32_t type)
{ {
return spa_type_to_short_name(type, spa_type_audio_iec958_codec, "UNKNOWN"); return spa_type_to_short_name(type, spa_type_audio_iec958_codec, "UNKNOWN");
} }

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_IEC958_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_IEC958_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_IEC958_UTILS static inline
#endif
#endif
SPA_API_AUDIO_IEC958_UTILS int
spa_format_audio_iec958_parse(const struct spa_pod *format, struct spa_audio_info_iec958 *info) spa_format_audio_iec958_parse(const struct spa_pod *format, struct spa_audio_info_iec958 *info)
{ {
int res; int res;
@ -30,7 +38,7 @@ spa_format_audio_iec958_parse(const struct spa_pod *format, struct spa_audio_inf
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_IEC958_UTILS struct spa_pod *
spa_format_audio_iec958_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_iec958_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_iec958 *info) const struct spa_audio_info_iec958 *info)
{ {

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_MP3_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_MP3_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_MP3_UTILS static inline
#endif
#endif
SPA_API_AUDIO_MP3_UTILS int
spa_format_audio_mp3_parse(const struct spa_pod *format, struct spa_audio_info_mp3 *info) spa_format_audio_mp3_parse(const struct spa_pod *format, struct spa_audio_info_mp3 *info)
{ {
int res; int res;
@ -30,7 +38,7 @@ spa_format_audio_mp3_parse(const struct spa_pod *format, struct spa_audio_info_m
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_MP3_UTILS struct spa_pod *
spa_format_audio_mp3_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_mp3_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_mp3 *info) const struct spa_audio_info_mp3 *info)
{ {

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_RA_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_RA_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_RA_UTILS static inline
#endif
#endif
SPA_API_AUDIO_RA_UTILS int
spa_format_audio_ra_parse(const struct spa_pod *format, struct spa_audio_info_ra *info) spa_format_audio_ra_parse(const struct spa_pod *format, struct spa_audio_info_ra *info)
{ {
int res; int res;
@ -30,7 +38,7 @@ spa_format_audio_ra_parse(const struct spa_pod *format, struct spa_audio_info_ra
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_RA_UTILS struct spa_pod *
spa_format_audio_ra_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_ra_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_ra *info) const struct spa_audio_info_ra *info)
{ {

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/audio/raw.h> #include <spa/param/audio/raw.h>
#include <spa/param/audio/raw-types.h> #include <spa/param/audio/raw-types.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_RAW_JSON
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_RAW_JSON SPA_API_IMPL
#else
#define SPA_API_AUDIO_RAW_JSON static inline
#endif
#endif
SPA_API_AUDIO_RAW_JSON int
spa_audio_parse_position(const char *str, size_t len, spa_audio_parse_position(const char *str, size_t len,
uint32_t *position, uint32_t *n_channels) uint32_t *position, uint32_t *n_channels)
{ {
@ -38,7 +46,7 @@ spa_audio_parse_position(const char *str, size_t len,
return channels; return channels;
} }
SPA_API_IMPL int SPA_API_AUDIO_RAW_JSON int
spa_audio_info_raw_update(struct spa_audio_info_raw *info, const char *key, const char *val, bool force) spa_audio_info_raw_update(struct spa_audio_info_raw *info, const char *key, const char *val, bool force)
{ {
uint32_t v; uint32_t v;
@ -60,7 +68,7 @@ spa_audio_info_raw_update(struct spa_audio_info_raw *info, const char *key, cons
return 0; return 0;
} }
SPA_API_IMPL int SPA_SENTINEL SPA_API_AUDIO_RAW_JSON int SPA_SENTINEL
spa_audio_info_raw_init_dict_keys(struct spa_audio_info_raw *info, spa_audio_info_raw_init_dict_keys(struct spa_audio_info_raw *info,
const struct spa_dict *defaults, const struct spa_dict *defaults,
const struct spa_dict *dict, ...) const struct spa_dict *dict, ...)

View file

@ -18,6 +18,14 @@ extern "C" {
#include <spa/utils/string.h> #include <spa/utils/string.h>
#include <spa/param/audio/raw.h> #include <spa/param/audio/raw.h>
#ifndef SPA_API_AUDIO_RAW_TYPES
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_RAW_TYPES SPA_API_IMPL
#else
#define SPA_API_AUDIO_RAW_TYPES static inline
#endif
#endif
#define SPA_TYPE_INFO_AudioFormat SPA_TYPE_INFO_ENUM_BASE "AudioFormat" #define SPA_TYPE_INFO_AudioFormat SPA_TYPE_INFO_ENUM_BASE "AudioFormat"
#define SPA_TYPE_INFO_AUDIO_FORMAT_BASE SPA_TYPE_INFO_AudioFormat ":" #define SPA_TYPE_INFO_AUDIO_FORMAT_BASE SPA_TYPE_INFO_AudioFormat ":"
@ -129,11 +137,11 @@ static const struct spa_type_info spa_type_audio_format[] = {
{ 0, 0, NULL, NULL }, { 0, 0, NULL, NULL },
}; };
SPA_API_IMPL uint32_t spa_type_audio_format_from_short_name(const char *name) SPA_API_AUDIO_RAW_TYPES uint32_t spa_type_audio_format_from_short_name(const char *name)
{ {
return spa_type_from_short_name(name, spa_type_audio_format, SPA_AUDIO_FORMAT_UNKNOWN); return spa_type_from_short_name(name, spa_type_audio_format, SPA_AUDIO_FORMAT_UNKNOWN);
} }
SPA_API_IMPL const char * spa_type_audio_format_to_short_name(uint32_t type) SPA_API_AUDIO_RAW_TYPES const char * spa_type_audio_format_to_short_name(uint32_t type)
{ {
return spa_type_to_short_name(type, spa_type_audio_format, "UNKNOWN"); return spa_type_to_short_name(type, spa_type_audio_format, "UNKNOWN");
} }
@ -257,11 +265,11 @@ static const struct spa_type_info spa_type_audio_channel[] = {
{ 0, 0, NULL, NULL }, { 0, 0, NULL, NULL },
}; };
SPA_API_IMPL uint32_t spa_type_audio_channel_from_short_name(const char *name) SPA_API_AUDIO_RAW_TYPES uint32_t spa_type_audio_channel_from_short_name(const char *name)
{ {
return spa_type_from_short_name(name, spa_type_audio_channel, SPA_AUDIO_CHANNEL_UNKNOWN); return spa_type_from_short_name(name, spa_type_audio_channel, SPA_AUDIO_CHANNEL_UNKNOWN);
} }
SPA_API_IMPL const char * spa_type_audio_channel_to_short_name(uint32_t type) SPA_API_AUDIO_RAW_TYPES const char * spa_type_audio_channel_to_short_name(uint32_t type)
{ {
return spa_type_to_short_name(type, spa_type_audio_channel, "UNK"); return spa_type_to_short_name(type, spa_type_audio_channel, "UNK");
} }

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_RAW_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_RAW_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_RAW_UTILS static inline
#endif
#endif
SPA_API_AUDIO_RAW_UTILS int
spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_raw *info) spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_raw *info)
{ {
struct spa_pod *position = NULL; struct spa_pod *position = NULL;
@ -38,7 +46,7 @@ spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_r
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_RAW_UTILS struct spa_pod *
spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_raw_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_raw *info) const struct spa_audio_info_raw *info)
{ {

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_VORBIS_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_VORBIS_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_VORBIS_UTILS static inline
#endif
#endif
SPA_API_AUDIO_VORBIS_UTILS int
spa_format_audio_vorbis_parse(const struct spa_pod *format, struct spa_audio_info_vorbis *info) spa_format_audio_vorbis_parse(const struct spa_pod *format, struct spa_audio_info_vorbis *info)
{ {
int res; int res;
@ -30,7 +38,7 @@ spa_format_audio_vorbis_parse(const struct spa_pod *format, struct spa_audio_inf
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_VORBIS_UTILS struct spa_pod *
spa_format_audio_vorbis_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_vorbis_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_vorbis *info) const struct spa_audio_info_vorbis *info)
{ {

View file

@ -19,7 +19,15 @@ extern "C" {
#include <spa/param/audio/format.h> #include <spa/param/audio/format.h>
#include <spa/param/format-utils.h> #include <spa/param/format-utils.h>
SPA_API_IMPL int #ifndef SPA_API_AUDIO_WMA_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_AUDIO_WMA_UTILS SPA_API_IMPL
#else
#define SPA_API_AUDIO_WMA_UTILS static inline
#endif
#endif
SPA_API_AUDIO_WMA_UTILS int
spa_format_audio_wma_parse(const struct spa_pod *format, struct spa_audio_info_wma *info) spa_format_audio_wma_parse(const struct spa_pod *format, struct spa_audio_info_wma *info)
{ {
int res; int res;
@ -33,7 +41,7 @@ spa_format_audio_wma_parse(const struct spa_pod *format, struct spa_audio_info_w
return res; return res;
} }
SPA_API_IMPL struct spa_pod * SPA_API_AUDIO_WMA_UTILS struct spa_pod *
spa_format_audio_wma_build(struct spa_pod_builder *builder, uint32_t id, spa_format_audio_wma_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_audio_info_wma *info) const struct spa_audio_info_wma *info)
{ {

View file

@ -18,7 +18,15 @@ extern "C" {
#include <spa/pod/parser.h> #include <spa/pod/parser.h>
#include <spa/param/format.h> #include <spa/param/format.h>
SPA_API_IMPL int #ifndef SPA_API_FORMAT_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_FORMAT_UTILS SPA_API_IMPL
#else
#define SPA_API_FORMAT_UTILS static inline
#endif
#endif
SPA_API_FORMAT_UTILS int
spa_format_parse(const struct spa_pod *format, uint32_t *media_type, uint32_t *media_subtype) spa_format_parse(const struct spa_pod *format, uint32_t *media_type, uint32_t *media_subtype)
{ {
return spa_pod_parse_object(format, return spa_pod_parse_object(format,

View file

@ -20,7 +20,15 @@ extern "C" {
#include <spa/pod/parser.h> #include <spa/pod/parser.h>
#include <spa/param/latency.h> #include <spa/param/latency.h>
SPA_API_IMPL int #ifndef SPA_API_LATENCY_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_LATENCY_UTILS SPA_API_IMPL
#else
#define SPA_API_LATENCY_UTILS static inline
#endif
#endif
SPA_API_LATENCY_UTILS int
spa_latency_info_compare(const struct spa_latency_info *a, const struct spa_latency_info *b) spa_latency_info_compare(const struct spa_latency_info *a, const struct spa_latency_info *b)
{ {
if (a->min_quantum == b->min_quantum && if (a->min_quantum == b->min_quantum &&
@ -33,7 +41,7 @@ spa_latency_info_compare(const struct spa_latency_info *a, const struct spa_late
return 1; return 1;
} }
SPA_API_IMPL void SPA_API_LATENCY_UTILS void
spa_latency_info_combine_start(struct spa_latency_info *info, enum spa_direction direction) spa_latency_info_combine_start(struct spa_latency_info *info, enum spa_direction direction)
{ {
*info = SPA_LATENCY_INFO(direction, *info = SPA_LATENCY_INFO(direction,
@ -44,7 +52,7 @@ spa_latency_info_combine_start(struct spa_latency_info *info, enum spa_direction
.min_ns = INT64_MAX, .min_ns = INT64_MAX,
.max_ns = INT64_MIN); .max_ns = INT64_MIN);
} }
SPA_API_IMPL void SPA_API_LATENCY_UTILS void
spa_latency_info_combine_finish(struct spa_latency_info *info) spa_latency_info_combine_finish(struct spa_latency_info *info)
{ {
if (info->min_quantum == FLT_MAX) if (info->min_quantum == FLT_MAX)
@ -61,7 +69,7 @@ spa_latency_info_combine_finish(struct spa_latency_info *info)
info->max_ns = 0; info->max_ns = 0;
} }
SPA_API_IMPL int SPA_API_LATENCY_UTILS int
spa_latency_info_combine(struct spa_latency_info *info, const struct spa_latency_info *other) spa_latency_info_combine(struct spa_latency_info *info, const struct spa_latency_info *other)
{ {
if (info->direction != other->direction) if (info->direction != other->direction)
@ -81,7 +89,7 @@ spa_latency_info_combine(struct spa_latency_info *info, const struct spa_latency
return 0; return 0;
} }
SPA_API_IMPL int SPA_API_LATENCY_UTILS int
spa_latency_parse(const struct spa_pod *latency, struct spa_latency_info *info) spa_latency_parse(const struct spa_pod *latency, struct spa_latency_info *info)
{ {
int res; int res;
@ -100,7 +108,7 @@ spa_latency_parse(const struct spa_pod *latency, struct spa_latency_info *info)
return 0; return 0;
} }
SPA_API_IMPL struct spa_pod * SPA_API_LATENCY_UTILS struct spa_pod *
spa_latency_build(struct spa_pod_builder *builder, uint32_t id, const struct spa_latency_info *info) spa_latency_build(struct spa_pod_builder *builder, uint32_t id, const struct spa_latency_info *info)
{ {
return (struct spa_pod *)spa_pod_builder_add_object(builder, return (struct spa_pod *)spa_pod_builder_add_object(builder,
@ -114,7 +122,7 @@ spa_latency_build(struct spa_pod_builder *builder, uint32_t id, const struct spa
SPA_PARAM_LATENCY_maxNs, SPA_POD_Long(info->max_ns)); SPA_PARAM_LATENCY_maxNs, SPA_POD_Long(info->max_ns));
} }
SPA_API_IMPL int SPA_API_LATENCY_UTILS int
spa_process_latency_parse(const struct spa_pod *latency, struct spa_process_latency_info *info) spa_process_latency_parse(const struct spa_pod *latency, struct spa_process_latency_info *info)
{ {
int res; int res;
@ -128,7 +136,7 @@ spa_process_latency_parse(const struct spa_pod *latency, struct spa_process_late
return 0; return 0;
} }
SPA_API_IMPL struct spa_pod * SPA_API_LATENCY_UTILS struct spa_pod *
spa_process_latency_build(struct spa_pod_builder *builder, uint32_t id, spa_process_latency_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_process_latency_info *info) const struct spa_process_latency_info *info)
{ {
@ -139,7 +147,7 @@ spa_process_latency_build(struct spa_pod_builder *builder, uint32_t id,
SPA_PARAM_PROCESS_LATENCY_ns, SPA_POD_Long(info->ns)); SPA_PARAM_PROCESS_LATENCY_ns, SPA_POD_Long(info->ns));
} }
SPA_API_IMPL int SPA_API_LATENCY_UTILS int
spa_process_latency_info_add(const struct spa_process_latency_info *process, spa_process_latency_info_add(const struct spa_process_latency_info *process,
struct spa_latency_info *info) struct spa_latency_info *info)
{ {
@ -152,7 +160,7 @@ spa_process_latency_info_add(const struct spa_process_latency_info *process,
return 0; return 0;
} }
SPA_API_IMPL int SPA_API_LATENCY_UTILS int
spa_process_latency_info_compare(const struct spa_process_latency_info *a, spa_process_latency_info_compare(const struct spa_process_latency_info *a,
const struct spa_process_latency_info *b) const struct spa_process_latency_info *b)
{ {

View file

@ -21,14 +21,22 @@ extern "C" {
#include <spa/pod/parser.h> #include <spa/pod/parser.h>
#include <spa/param/tag.h> #include <spa/param/tag.h>
SPA_API_IMPL int #ifndef SPA_API_TAG_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_TAG_UTILS SPA_API_IMPL
#else
#define SPA_API_TAG_UTILS static inline
#endif
#endif
SPA_API_TAG_UTILS int
spa_tag_compare(const struct spa_pod *a, const struct spa_pod *b) spa_tag_compare(const struct spa_pod *a, const struct spa_pod *b)
{ {
return ((a == b) || (a && b && SPA_POD_SIZE(a) == SPA_POD_SIZE(b) && return ((a == b) || (a && b && SPA_POD_SIZE(a) == SPA_POD_SIZE(b) &&
memcmp(a, b, SPA_POD_SIZE(b)) == 0)) ? 0 : 1; memcmp(a, b, SPA_POD_SIZE(b)) == 0)) ? 0 : 1;
} }
SPA_API_IMPL int SPA_API_TAG_UTILS int
spa_tag_parse(const struct spa_pod *tag, struct spa_tag_info *info, void **state) spa_tag_parse(const struct spa_pod *tag, struct spa_tag_info *info, void **state)
{ {
int res; int res;
@ -57,7 +65,7 @@ spa_tag_parse(const struct spa_pod *tag, struct spa_tag_info *info, void **state
return 0; return 0;
} }
SPA_API_IMPL int SPA_API_TAG_UTILS int
spa_tag_info_parse(const struct spa_tag_info *info, struct spa_dict *dict, struct spa_dict_item *items) spa_tag_info_parse(const struct spa_tag_info *info, struct spa_dict *dict, struct spa_dict_item *items)
{ {
struct spa_pod_parser prs; struct spa_pod_parser prs;
@ -90,7 +98,7 @@ spa_tag_info_parse(const struct spa_tag_info *info, struct spa_dict *dict, struc
return 0; return 0;
} }
SPA_API_IMPL void SPA_API_TAG_UTILS void
spa_tag_build_start(struct spa_pod_builder *builder, struct spa_pod_frame *f, spa_tag_build_start(struct spa_pod_builder *builder, struct spa_pod_frame *f,
uint32_t id, enum spa_direction direction) uint32_t id, enum spa_direction direction)
{ {
@ -100,7 +108,7 @@ spa_tag_build_start(struct spa_pod_builder *builder, struct spa_pod_frame *f,
0); 0);
} }
SPA_API_IMPL void SPA_API_TAG_UTILS void
spa_tag_build_add_info(struct spa_pod_builder *builder, const struct spa_pod *info) spa_tag_build_add_info(struct spa_pod_builder *builder, const struct spa_pod *info)
{ {
spa_pod_builder_add(builder, spa_pod_builder_add(builder,
@ -108,7 +116,7 @@ spa_tag_build_add_info(struct spa_pod_builder *builder, const struct spa_pod *in
0); 0);
} }
SPA_API_IMPL void SPA_API_TAG_UTILS void
spa_tag_build_add_dict(struct spa_pod_builder *builder, const struct spa_dict *dict) spa_tag_build_add_dict(struct spa_pod_builder *builder, const struct spa_dict *dict)
{ {
uint32_t i, n_items; uint32_t i, n_items;
@ -126,7 +134,7 @@ spa_tag_build_add_dict(struct spa_pod_builder *builder, const struct spa_dict *d
spa_pod_builder_pop(builder, &f); spa_pod_builder_pop(builder, &f);
} }
SPA_API_IMPL struct spa_pod * SPA_API_TAG_UTILS struct spa_pod *
spa_tag_build_end(struct spa_pod_builder *builder, struct spa_pod_frame *f) spa_tag_build_end(struct spa_pod_builder *builder, struct spa_pod_frame *f)
{ {
return (struct spa_pod*)spa_pod_builder_pop(builder, f); return (struct spa_pod*)spa_pod_builder_pop(builder, f);

View file

@ -18,7 +18,15 @@ extern "C" {
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#include <spa/param/video/dsp.h> #include <spa/param/video/dsp.h>
SPA_API_IMPL int #ifndef SPA_API_VIDEO_DSP_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_VIDEO_DSP_UTILS SPA_API_IMPL
#else
#define SPA_API_VIDEO_DSP_UTILS static inline
#endif
#endif
SPA_API_VIDEO_DSP_UTILS int
spa_format_video_dsp_parse(const struct spa_pod *format, spa_format_video_dsp_parse(const struct spa_pod *format,
struct spa_video_info_dsp *info) struct spa_video_info_dsp *info)
{ {
@ -36,7 +44,7 @@ spa_format_video_dsp_parse(const struct spa_pod *format,
SPA_FORMAT_VIDEO_modifier, SPA_POD_OPT_Long(&info->modifier)); SPA_FORMAT_VIDEO_modifier, SPA_POD_OPT_Long(&info->modifier));
} }
SPA_API_IMPL struct spa_pod * SPA_API_VIDEO_DSP_UTILS struct spa_pod *
spa_format_video_dsp_build(struct spa_pod_builder *builder, uint32_t id, spa_format_video_dsp_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_video_info_dsp *info) const struct spa_video_info_dsp *info)
{ {

View file

@ -16,7 +16,15 @@ extern "C" {
#include <spa/param/video/h264-utils.h> #include <spa/param/video/h264-utils.h>
#include <spa/param/video/mjpg-utils.h> #include <spa/param/video/mjpg-utils.h>
SPA_API_IMPL int #ifndef SPA_API_VIDEO_FORMAT_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_VIDEO_FORMAT_UTILS SPA_API_IMPL
#else
#define SPA_API_VIDEO_FORMAT_UTILS static inline
#endif
#endif
SPA_API_VIDEO_FORMAT_UTILS int
spa_format_video_parse(const struct spa_pod *format, struct spa_video_info *info) spa_format_video_parse(const struct spa_pod *format, struct spa_video_info *info)
{ {
int res; int res;
@ -40,7 +48,7 @@ spa_format_video_parse(const struct spa_pod *format, struct spa_video_info *info
return -ENOTSUP; return -ENOTSUP;
} }
SPA_API_IMPL struct spa_pod * SPA_API_VIDEO_FORMAT_UTILS struct spa_pod *
spa_format_video_build(struct spa_pod_builder *builder, uint32_t id, spa_format_video_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_video_info *info) const struct spa_video_info *info)
{ {

View file

@ -18,7 +18,15 @@ extern "C" {
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#include <spa/param/video/h264.h> #include <spa/param/video/h264.h>
SPA_API_IMPL int #ifndef SPA_API_VIDEO_H264_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_VIDEO_H264_UTILS SPA_API_IMPL
#else
#define SPA_API_VIDEO_H264_UTILS static inline
#endif
#endif
SPA_API_VIDEO_H264_UTILS int
spa_format_video_h264_parse(const struct spa_pod *format, spa_format_video_h264_parse(const struct spa_pod *format,
struct spa_video_info_h264 *info) struct spa_video_info_h264 *info)
{ {
@ -31,7 +39,7 @@ spa_format_video_h264_parse(const struct spa_pod *format,
SPA_FORMAT_VIDEO_H264_alignment, SPA_POD_OPT_Id(&info->alignment)); SPA_FORMAT_VIDEO_H264_alignment, SPA_POD_OPT_Id(&info->alignment));
} }
SPA_API_IMPL struct spa_pod * SPA_API_VIDEO_H264_UTILS struct spa_pod *
spa_format_video_h264_build(struct spa_pod_builder *builder, uint32_t id, spa_format_video_h264_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_video_info_h264 *info) const struct spa_video_info_h264 *info)
{ {

View file

@ -18,7 +18,15 @@ extern "C" {
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#include <spa/param/video/mjpg.h> #include <spa/param/video/mjpg.h>
SPA_API_IMPL int #ifndef SPA_API_VIDEO_MJPG_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_VIDEO_MJPG_UTILS SPA_API_IMPL
#else
#define SPA_API_VIDEO_MJPG_UTILS static inline
#endif
#endif
SPA_API_VIDEO_MJPG_UTILS int
spa_format_video_mjpg_parse(const struct spa_pod *format, spa_format_video_mjpg_parse(const struct spa_pod *format,
struct spa_video_info_mjpg *info) struct spa_video_info_mjpg *info)
{ {
@ -29,7 +37,7 @@ spa_format_video_mjpg_parse(const struct spa_pod *format,
SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_OPT_Fraction(&info->max_framerate)); SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_OPT_Fraction(&info->max_framerate));
} }
SPA_API_IMPL struct spa_pod * SPA_API_VIDEO_MJPG_UTILS struct spa_pod *
spa_format_video_mjpg_build(struct spa_pod_builder *builder, uint32_t id, spa_format_video_mjpg_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_video_info_mjpg *info) const struct spa_video_info_mjpg *info)
{ {

View file

@ -16,6 +16,14 @@ extern "C" {
#include <spa/utils/type.h> #include <spa/utils/type.h>
#include <spa/param/video/raw.h> #include <spa/param/video/raw.h>
#ifndef SPA_API_VIDEO_RAW_TYPES
#ifdef SPA_API_IMPL
#define SPA_API_VIDEO_RAW_TYPES SPA_API_IMPL
#else
#define SPA_API_VIDEO_RAW_TYPES static inline
#endif
#endif
#define SPA_TYPE_INFO_VideoFormat SPA_TYPE_INFO_ENUM_BASE "VideoFormat" #define SPA_TYPE_INFO_VideoFormat SPA_TYPE_INFO_ENUM_BASE "VideoFormat"
#define SPA_TYPE_INFO_VIDEO_FORMAT_BASE SPA_TYPE_INFO_VideoFormat ":" #define SPA_TYPE_INFO_VIDEO_FORMAT_BASE SPA_TYPE_INFO_VideoFormat ":"
@ -111,11 +119,11 @@ static const struct spa_type_info spa_type_video_format[] = {
{ 0, 0, NULL, NULL }, { 0, 0, NULL, NULL },
}; };
SPA_API_IMPL uint32_t spa_type_video_format_from_short_name(const char *name) SPA_API_VIDEO_RAW_TYPES uint32_t spa_type_video_format_from_short_name(const char *name)
{ {
return spa_type_from_short_name(name, spa_type_video_format, SPA_VIDEO_FORMAT_UNKNOWN); return spa_type_from_short_name(name, spa_type_video_format, SPA_VIDEO_FORMAT_UNKNOWN);
} }
SPA_API_IMPL const char * spa_type_video_format_to_short_name(uint32_t type) SPA_API_VIDEO_RAW_TYPES const char * spa_type_video_format_to_short_name(uint32_t type)
{ {
return spa_type_to_short_name(type, spa_type_video_format, "UNKNOWN"); return spa_type_to_short_name(type, spa_type_video_format, "UNKNOWN");
} }

View file

@ -18,7 +18,15 @@ extern "C" {
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#include <spa/param/video/raw.h> #include <spa/param/video/raw.h>
SPA_API_IMPL int #ifndef SPA_API_VIDEO_RAW_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_VIDEO_RAW_UTILS SPA_API_IMPL
#else
#define SPA_API_VIDEO_RAW_UTILS static inline
#endif
#endif
SPA_API_VIDEO_RAW_UTILS int
spa_format_video_raw_parse(const struct spa_pod *format, spa_format_video_raw_parse(const struct spa_pod *format,
struct spa_video_info_raw *info) struct spa_video_info_raw *info)
{ {
@ -49,7 +57,7 @@ spa_format_video_raw_parse(const struct spa_pod *format,
SPA_FORMAT_VIDEO_colorPrimaries, SPA_POD_OPT_Id(&info->color_primaries)); SPA_FORMAT_VIDEO_colorPrimaries, SPA_POD_OPT_Id(&info->color_primaries));
} }
SPA_API_IMPL struct spa_pod * SPA_API_VIDEO_RAW_UTILS struct spa_pod *
spa_format_video_raw_build(struct spa_pod_builder *builder, uint32_t id, spa_format_video_raw_build(struct spa_pod_builder *builder, uint32_t id,
const struct spa_video_info_raw *info) const struct spa_video_info_raw *info)
{ {

View file

@ -24,6 +24,14 @@ extern "C" {
#include <spa/pod/iter.h> #include <spa/pod/iter.h>
#include <spa/pod/vararg.h> #include <spa/pod/vararg.h>
#ifndef SPA_API_POD_BUILDER
#ifdef SPA_API_IMPL
#define SPA_API_POD_BUILDER SPA_API_IMPL
#else
#define SPA_API_POD_BUILDER static inline
#endif
#endif
struct spa_pod_builder_state { struct spa_pod_builder_state {
uint32_t offset; uint32_t offset;
#define SPA_POD_BUILDER_FLAG_BODY (1<<0) #define SPA_POD_BUILDER_FLAG_BODY (1<<0)
@ -51,20 +59,20 @@ struct spa_pod_builder {
#define SPA_POD_BUILDER_INIT(buffer,size) ((struct spa_pod_builder){ (buffer), (size), 0, {0,0,NULL},{NULL,NULL}}) #define SPA_POD_BUILDER_INIT(buffer,size) ((struct spa_pod_builder){ (buffer), (size), 0, {0,0,NULL},{NULL,NULL}})
SPA_API_IMPL void SPA_API_POD_BUILDER void
spa_pod_builder_get_state(struct spa_pod_builder *builder, struct spa_pod_builder_state *state) spa_pod_builder_get_state(struct spa_pod_builder *builder, struct spa_pod_builder_state *state)
{ {
*state = builder->state; *state = builder->state;
} }
SPA_API_IMPL void SPA_API_POD_BUILDER void
spa_pod_builder_set_callbacks(struct spa_pod_builder *builder, spa_pod_builder_set_callbacks(struct spa_pod_builder *builder,
const struct spa_pod_builder_callbacks *callbacks, void *data) const struct spa_pod_builder_callbacks *callbacks, void *data)
{ {
builder->callbacks = SPA_CALLBACKS_INIT(callbacks, data); builder->callbacks = SPA_CALLBACKS_INIT(callbacks, data);
} }
SPA_API_IMPL void SPA_API_POD_BUILDER void
spa_pod_builder_reset(struct spa_pod_builder *builder, struct spa_pod_builder_state *state) spa_pod_builder_reset(struct spa_pod_builder *builder, struct spa_pod_builder_state *state)
{ {
struct spa_pod_frame *f; struct spa_pod_frame *f;
@ -74,12 +82,12 @@ spa_pod_builder_reset(struct spa_pod_builder *builder, struct spa_pod_builder_st
f->pod.size -= size; f->pod.size -= size;
} }
SPA_API_IMPL void spa_pod_builder_init(struct spa_pod_builder *builder, void *data, uint32_t size) SPA_API_POD_BUILDER void spa_pod_builder_init(struct spa_pod_builder *builder, void *data, uint32_t size)
{ {
*builder = SPA_POD_BUILDER_INIT(data, size); *builder = SPA_POD_BUILDER_INIT(data, size);
} }
SPA_API_IMPL struct spa_pod * SPA_API_POD_BUILDER struct spa_pod *
spa_pod_builder_deref(struct spa_pod_builder *builder, uint32_t offset) spa_pod_builder_deref(struct spa_pod_builder *builder, uint32_t offset)
{ {
uint32_t size = builder->size; uint32_t size = builder->size;
@ -91,7 +99,7 @@ spa_pod_builder_deref(struct spa_pod_builder *builder, uint32_t offset)
return NULL; return NULL;
} }
SPA_API_IMPL struct spa_pod * SPA_API_POD_BUILDER struct spa_pod *
spa_pod_builder_frame(struct spa_pod_builder *builder, struct spa_pod_frame *frame) spa_pod_builder_frame(struct spa_pod_builder *builder, struct spa_pod_frame *frame)
{ {
if (frame->offset + SPA_POD_SIZE(&frame->pod) <= builder->size) if (frame->offset + SPA_POD_SIZE(&frame->pod) <= builder->size)
@ -99,7 +107,7 @@ spa_pod_builder_frame(struct spa_pod_builder *builder, struct spa_pod_frame *fra
return NULL; return NULL;
} }
SPA_API_IMPL void SPA_API_POD_BUILDER void
spa_pod_builder_push(struct spa_pod_builder *builder, spa_pod_builder_push(struct spa_pod_builder *builder,
struct spa_pod_frame *frame, struct spa_pod_frame *frame,
const struct spa_pod *pod, const struct spa_pod *pod,
@ -115,7 +123,7 @@ spa_pod_builder_push(struct spa_pod_builder *builder,
builder->state.flags = SPA_POD_BUILDER_FLAG_FIRST | SPA_POD_BUILDER_FLAG_BODY; builder->state.flags = SPA_POD_BUILDER_FLAG_FIRST | SPA_POD_BUILDER_FLAG_BODY;
} }
SPA_API_IMPL int spa_pod_builder_raw(struct spa_pod_builder *builder, const void *data, uint32_t size) SPA_API_POD_BUILDER int spa_pod_builder_raw(struct spa_pod_builder *builder, const void *data, uint32_t size)
{ {
int res = 0; int res = 0;
struct spa_pod_frame *f; struct spa_pod_frame *f;
@ -139,14 +147,14 @@ SPA_API_IMPL int spa_pod_builder_raw(struct spa_pod_builder *builder, const void
return res; return res;
} }
SPA_API_IMPL int spa_pod_builder_pad(struct spa_pod_builder *builder, uint32_t size) SPA_API_POD_BUILDER int spa_pod_builder_pad(struct spa_pod_builder *builder, uint32_t size)
{ {
uint64_t zeroes = 0; uint64_t zeroes = 0;
size = SPA_ROUND_UP_N(size, 8) - size; size = SPA_ROUND_UP_N(size, 8) - size;
return size ? spa_pod_builder_raw(builder, &zeroes, size) : 0; return size ? spa_pod_builder_raw(builder, &zeroes, size) : 0;
} }
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_raw_padded(struct spa_pod_builder *builder, const void *data, uint32_t size) spa_pod_builder_raw_padded(struct spa_pod_builder *builder, const void *data, uint32_t size)
{ {
int r, res = spa_pod_builder_raw(builder, data, size); int r, res = spa_pod_builder_raw(builder, data, size);
@ -155,7 +163,7 @@ spa_pod_builder_raw_padded(struct spa_pod_builder *builder, const void *data, ui
return res; return res;
} }
SPA_API_IMPL void *spa_pod_builder_pop(struct spa_pod_builder *builder, struct spa_pod_frame *frame) SPA_API_POD_BUILDER void *spa_pod_builder_pop(struct spa_pod_builder *builder, struct spa_pod_frame *frame)
{ {
struct spa_pod *pod; struct spa_pod *pod;
@ -172,7 +180,7 @@ SPA_API_IMPL void *spa_pod_builder_pop(struct spa_pod_builder *builder, struct s
return pod; return pod;
} }
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod *p) spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod *p)
{ {
const void *data; const void *data;
@ -198,13 +206,13 @@ spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod
#define SPA_POD_INIT_None() SPA_POD_INIT(0, SPA_TYPE_None) #define SPA_POD_INIT_None() SPA_POD_INIT(0, SPA_TYPE_None)
SPA_API_IMPL int spa_pod_builder_none(struct spa_pod_builder *builder) SPA_API_POD_BUILDER int spa_pod_builder_none(struct spa_pod_builder *builder)
{ {
const struct spa_pod p = SPA_POD_INIT_None(); const struct spa_pod p = SPA_POD_INIT_None();
return spa_pod_builder_primitive(builder, &p); return spa_pod_builder_primitive(builder, &p);
} }
SPA_API_IMPL int spa_pod_builder_child(struct spa_pod_builder *builder, uint32_t size, uint32_t type) SPA_API_POD_BUILDER int spa_pod_builder_child(struct spa_pod_builder *builder, uint32_t size, uint32_t type)
{ {
const struct spa_pod p = SPA_POD_INIT(size,type); const struct spa_pod p = SPA_POD_INIT(size,type);
SPA_FLAG_CLEAR(builder->state.flags, SPA_POD_BUILDER_FLAG_FIRST); SPA_FLAG_CLEAR(builder->state.flags, SPA_POD_BUILDER_FLAG_FIRST);
@ -213,7 +221,7 @@ SPA_API_IMPL int spa_pod_builder_child(struct spa_pod_builder *builder, uint32_t
#define SPA_POD_INIT_Bool(val) ((struct spa_pod_bool){ { sizeof(uint32_t), SPA_TYPE_Bool }, (val) ? 1 : 0, 0 }) #define SPA_POD_INIT_Bool(val) ((struct spa_pod_bool){ { sizeof(uint32_t), SPA_TYPE_Bool }, (val) ? 1 : 0, 0 })
SPA_API_IMPL int spa_pod_builder_bool(struct spa_pod_builder *builder, bool val) SPA_API_POD_BUILDER int spa_pod_builder_bool(struct spa_pod_builder *builder, bool val)
{ {
const struct spa_pod_bool p = SPA_POD_INIT_Bool(val); const struct spa_pod_bool p = SPA_POD_INIT_Bool(val);
return spa_pod_builder_primitive(builder, &p.pod); return spa_pod_builder_primitive(builder, &p.pod);
@ -221,7 +229,7 @@ SPA_API_IMPL int spa_pod_builder_bool(struct spa_pod_builder *builder, bool val)
#define SPA_POD_INIT_Id(val) ((struct spa_pod_id){ { sizeof(uint32_t), SPA_TYPE_Id }, (val), 0 }) #define SPA_POD_INIT_Id(val) ((struct spa_pod_id){ { sizeof(uint32_t), SPA_TYPE_Id }, (val), 0 })
SPA_API_IMPL int spa_pod_builder_id(struct spa_pod_builder *builder, uint32_t val) SPA_API_POD_BUILDER int spa_pod_builder_id(struct spa_pod_builder *builder, uint32_t val)
{ {
const struct spa_pod_id p = SPA_POD_INIT_Id(val); const struct spa_pod_id p = SPA_POD_INIT_Id(val);
return spa_pod_builder_primitive(builder, &p.pod); return spa_pod_builder_primitive(builder, &p.pod);
@ -229,7 +237,7 @@ SPA_API_IMPL int spa_pod_builder_id(struct spa_pod_builder *builder, uint32_t va
#define SPA_POD_INIT_Int(val) ((struct spa_pod_int){ { sizeof(int32_t), SPA_TYPE_Int }, (val), 0 }) #define SPA_POD_INIT_Int(val) ((struct spa_pod_int){ { sizeof(int32_t), SPA_TYPE_Int }, (val), 0 })
SPA_API_IMPL int spa_pod_builder_int(struct spa_pod_builder *builder, int32_t val) SPA_API_POD_BUILDER int spa_pod_builder_int(struct spa_pod_builder *builder, int32_t val)
{ {
const struct spa_pod_int p = SPA_POD_INIT_Int(val); const struct spa_pod_int p = SPA_POD_INIT_Int(val);
return spa_pod_builder_primitive(builder, &p.pod); return spa_pod_builder_primitive(builder, &p.pod);
@ -237,7 +245,7 @@ SPA_API_IMPL int spa_pod_builder_int(struct spa_pod_builder *builder, int32_t va
#define SPA_POD_INIT_Long(val) ((struct spa_pod_long){ { sizeof(int64_t), SPA_TYPE_Long }, (val) }) #define SPA_POD_INIT_Long(val) ((struct spa_pod_long){ { sizeof(int64_t), SPA_TYPE_Long }, (val) })
SPA_API_IMPL int spa_pod_builder_long(struct spa_pod_builder *builder, int64_t val) SPA_API_POD_BUILDER int spa_pod_builder_long(struct spa_pod_builder *builder, int64_t val)
{ {
const struct spa_pod_long p = SPA_POD_INIT_Long(val); const struct spa_pod_long p = SPA_POD_INIT_Long(val);
return spa_pod_builder_primitive(builder, &p.pod); return spa_pod_builder_primitive(builder, &p.pod);
@ -245,7 +253,7 @@ SPA_API_IMPL int spa_pod_builder_long(struct spa_pod_builder *builder, int64_t v
#define SPA_POD_INIT_Float(val) ((struct spa_pod_float){ { sizeof(float), SPA_TYPE_Float }, (val), 0 }) #define SPA_POD_INIT_Float(val) ((struct spa_pod_float){ { sizeof(float), SPA_TYPE_Float }, (val), 0 })
SPA_API_IMPL int spa_pod_builder_float(struct spa_pod_builder *builder, float val) SPA_API_POD_BUILDER int spa_pod_builder_float(struct spa_pod_builder *builder, float val)
{ {
const struct spa_pod_float p = SPA_POD_INIT_Float(val); const struct spa_pod_float p = SPA_POD_INIT_Float(val);
return spa_pod_builder_primitive(builder, &p.pod); return spa_pod_builder_primitive(builder, &p.pod);
@ -253,7 +261,7 @@ SPA_API_IMPL int spa_pod_builder_float(struct spa_pod_builder *builder, float va
#define SPA_POD_INIT_Double(val) ((struct spa_pod_double){ { sizeof(double), SPA_TYPE_Double }, (val) }) #define SPA_POD_INIT_Double(val) ((struct spa_pod_double){ { sizeof(double), SPA_TYPE_Double }, (val) })
SPA_API_IMPL int spa_pod_builder_double(struct spa_pod_builder *builder, double val) SPA_API_POD_BUILDER int spa_pod_builder_double(struct spa_pod_builder *builder, double val)
{ {
const struct spa_pod_double p = SPA_POD_INIT_Double(val); const struct spa_pod_double p = SPA_POD_INIT_Double(val);
return spa_pod_builder_primitive(builder, &p.pod); return spa_pod_builder_primitive(builder, &p.pod);
@ -261,7 +269,7 @@ SPA_API_IMPL int spa_pod_builder_double(struct spa_pod_builder *builder, double
#define SPA_POD_INIT_String(len) ((struct spa_pod_string){ { (len), SPA_TYPE_String } }) #define SPA_POD_INIT_String(len) ((struct spa_pod_string){ { (len), SPA_TYPE_String } })
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_write_string(struct spa_pod_builder *builder, const char *str, uint32_t len) spa_pod_builder_write_string(struct spa_pod_builder *builder, const char *str, uint32_t len)
{ {
int r, res; int r, res;
@ -273,7 +281,7 @@ spa_pod_builder_write_string(struct spa_pod_builder *builder, const char *str, u
return res; return res;
} }
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_string_len(struct spa_pod_builder *builder, const char *str, uint32_t len) spa_pod_builder_string_len(struct spa_pod_builder *builder, const char *str, uint32_t len)
{ {
const struct spa_pod_string p = SPA_POD_INIT_String(len+1); const struct spa_pod_string p = SPA_POD_INIT_String(len+1);
@ -283,7 +291,7 @@ spa_pod_builder_string_len(struct spa_pod_builder *builder, const char *str, uin
return res; return res;
} }
SPA_API_IMPL int spa_pod_builder_string(struct spa_pod_builder *builder, const char *str) SPA_API_POD_BUILDER int spa_pod_builder_string(struct spa_pod_builder *builder, const char *str)
{ {
uint32_t len = str ? strlen(str) : 0; uint32_t len = str ? strlen(str) : 0;
return spa_pod_builder_string_len(builder, str ? str : "", len); return spa_pod_builder_string_len(builder, str ? str : "", len);
@ -291,7 +299,7 @@ SPA_API_IMPL int spa_pod_builder_string(struct spa_pod_builder *builder, const c
#define SPA_POD_INIT_Bytes(len) ((struct spa_pod_bytes){ { (len), SPA_TYPE_Bytes } }) #define SPA_POD_INIT_Bytes(len) ((struct spa_pod_bytes){ { (len), SPA_TYPE_Bytes } })
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_bytes(struct spa_pod_builder *builder, const void *bytes, uint32_t len) spa_pod_builder_bytes(struct spa_pod_builder *builder, const void *bytes, uint32_t len)
{ {
const struct spa_pod_bytes p = SPA_POD_INIT_Bytes(len); const struct spa_pod_bytes p = SPA_POD_INIT_Bytes(len);
@ -300,7 +308,7 @@ spa_pod_builder_bytes(struct spa_pod_builder *builder, const void *bytes, uint32
res = r; res = r;
return res; return res;
} }
SPA_API_IMPL void * SPA_API_POD_BUILDER void *
spa_pod_builder_reserve_bytes(struct spa_pod_builder *builder, uint32_t len) spa_pod_builder_reserve_bytes(struct spa_pod_builder *builder, uint32_t len)
{ {
uint32_t offset = builder->state.offset; uint32_t offset = builder->state.offset;
@ -311,7 +319,7 @@ spa_pod_builder_reserve_bytes(struct spa_pod_builder *builder, uint32_t len)
#define SPA_POD_INIT_Pointer(type,value) ((struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_TYPE_Pointer }, { (type), 0, (value) } }) #define SPA_POD_INIT_Pointer(type,value) ((struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_TYPE_Pointer }, { (type), 0, (value) } })
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, const void *val) spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, const void *val)
{ {
const struct spa_pod_pointer p = SPA_POD_INIT_Pointer(type, val); const struct spa_pod_pointer p = SPA_POD_INIT_Pointer(type, val);
@ -320,7 +328,7 @@ spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, const vo
#define SPA_POD_INIT_Fd(fd) ((struct spa_pod_fd){ { sizeof(int64_t), SPA_TYPE_Fd }, (fd) }) #define SPA_POD_INIT_Fd(fd) ((struct spa_pod_fd){ { sizeof(int64_t), SPA_TYPE_Fd }, (fd) })
SPA_API_IMPL int spa_pod_builder_fd(struct spa_pod_builder *builder, int64_t fd) SPA_API_POD_BUILDER int spa_pod_builder_fd(struct spa_pod_builder *builder, int64_t fd)
{ {
const struct spa_pod_fd p = SPA_POD_INIT_Fd(fd); const struct spa_pod_fd p = SPA_POD_INIT_Fd(fd);
return spa_pod_builder_primitive(builder, &p.pod); return spa_pod_builder_primitive(builder, &p.pod);
@ -328,7 +336,7 @@ SPA_API_IMPL int spa_pod_builder_fd(struct spa_pod_builder *builder, int64_t fd)
#define SPA_POD_INIT_Rectangle(val) ((struct spa_pod_rectangle){ { sizeof(struct spa_rectangle), SPA_TYPE_Rectangle }, (val) }) #define SPA_POD_INIT_Rectangle(val) ((struct spa_pod_rectangle){ { sizeof(struct spa_rectangle), SPA_TYPE_Rectangle }, (val) })
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_rectangle(struct spa_pod_builder *builder, uint32_t width, uint32_t height) spa_pod_builder_rectangle(struct spa_pod_builder *builder, uint32_t width, uint32_t height)
{ {
const struct spa_pod_rectangle p = SPA_POD_INIT_Rectangle(SPA_RECTANGLE(width, height)); const struct spa_pod_rectangle p = SPA_POD_INIT_Rectangle(SPA_RECTANGLE(width, height));
@ -337,14 +345,14 @@ spa_pod_builder_rectangle(struct spa_pod_builder *builder, uint32_t width, uint3
#define SPA_POD_INIT_Fraction(val) ((struct spa_pod_fraction){ { sizeof(struct spa_fraction), SPA_TYPE_Fraction }, (val) }) #define SPA_POD_INIT_Fraction(val) ((struct spa_pod_fraction){ { sizeof(struct spa_fraction), SPA_TYPE_Fraction }, (val) })
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_fraction(struct spa_pod_builder *builder, uint32_t num, uint32_t denom) spa_pod_builder_fraction(struct spa_pod_builder *builder, uint32_t num, uint32_t denom)
{ {
const struct spa_pod_fraction p = SPA_POD_INIT_Fraction(SPA_FRACTION(num, denom)); const struct spa_pod_fraction p = SPA_POD_INIT_Fraction(SPA_FRACTION(num, denom));
return spa_pod_builder_primitive(builder, &p.pod); return spa_pod_builder_primitive(builder, &p.pod);
} }
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_push_array(struct spa_pod_builder *builder, struct spa_pod_frame *frame) spa_pod_builder_push_array(struct spa_pod_builder *builder, struct spa_pod_frame *frame)
{ {
const struct spa_pod_array p = const struct spa_pod_array p =
@ -356,7 +364,7 @@ spa_pod_builder_push_array(struct spa_pod_builder *builder, struct spa_pod_frame
return res; return res;
} }
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_array(struct spa_pod_builder *builder, spa_pod_builder_array(struct spa_pod_builder *builder,
uint32_t child_size, uint32_t child_type, uint32_t n_elems, const void *elems) uint32_t child_size, uint32_t child_type, uint32_t n_elems, const void *elems)
{ {
@ -378,7 +386,7 @@ spa_pod_builder_array(struct spa_pod_builder *builder,
{ { { (n_vals) * sizeof(ctype) + sizeof(struct spa_pod_choice_body), SPA_TYPE_Choice }, \ { { { (n_vals) * sizeof(ctype) + sizeof(struct spa_pod_choice_body), SPA_TYPE_Choice }, \
{ (type), 0, { sizeof(ctype), (child_type) } } }, { __VA_ARGS__ } }) { (type), 0, { sizeof(ctype), (child_type) } } }, { __VA_ARGS__ } })
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_push_choice(struct spa_pod_builder *builder, struct spa_pod_frame *frame, spa_pod_builder_push_choice(struct spa_pod_builder *builder, struct spa_pod_frame *frame,
uint32_t type, uint32_t flags) uint32_t type, uint32_t flags)
{ {
@ -393,7 +401,7 @@ spa_pod_builder_push_choice(struct spa_pod_builder *builder, struct spa_pod_fram
#define SPA_POD_INIT_Struct(size) ((struct spa_pod_struct){ { (size), SPA_TYPE_Struct } }) #define SPA_POD_INIT_Struct(size) ((struct spa_pod_struct){ { (size), SPA_TYPE_Struct } })
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_push_struct(struct spa_pod_builder *builder, struct spa_pod_frame *frame) spa_pod_builder_push_struct(struct spa_pod_builder *builder, struct spa_pod_frame *frame)
{ {
const struct spa_pod_struct p = SPA_POD_INIT_Struct(0); const struct spa_pod_struct p = SPA_POD_INIT_Struct(0);
@ -405,7 +413,7 @@ spa_pod_builder_push_struct(struct spa_pod_builder *builder, struct spa_pod_fram
#define SPA_POD_INIT_Object(size,type,id,...) ((struct spa_pod_object){ { (size), SPA_TYPE_Object }, { (type), (id) }, ##__VA_ARGS__ }) #define SPA_POD_INIT_Object(size,type,id,...) ((struct spa_pod_object){ { (size), SPA_TYPE_Object }, { (type), (id) }, ##__VA_ARGS__ })
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_push_object(struct spa_pod_builder *builder, struct spa_pod_frame *frame, spa_pod_builder_push_object(struct spa_pod_builder *builder, struct spa_pod_frame *frame,
uint32_t type, uint32_t id) uint32_t type, uint32_t id)
{ {
@ -420,7 +428,7 @@ spa_pod_builder_push_object(struct spa_pod_builder *builder, struct spa_pod_fram
#define SPA_POD_INIT_Prop(key,flags,size,type) \ #define SPA_POD_INIT_Prop(key,flags,size,type) \
((struct spa_pod_prop){ (key), (flags), { (size), (type) } }) ((struct spa_pod_prop){ (key), (flags), { (size), (type) } })
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_prop(struct spa_pod_builder *builder, uint32_t key, uint32_t flags) spa_pod_builder_prop(struct spa_pod_builder *builder, uint32_t key, uint32_t flags)
{ {
const struct { uint32_t key; uint32_t flags; } p = { key, flags }; const struct { uint32_t key; uint32_t flags; } p = { key, flags };
@ -430,7 +438,7 @@ spa_pod_builder_prop(struct spa_pod_builder *builder, uint32_t key, uint32_t fla
#define SPA_POD_INIT_Sequence(size,unit) \ #define SPA_POD_INIT_Sequence(size,unit) \
((struct spa_pod_sequence){ { (size), SPA_TYPE_Sequence}, {(unit), 0 } }) ((struct spa_pod_sequence){ { (size), SPA_TYPE_Sequence}, {(unit), 0 } })
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_push_sequence(struct spa_pod_builder *builder, struct spa_pod_frame *frame, uint32_t unit) spa_pod_builder_push_sequence(struct spa_pod_builder *builder, struct spa_pod_frame *frame, uint32_t unit)
{ {
const struct spa_pod_sequence p = const struct spa_pod_sequence p =
@ -441,14 +449,14 @@ spa_pod_builder_push_sequence(struct spa_pod_builder *builder, struct spa_pod_fr
return res; return res;
} }
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_control(struct spa_pod_builder *builder, uint32_t offset, uint32_t type) spa_pod_builder_control(struct spa_pod_builder *builder, uint32_t offset, uint32_t type)
{ {
const struct { uint32_t offset; uint32_t type; } p = { offset, type }; const struct { uint32_t offset; uint32_t type; } p = { offset, type };
return spa_pod_builder_raw(builder, &p, sizeof(p)); return spa_pod_builder_raw(builder, &p, sizeof(p));
} }
SPA_API_IMPL uint32_t spa_choice_from_id(char id) SPA_API_POD_BUILDER uint32_t spa_choice_from_id(char id)
{ {
switch (id) { switch (id) {
case 'r': case 'r':
@ -560,7 +568,7 @@ do { \
} \ } \
} while(false) } while(false)
SPA_API_IMPL int SPA_API_POD_BUILDER int
spa_pod_builder_addv(struct spa_pod_builder *builder, va_list args) spa_pod_builder_addv(struct spa_pod_builder *builder, va_list args)
{ {
int res = 0; int res = 0;
@ -618,7 +626,7 @@ spa_pod_builder_addv(struct spa_pod_builder *builder, va_list args)
return res; return res;
} }
SPA_API_IMPL int spa_pod_builder_add(struct spa_pod_builder *builder, ...) SPA_API_POD_BUILDER int spa_pod_builder_add(struct spa_pod_builder *builder, ...)
{ {
int res; int res;
va_list args; va_list args;
@ -658,7 +666,7 @@ SPA_API_IMPL int spa_pod_builder_add(struct spa_pod_builder *builder, ...)
}) })
/** Copy a pod structure */ /** Copy a pod structure */
SPA_API_IMPL struct spa_pod * SPA_API_POD_BUILDER struct spa_pod *
spa_pod_copy(const struct spa_pod *pod) spa_pod_copy(const struct spa_pod *pod)
{ {
size_t size; size_t size;

View file

@ -20,12 +20,20 @@ extern "C" {
#include <spa/pod/iter.h> #include <spa/pod/iter.h>
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#ifndef SPA_API_POD_COMPARE
#ifdef SPA_API_IMPL
#define SPA_API_POD_COMPARE SPA_API_IMPL
#else
#define SPA_API_POD_COMPARE static inline
#endif
#endif
/** /**
* \addtogroup spa_pod * \addtogroup spa_pod
* \{ * \{
*/ */
SPA_API_IMPL int spa_pod_compare_value(uint32_t type, const void *r1, const void *r2, uint32_t size) SPA_API_POD_COMPARE int spa_pod_compare_value(uint32_t type, const void *r1, const void *r2, uint32_t size)
{ {
switch (type) { switch (type) {
case SPA_TYPE_None: case SPA_TYPE_None:
@ -72,7 +80,7 @@ SPA_API_IMPL int spa_pod_compare_value(uint32_t type, const void *r1, const void
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_compare(const struct spa_pod *pod1, SPA_API_POD_COMPARE int spa_pod_compare(const struct spa_pod *pod1,
const struct spa_pod *pod2) const struct spa_pod *pod2)
{ {
int res = 0; int res = 0;

View file

@ -12,6 +12,14 @@ extern "C" {
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#include <spa/utils/cleanup.h> #include <spa/utils/cleanup.h>
#ifndef SPA_API_POD_DYNAMIC
#ifdef SPA_API_IMPL
#define SPA_API_POD_DYNAMIC SPA_API_IMPL
#else
#define SPA_API_POD_DYNAMIC static inline
#endif
#endif
struct spa_pod_dynamic_builder { struct spa_pod_dynamic_builder {
struct spa_pod_builder b; struct spa_pod_builder b;
void *data; void *data;
@ -37,7 +45,7 @@ static int spa_pod_dynamic_builder_overflow(void *data, uint32_t size)
return 0; return 0;
} }
SPA_API_IMPL void spa_pod_dynamic_builder_init(struct spa_pod_dynamic_builder *builder, SPA_API_POD_DYNAMIC void spa_pod_dynamic_builder_init(struct spa_pod_dynamic_builder *builder,
void *data, uint32_t size, uint32_t extend) void *data, uint32_t size, uint32_t extend)
{ {
static const struct spa_pod_builder_callbacks spa_pod_dynamic_builder_callbacks = { static const struct spa_pod_builder_callbacks spa_pod_dynamic_builder_callbacks = {
@ -50,7 +58,7 @@ SPA_API_IMPL void spa_pod_dynamic_builder_init(struct spa_pod_dynamic_builder *b
builder->data = data; builder->data = data;
} }
SPA_API_IMPL void spa_pod_dynamic_builder_clean(struct spa_pod_dynamic_builder *builder) SPA_API_POD_DYNAMIC void spa_pod_dynamic_builder_clean(struct spa_pod_dynamic_builder *builder)
{ {
if (builder->data != builder->b.data) if (builder->data != builder->b.data)
free(builder->b.data); free(builder->b.data);

View file

@ -20,12 +20,20 @@ extern "C" {
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#include <spa/pod/compare.h> #include <spa/pod/compare.h>
#ifndef SPA_API_POD_FILTER
#ifdef SPA_API_IMPL
#define SPA_API_POD_FILTER SPA_API_IMPL
#else
#define SPA_API_POD_FILTER static inline
#endif
#endif
/** /**
* \addtogroup spa_pod * \addtogroup spa_pod
* \{ * \{
*/ */
SPA_API_IMPL int spa_pod_choice_fix_default(struct spa_pod_choice *choice) SPA_API_POD_FILTER int spa_pod_choice_fix_default(struct spa_pod_choice *choice)
{ {
void *val, *alt; void *val, *alt;
int i, nvals; int i, nvals;
@ -77,7 +85,7 @@ SPA_API_IMPL int spa_pod_choice_fix_default(struct spa_pod_choice *choice)
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_filter_flags_value(struct spa_pod_builder *b, SPA_API_POD_FILTER int spa_pod_filter_flags_value(struct spa_pod_builder *b,
uint32_t type, const void *r1, const void *r2, uint32_t size SPA_UNUSED) uint32_t type, const void *r1, const void *r2, uint32_t size SPA_UNUSED)
{ {
switch (type) { switch (type) {
@ -103,7 +111,7 @@ SPA_API_IMPL int spa_pod_filter_flags_value(struct spa_pod_builder *b,
return 1; return 1;
} }
SPA_API_IMPL int spa_pod_filter_is_step_of(uint32_t type, const void *r1, SPA_API_POD_FILTER int spa_pod_filter_is_step_of(uint32_t type, const void *r1,
const void *r2, uint32_t size SPA_UNUSED) const void *r2, uint32_t size SPA_UNUSED)
{ {
switch (type) { switch (type) {
@ -125,7 +133,7 @@ SPA_API_IMPL int spa_pod_filter_is_step_of(uint32_t type, const void *r1,
return 0; return 0;
} }
SPA_API_IMPL int SPA_API_POD_FILTER int
spa_pod_filter_prop(struct spa_pod_builder *b, spa_pod_filter_prop(struct spa_pod_builder *b,
const struct spa_pod_prop *p1, const struct spa_pod_prop *p1,
const struct spa_pod_prop *p2) const struct spa_pod_prop *p2)
@ -322,7 +330,7 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_filter_part(struct spa_pod_builder *b, SPA_API_POD_FILTER int spa_pod_filter_part(struct spa_pod_builder *b,
const struct spa_pod *pod, uint32_t pod_size, const struct spa_pod *pod, uint32_t pod_size,
const struct spa_pod *filter, uint32_t filter_size) const struct spa_pod *filter, uint32_t filter_size)
{ {
@ -422,7 +430,7 @@ SPA_API_IMPL int spa_pod_filter_part(struct spa_pod_builder *b,
return res; return res;
} }
SPA_API_IMPL int SPA_API_POD_FILTER int
spa_pod_filter(struct spa_pod_builder *b, spa_pod_filter(struct spa_pod_builder *b,
struct spa_pod **result, struct spa_pod **result,
const struct spa_pod *pod, const struct spa_pod *pod,

View file

@ -14,6 +14,14 @@ extern "C" {
#include <spa/pod/pod.h> #include <spa/pod/pod.h>
#ifndef SPA_API_POD_ITER
#ifdef SPA_API_IMPL
#define SPA_API_POD_ITER SPA_API_IMPL
#else
#define SPA_API_POD_ITER static inline
#endif
#endif
/** /**
* \addtogroup spa_pod * \addtogroup spa_pod
* \{ * \{
@ -26,7 +34,7 @@ struct spa_pod_frame {
uint32_t flags; uint32_t flags;
}; };
SPA_API_IMPL bool spa_pod_is_inside(const void *pod, uint32_t size, const void *iter) SPA_API_POD_ITER bool spa_pod_is_inside(const void *pod, uint32_t size, const void *iter)
{ {
size_t remaining; size_t remaining;
@ -34,17 +42,17 @@ SPA_API_IMPL bool spa_pod_is_inside(const void *pod, uint32_t size, const void *
remaining >= SPA_POD_BODY_SIZE(iter); remaining >= SPA_POD_BODY_SIZE(iter);
} }
SPA_API_IMPL void *spa_pod_next(const void *iter) SPA_API_POD_ITER void *spa_pod_next(const void *iter)
{ {
return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_SIZE(iter), 8), void); return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_SIZE(iter), 8), void);
} }
SPA_API_IMPL struct spa_pod_prop *spa_pod_prop_first(const struct spa_pod_object_body *body) SPA_API_POD_ITER struct spa_pod_prop *spa_pod_prop_first(const struct spa_pod_object_body *body)
{ {
return SPA_PTROFF(body, sizeof(struct spa_pod_object_body), struct spa_pod_prop); return SPA_PTROFF(body, sizeof(struct spa_pod_object_body), struct spa_pod_prop);
} }
SPA_API_IMPL bool spa_pod_prop_is_inside(const struct spa_pod_object_body *body, SPA_API_POD_ITER bool spa_pod_prop_is_inside(const struct spa_pod_object_body *body,
uint32_t size, const struct spa_pod_prop *iter) uint32_t size, const struct spa_pod_prop *iter)
{ {
size_t remaining; size_t remaining;
@ -53,17 +61,17 @@ SPA_API_IMPL bool spa_pod_prop_is_inside(const struct spa_pod_object_body *body,
remaining >= iter->value.size; remaining >= iter->value.size;
} }
SPA_API_IMPL struct spa_pod_prop *spa_pod_prop_next(const struct spa_pod_prop *iter) SPA_API_POD_ITER struct spa_pod_prop *spa_pod_prop_next(const struct spa_pod_prop *iter)
{ {
return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_PROP_SIZE(iter), 8), struct spa_pod_prop); return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_PROP_SIZE(iter), 8), struct spa_pod_prop);
} }
SPA_API_IMPL struct spa_pod_control *spa_pod_control_first(const struct spa_pod_sequence_body *body) SPA_API_POD_ITER struct spa_pod_control *spa_pod_control_first(const struct spa_pod_sequence_body *body)
{ {
return SPA_PTROFF(body, sizeof(struct spa_pod_sequence_body), struct spa_pod_control); return SPA_PTROFF(body, sizeof(struct spa_pod_sequence_body), struct spa_pod_control);
} }
SPA_API_IMPL bool spa_pod_control_is_inside(const struct spa_pod_sequence_body *body, SPA_API_POD_ITER bool spa_pod_control_is_inside(const struct spa_pod_sequence_body *body,
uint32_t size, const struct spa_pod_control *iter) uint32_t size, const struct spa_pod_control *iter)
{ {
size_t remaining; size_t remaining;
@ -72,7 +80,7 @@ SPA_API_IMPL bool spa_pod_control_is_inside(const struct spa_pod_sequence_body *
remaining >= iter->value.size; remaining >= iter->value.size;
} }
SPA_API_IMPL struct spa_pod_control *spa_pod_control_next(const struct spa_pod_control *iter) SPA_API_POD_ITER struct spa_pod_control *spa_pod_control_next(const struct spa_pod_control *iter)
{ {
return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_CONTROL_SIZE(iter), 8), struct spa_pod_control); return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_CONTROL_SIZE(iter), 8), struct spa_pod_control);
} }
@ -118,7 +126,7 @@ SPA_API_IMPL struct spa_pod_control *spa_pod_control_next(const struct spa_pod_c
SPA_POD_SEQUENCE_BODY_FOREACH(&(seq)->body, SPA_POD_BODY_SIZE(seq), iter) SPA_POD_SEQUENCE_BODY_FOREACH(&(seq)->body, SPA_POD_BODY_SIZE(seq), iter)
SPA_API_IMPL void *spa_pod_from_data(void *data, size_t maxsize, off_t offset, size_t size) SPA_API_POD_ITER void *spa_pod_from_data(void *data, size_t maxsize, off_t offset, size_t size)
{ {
void *pod; void *pod;
if (size < sizeof(struct spa_pod) || offset + size > maxsize) if (size < sizeof(struct spa_pod) || offset + size > maxsize)
@ -129,17 +137,17 @@ SPA_API_IMPL void *spa_pod_from_data(void *data, size_t maxsize, off_t offset, s
return pod; return pod;
} }
SPA_API_IMPL int spa_pod_is_none(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_none(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_None); return (SPA_POD_TYPE(pod) == SPA_TYPE_None);
} }
SPA_API_IMPL int spa_pod_is_bool(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_bool(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Bool && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t)); return (SPA_POD_TYPE(pod) == SPA_TYPE_Bool && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t));
} }
SPA_API_IMPL int spa_pod_get_bool(const struct spa_pod *pod, bool *value) SPA_API_POD_ITER int spa_pod_get_bool(const struct spa_pod *pod, bool *value)
{ {
if (!spa_pod_is_bool(pod)) if (!spa_pod_is_bool(pod))
return -EINVAL; return -EINVAL;
@ -147,12 +155,12 @@ SPA_API_IMPL int spa_pod_get_bool(const struct spa_pod *pod, bool *value)
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_id(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_id(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Id && SPA_POD_BODY_SIZE(pod) >= sizeof(uint32_t)); return (SPA_POD_TYPE(pod) == SPA_TYPE_Id && SPA_POD_BODY_SIZE(pod) >= sizeof(uint32_t));
} }
SPA_API_IMPL int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value) SPA_API_POD_ITER int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value)
{ {
if (!spa_pod_is_id(pod)) if (!spa_pod_is_id(pod))
return -EINVAL; return -EINVAL;
@ -160,12 +168,12 @@ SPA_API_IMPL int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value)
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_int(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_int(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Int && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t)); return (SPA_POD_TYPE(pod) == SPA_TYPE_Int && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_t));
} }
SPA_API_IMPL int spa_pod_get_int(const struct spa_pod *pod, int32_t *value) SPA_API_POD_ITER int spa_pod_get_int(const struct spa_pod *pod, int32_t *value)
{ {
if (!spa_pod_is_int(pod)) if (!spa_pod_is_int(pod))
return -EINVAL; return -EINVAL;
@ -173,12 +181,12 @@ SPA_API_IMPL int spa_pod_get_int(const struct spa_pod *pod, int32_t *value)
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_long(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_long(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Long && SPA_POD_BODY_SIZE(pod) >= sizeof(int64_t)); return (SPA_POD_TYPE(pod) == SPA_TYPE_Long && SPA_POD_BODY_SIZE(pod) >= sizeof(int64_t));
} }
SPA_API_IMPL int spa_pod_get_long(const struct spa_pod *pod, int64_t *value) SPA_API_POD_ITER int spa_pod_get_long(const struct spa_pod *pod, int64_t *value)
{ {
if (!spa_pod_is_long(pod)) if (!spa_pod_is_long(pod))
return -EINVAL; return -EINVAL;
@ -186,12 +194,12 @@ SPA_API_IMPL int spa_pod_get_long(const struct spa_pod *pod, int64_t *value)
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_float(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_float(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Float && SPA_POD_BODY_SIZE(pod) >= sizeof(float)); return (SPA_POD_TYPE(pod) == SPA_TYPE_Float && SPA_POD_BODY_SIZE(pod) >= sizeof(float));
} }
SPA_API_IMPL int spa_pod_get_float(const struct spa_pod *pod, float *value) SPA_API_POD_ITER int spa_pod_get_float(const struct spa_pod *pod, float *value)
{ {
if (!spa_pod_is_float(pod)) if (!spa_pod_is_float(pod))
return -EINVAL; return -EINVAL;
@ -199,12 +207,12 @@ SPA_API_IMPL int spa_pod_get_float(const struct spa_pod *pod, float *value)
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_double(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_double(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Double && SPA_POD_BODY_SIZE(pod) >= sizeof(double)); return (SPA_POD_TYPE(pod) == SPA_TYPE_Double && SPA_POD_BODY_SIZE(pod) >= sizeof(double));
} }
SPA_API_IMPL int spa_pod_get_double(const struct spa_pod *pod, double *value) SPA_API_POD_ITER int spa_pod_get_double(const struct spa_pod *pod, double *value)
{ {
if (!spa_pod_is_double(pod)) if (!spa_pod_is_double(pod))
return -EINVAL; return -EINVAL;
@ -212,7 +220,7 @@ SPA_API_IMPL int spa_pod_get_double(const struct spa_pod *pod, double *value)
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_string(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_string(const struct spa_pod *pod)
{ {
const char *s = (const char *)SPA_POD_CONTENTS(struct spa_pod_string, pod); const char *s = (const char *)SPA_POD_CONTENTS(struct spa_pod_string, pod);
return (SPA_POD_TYPE(pod) == SPA_TYPE_String && return (SPA_POD_TYPE(pod) == SPA_TYPE_String &&
@ -220,7 +228,7 @@ SPA_API_IMPL int spa_pod_is_string(const struct spa_pod *pod)
s[SPA_POD_BODY_SIZE(pod)-1] == '\0'); s[SPA_POD_BODY_SIZE(pod)-1] == '\0');
} }
SPA_API_IMPL int spa_pod_get_string(const struct spa_pod *pod, const char **value) SPA_API_POD_ITER int spa_pod_get_string(const struct spa_pod *pod, const char **value)
{ {
if (!spa_pod_is_string(pod)) if (!spa_pod_is_string(pod))
return -EINVAL; return -EINVAL;
@ -228,7 +236,7 @@ SPA_API_IMPL int spa_pod_get_string(const struct spa_pod *pod, const char **valu
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_copy_string(const struct spa_pod *pod, size_t maxlen, char *dest) SPA_API_POD_ITER int spa_pod_copy_string(const struct spa_pod *pod, size_t maxlen, char *dest)
{ {
const char *s = (const char *)SPA_POD_CONTENTS(struct spa_pod_string, pod); const char *s = (const char *)SPA_POD_CONTENTS(struct spa_pod_string, pod);
if (!spa_pod_is_string(pod) || maxlen < 1) if (!spa_pod_is_string(pod) || maxlen < 1)
@ -238,12 +246,12 @@ SPA_API_IMPL int spa_pod_copy_string(const struct spa_pod *pod, size_t maxlen, c
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_bytes(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_bytes(const struct spa_pod *pod)
{ {
return SPA_POD_TYPE(pod) == SPA_TYPE_Bytes; return SPA_POD_TYPE(pod) == SPA_TYPE_Bytes;
} }
SPA_API_IMPL int spa_pod_get_bytes(const struct spa_pod *pod, const void **value, uint32_t *len) SPA_API_POD_ITER int spa_pod_get_bytes(const struct spa_pod *pod, const void **value, uint32_t *len)
{ {
if (!spa_pod_is_bytes(pod)) if (!spa_pod_is_bytes(pod))
return -EINVAL; return -EINVAL;
@ -252,13 +260,13 @@ SPA_API_IMPL int spa_pod_get_bytes(const struct spa_pod *pod, const void **value
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_pointer(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_pointer(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Pointer && return (SPA_POD_TYPE(pod) == SPA_TYPE_Pointer &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_pointer_body)); SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_pointer_body));
} }
SPA_API_IMPL int spa_pod_get_pointer(const struct spa_pod *pod, uint32_t *type, const void **value) SPA_API_POD_ITER int spa_pod_get_pointer(const struct spa_pod *pod, uint32_t *type, const void **value)
{ {
if (!spa_pod_is_pointer(pod)) if (!spa_pod_is_pointer(pod))
return -EINVAL; return -EINVAL;
@ -267,13 +275,13 @@ SPA_API_IMPL int spa_pod_get_pointer(const struct spa_pod *pod, uint32_t *type,
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_fd(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_fd(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Fd && return (SPA_POD_TYPE(pod) == SPA_TYPE_Fd &&
SPA_POD_BODY_SIZE(pod) >= sizeof(int64_t)); SPA_POD_BODY_SIZE(pod) >= sizeof(int64_t));
} }
SPA_API_IMPL int spa_pod_get_fd(const struct spa_pod *pod, int64_t *value) SPA_API_POD_ITER int spa_pod_get_fd(const struct spa_pod *pod, int64_t *value)
{ {
if (!spa_pod_is_fd(pod)) if (!spa_pod_is_fd(pod))
return -EINVAL; return -EINVAL;
@ -281,13 +289,13 @@ SPA_API_IMPL int spa_pod_get_fd(const struct spa_pod *pod, int64_t *value)
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_rectangle(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_rectangle(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Rectangle && return (SPA_POD_TYPE(pod) == SPA_TYPE_Rectangle &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_rectangle)); SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_rectangle));
} }
SPA_API_IMPL int spa_pod_get_rectangle(const struct spa_pod *pod, struct spa_rectangle *value) SPA_API_POD_ITER int spa_pod_get_rectangle(const struct spa_pod *pod, struct spa_rectangle *value)
{ {
if (!spa_pod_is_rectangle(pod)) if (!spa_pod_is_rectangle(pod))
return -EINVAL; return -EINVAL;
@ -295,39 +303,39 @@ SPA_API_IMPL int spa_pod_get_rectangle(const struct spa_pod *pod, struct spa_rec
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_fraction(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_fraction(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Fraction && return (SPA_POD_TYPE(pod) == SPA_TYPE_Fraction &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_fraction)); SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_fraction));
} }
SPA_API_IMPL int spa_pod_get_fraction(const struct spa_pod *pod, struct spa_fraction *value) SPA_API_POD_ITER int spa_pod_get_fraction(const struct spa_pod *pod, struct spa_fraction *value)
{ {
spa_return_val_if_fail(spa_pod_is_fraction(pod), -EINVAL); spa_return_val_if_fail(spa_pod_is_fraction(pod), -EINVAL);
*value = SPA_POD_VALUE(struct spa_pod_fraction, pod); *value = SPA_POD_VALUE(struct spa_pod_fraction, pod);
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_bitmap(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_bitmap(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Bitmap && return (SPA_POD_TYPE(pod) == SPA_TYPE_Bitmap &&
SPA_POD_BODY_SIZE(pod) >= sizeof(uint8_t)); SPA_POD_BODY_SIZE(pod) >= sizeof(uint8_t));
} }
SPA_API_IMPL int spa_pod_is_array(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_array(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Array && return (SPA_POD_TYPE(pod) == SPA_TYPE_Array &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_array_body)); SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_array_body));
} }
SPA_API_IMPL void *spa_pod_get_array(const struct spa_pod *pod, uint32_t *n_values) SPA_API_POD_ITER void *spa_pod_get_array(const struct spa_pod *pod, uint32_t *n_values)
{ {
spa_return_val_if_fail(spa_pod_is_array(pod), NULL); spa_return_val_if_fail(spa_pod_is_array(pod), NULL);
*n_values = SPA_POD_ARRAY_N_VALUES(pod); *n_values = SPA_POD_ARRAY_N_VALUES(pod);
return SPA_POD_ARRAY_VALUES(pod); return SPA_POD_ARRAY_VALUES(pod);
} }
SPA_API_IMPL uint32_t spa_pod_copy_array(const struct spa_pod *pod, uint32_t type, SPA_API_POD_ITER uint32_t spa_pod_copy_array(const struct spa_pod *pod, uint32_t type,
void *values, uint32_t max_values) void *values, uint32_t max_values)
{ {
uint32_t n_values; uint32_t n_values;
@ -339,13 +347,13 @@ SPA_API_IMPL uint32_t spa_pod_copy_array(const struct spa_pod *pod, uint32_t typ
return n_values; return n_values;
} }
SPA_API_IMPL int spa_pod_is_choice(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_choice(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Choice && return (SPA_POD_TYPE(pod) == SPA_TYPE_Choice &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_choice_body)); SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_choice_body));
} }
SPA_API_IMPL struct spa_pod *spa_pod_get_values(const struct spa_pod *pod, uint32_t *n_vals, uint32_t *choice) SPA_API_POD_ITER struct spa_pod *spa_pod_get_values(const struct spa_pod *pod, uint32_t *n_vals, uint32_t *choice)
{ {
if (pod->type == SPA_TYPE_Choice) { if (pod->type == SPA_TYPE_Choice) {
*n_vals = SPA_POD_CHOICE_N_VALUES(pod); *n_vals = SPA_POD_CHOICE_N_VALUES(pod);
@ -359,34 +367,34 @@ SPA_API_IMPL struct spa_pod *spa_pod_get_values(const struct spa_pod *pod, uint3
} }
} }
SPA_API_IMPL int spa_pod_is_struct(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_struct(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Struct); return (SPA_POD_TYPE(pod) == SPA_TYPE_Struct);
} }
SPA_API_IMPL int spa_pod_is_object(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_object(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Object && return (SPA_POD_TYPE(pod) == SPA_TYPE_Object &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_object_body)); SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_object_body));
} }
SPA_API_IMPL bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type) SPA_API_POD_ITER bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type)
{ {
return (pod && spa_pod_is_object(pod) && SPA_POD_OBJECT_TYPE(pod) == type); return (pod && spa_pod_is_object(pod) && SPA_POD_OBJECT_TYPE(pod) == type);
} }
SPA_API_IMPL bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id) SPA_API_POD_ITER bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id)
{ {
return (pod && spa_pod_is_object(pod) && SPA_POD_OBJECT_ID(pod) == id); return (pod && spa_pod_is_object(pod) && SPA_POD_OBJECT_ID(pod) == id);
} }
SPA_API_IMPL int spa_pod_is_sequence(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_sequence(const struct spa_pod *pod)
{ {
return (SPA_POD_TYPE(pod) == SPA_TYPE_Sequence && return (SPA_POD_TYPE(pod) == SPA_TYPE_Sequence &&
SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_sequence_body)); SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_sequence_body));
} }
SPA_API_IMPL const struct spa_pod_prop *spa_pod_object_find_prop(const struct spa_pod_object *pod, SPA_API_POD_ITER const struct spa_pod_prop *spa_pod_object_find_prop(const struct spa_pod_object *pod,
const struct spa_pod_prop *start, uint32_t key) const struct spa_pod_prop *start, uint32_t key)
{ {
const struct spa_pod_prop *first, *res; const struct spa_pod_prop *first, *res;
@ -406,7 +414,7 @@ SPA_API_IMPL const struct spa_pod_prop *spa_pod_object_find_prop(const struct sp
return NULL; return NULL;
} }
SPA_API_IMPL const struct spa_pod_prop *spa_pod_find_prop(const struct spa_pod *pod, SPA_API_POD_ITER const struct spa_pod_prop *spa_pod_find_prop(const struct spa_pod *pod,
const struct spa_pod_prop *start, uint32_t key) const struct spa_pod_prop *start, uint32_t key)
{ {
if (!spa_pod_is_object(pod)) if (!spa_pod_is_object(pod))
@ -414,7 +422,7 @@ SPA_API_IMPL const struct spa_pod_prop *spa_pod_find_prop(const struct spa_pod *
return spa_pod_object_find_prop((const struct spa_pod_object *)pod, start, key); return spa_pod_object_find_prop((const struct spa_pod_object *)pod, start, key);
} }
SPA_API_IMPL int spa_pod_object_fixate(struct spa_pod_object *pod) SPA_API_POD_ITER int spa_pod_object_fixate(struct spa_pod_object *pod)
{ {
struct spa_pod_prop *res; struct spa_pod_prop *res;
SPA_POD_OBJECT_FOREACH(pod, res) { SPA_POD_OBJECT_FOREACH(pod, res) {
@ -425,14 +433,14 @@ SPA_API_IMPL int spa_pod_object_fixate(struct spa_pod_object *pod)
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_fixate(struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_fixate(struct spa_pod *pod)
{ {
if (!spa_pod_is_object(pod)) if (!spa_pod_is_object(pod))
return -EINVAL; return -EINVAL;
return spa_pod_object_fixate((struct spa_pod_object *)pod); return spa_pod_object_fixate((struct spa_pod_object *)pod);
} }
SPA_API_IMPL int spa_pod_object_is_fixated(const struct spa_pod_object *pod) SPA_API_POD_ITER int spa_pod_object_is_fixated(const struct spa_pod_object *pod)
{ {
struct spa_pod_prop *res; struct spa_pod_prop *res;
SPA_POD_OBJECT_FOREACH(pod, res) { SPA_POD_OBJECT_FOREACH(pod, res) {
@ -443,7 +451,7 @@ SPA_API_IMPL int spa_pod_object_is_fixated(const struct spa_pod_object *pod)
return 1; return 1;
} }
SPA_API_IMPL int spa_pod_object_has_props(const struct spa_pod_object *pod) SPA_API_POD_ITER int spa_pod_object_has_props(const struct spa_pod_object *pod)
{ {
struct spa_pod_prop *res; struct spa_pod_prop *res;
SPA_POD_OBJECT_FOREACH(pod, res) SPA_POD_OBJECT_FOREACH(pod, res)
@ -451,7 +459,7 @@ SPA_API_IMPL int spa_pod_object_has_props(const struct spa_pod_object *pod)
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_is_fixated(const struct spa_pod *pod) SPA_API_POD_ITER int spa_pod_is_fixated(const struct spa_pod *pod)
{ {
if (!spa_pod_is_object(pod)) if (!spa_pod_is_object(pod))
return -EINVAL; return -EINVAL;

View file

@ -15,6 +15,14 @@ extern "C" {
#include <spa/pod/iter.h> #include <spa/pod/iter.h>
#include <spa/pod/vararg.h> #include <spa/pod/vararg.h>
#ifndef SPA_API_POD_PARSER
#ifdef SPA_API_IMPL
#define SPA_API_POD_PARSER SPA_API_IMPL
#else
#define SPA_API_POD_PARSER static inline
#endif
#endif
/** /**
* \addtogroup spa_pod * \addtogroup spa_pod
* \{ * \{
@ -35,31 +43,31 @@ struct spa_pod_parser {
#define SPA_POD_PARSER_INIT(buffer,size) ((struct spa_pod_parser){ (buffer), (size), 0, {0,0,NULL}}) #define SPA_POD_PARSER_INIT(buffer,size) ((struct spa_pod_parser){ (buffer), (size), 0, {0,0,NULL}})
SPA_API_IMPL void spa_pod_parser_init(struct spa_pod_parser *parser, SPA_API_POD_PARSER void spa_pod_parser_init(struct spa_pod_parser *parser,
const void *data, uint32_t size) const void *data, uint32_t size)
{ {
*parser = SPA_POD_PARSER_INIT(data, size); *parser = SPA_POD_PARSER_INIT(data, size);
} }
SPA_API_IMPL void spa_pod_parser_pod(struct spa_pod_parser *parser, SPA_API_POD_PARSER void spa_pod_parser_pod(struct spa_pod_parser *parser,
const struct spa_pod *pod) const struct spa_pod *pod)
{ {
spa_pod_parser_init(parser, pod, SPA_POD_SIZE(pod)); spa_pod_parser_init(parser, pod, SPA_POD_SIZE(pod));
} }
SPA_API_IMPL void SPA_API_POD_PARSER void
spa_pod_parser_get_state(struct spa_pod_parser *parser, struct spa_pod_parser_state *state) spa_pod_parser_get_state(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)
{ {
*state = parser->state; *state = parser->state;
} }
SPA_API_IMPL void SPA_API_POD_PARSER void
spa_pod_parser_reset(struct spa_pod_parser *parser, struct spa_pod_parser_state *state) spa_pod_parser_reset(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)
{ {
parser->state = *state; parser->state = *state;
} }
SPA_API_IMPL struct spa_pod * SPA_API_POD_PARSER struct spa_pod *
spa_pod_parser_deref(struct spa_pod_parser *parser, uint32_t offset, uint32_t size) spa_pod_parser_deref(struct spa_pod_parser *parser, uint32_t offset, uint32_t size)
{ {
/* Cast to uint64_t to avoid wraparound. Add 8 for the pod itself. */ /* Cast to uint64_t to avoid wraparound. Add 8 for the pod itself. */
@ -78,12 +86,12 @@ spa_pod_parser_deref(struct spa_pod_parser *parser, uint32_t offset, uint32_t si
return NULL; return NULL;
} }
SPA_API_IMPL struct spa_pod *spa_pod_parser_frame(struct spa_pod_parser *parser, struct spa_pod_frame *frame) SPA_API_POD_PARSER struct spa_pod *spa_pod_parser_frame(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
{ {
return SPA_PTROFF(parser->data, frame->offset, struct spa_pod); return SPA_PTROFF(parser->data, frame->offset, struct spa_pod);
} }
SPA_API_IMPL void spa_pod_parser_push(struct spa_pod_parser *parser, SPA_API_POD_PARSER void spa_pod_parser_push(struct spa_pod_parser *parser,
struct spa_pod_frame *frame, const struct spa_pod *pod, uint32_t offset) struct spa_pod_frame *frame, const struct spa_pod *pod, uint32_t offset)
{ {
frame->pod = *pod; frame->pod = *pod;
@ -93,19 +101,19 @@ SPA_API_IMPL void spa_pod_parser_push(struct spa_pod_parser *parser,
parser->state.frame = frame; parser->state.frame = frame;
} }
SPA_API_IMPL struct spa_pod *spa_pod_parser_current(struct spa_pod_parser *parser) SPA_API_POD_PARSER struct spa_pod *spa_pod_parser_current(struct spa_pod_parser *parser)
{ {
struct spa_pod_frame *f = parser->state.frame; struct spa_pod_frame *f = parser->state.frame;
uint32_t size = f ? f->offset + SPA_POD_SIZE(&f->pod) : parser->size; uint32_t size = f ? f->offset + SPA_POD_SIZE(&f->pod) : parser->size;
return spa_pod_parser_deref(parser, parser->state.offset, size); return spa_pod_parser_deref(parser, parser->state.offset, size);
} }
SPA_API_IMPL void spa_pod_parser_advance(struct spa_pod_parser *parser, const struct spa_pod *pod) SPA_API_POD_PARSER void spa_pod_parser_advance(struct spa_pod_parser *parser, const struct spa_pod *pod)
{ {
parser->state.offset += SPA_ROUND_UP_N(SPA_POD_SIZE(pod), 8); parser->state.offset += SPA_ROUND_UP_N(SPA_POD_SIZE(pod), 8);
} }
SPA_API_IMPL struct spa_pod *spa_pod_parser_next(struct spa_pod_parser *parser) SPA_API_POD_PARSER struct spa_pod *spa_pod_parser_next(struct spa_pod_parser *parser)
{ {
struct spa_pod *pod = spa_pod_parser_current(parser); struct spa_pod *pod = spa_pod_parser_current(parser);
if (pod) if (pod)
@ -113,7 +121,7 @@ SPA_API_IMPL struct spa_pod *spa_pod_parser_next(struct spa_pod_parser *parser)
return pod; return pod;
} }
SPA_API_IMPL int spa_pod_parser_pop(struct spa_pod_parser *parser, SPA_API_POD_PARSER int spa_pod_parser_pop(struct spa_pod_parser *parser,
struct spa_pod_frame *frame) struct spa_pod_frame *frame)
{ {
parser->state.frame = frame->parent; parser->state.frame = frame->parent;
@ -121,7 +129,7 @@ SPA_API_IMPL int spa_pod_parser_pop(struct spa_pod_parser *parser,
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_parser_get_bool(struct spa_pod_parser *parser, bool *value) SPA_API_POD_PARSER int spa_pod_parser_get_bool(struct spa_pod_parser *parser, bool *value)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -130,7 +138,7 @@ SPA_API_IMPL int spa_pod_parser_get_bool(struct spa_pod_parser *parser, bool *va
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_id(struct spa_pod_parser *parser, uint32_t *value) SPA_API_POD_PARSER int spa_pod_parser_get_id(struct spa_pod_parser *parser, uint32_t *value)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -139,7 +147,7 @@ SPA_API_IMPL int spa_pod_parser_get_id(struct spa_pod_parser *parser, uint32_t *
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_int(struct spa_pod_parser *parser, int32_t *value) SPA_API_POD_PARSER int spa_pod_parser_get_int(struct spa_pod_parser *parser, int32_t *value)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -148,7 +156,7 @@ SPA_API_IMPL int spa_pod_parser_get_int(struct spa_pod_parser *parser, int32_t *
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_long(struct spa_pod_parser *parser, int64_t *value) SPA_API_POD_PARSER int spa_pod_parser_get_long(struct spa_pod_parser *parser, int64_t *value)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -157,7 +165,7 @@ SPA_API_IMPL int spa_pod_parser_get_long(struct spa_pod_parser *parser, int64_t
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_float(struct spa_pod_parser *parser, float *value) SPA_API_POD_PARSER int spa_pod_parser_get_float(struct spa_pod_parser *parser, float *value)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -166,7 +174,7 @@ SPA_API_IMPL int spa_pod_parser_get_float(struct spa_pod_parser *parser, float *
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_double(struct spa_pod_parser *parser, double *value) SPA_API_POD_PARSER int spa_pod_parser_get_double(struct spa_pod_parser *parser, double *value)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -175,7 +183,7 @@ SPA_API_IMPL int spa_pod_parser_get_double(struct spa_pod_parser *parser, double
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_string(struct spa_pod_parser *parser, const char **value) SPA_API_POD_PARSER int spa_pod_parser_get_string(struct spa_pod_parser *parser, const char **value)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -184,7 +192,7 @@ SPA_API_IMPL int spa_pod_parser_get_string(struct spa_pod_parser *parser, const
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_bytes(struct spa_pod_parser *parser, const void **value, uint32_t *len) SPA_API_POD_PARSER int spa_pod_parser_get_bytes(struct spa_pod_parser *parser, const void **value, uint32_t *len)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -193,7 +201,7 @@ SPA_API_IMPL int spa_pod_parser_get_bytes(struct spa_pod_parser *parser, const v
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_pointer(struct spa_pod_parser *parser, uint32_t *type, const void **value) SPA_API_POD_PARSER int spa_pod_parser_get_pointer(struct spa_pod_parser *parser, uint32_t *type, const void **value)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -202,7 +210,7 @@ SPA_API_IMPL int spa_pod_parser_get_pointer(struct spa_pod_parser *parser, uint3
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_fd(struct spa_pod_parser *parser, int64_t *value) SPA_API_POD_PARSER int spa_pod_parser_get_fd(struct spa_pod_parser *parser, int64_t *value)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -211,7 +219,7 @@ SPA_API_IMPL int spa_pod_parser_get_fd(struct spa_pod_parser *parser, int64_t *v
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_rectangle(struct spa_pod_parser *parser, struct spa_rectangle *value) SPA_API_POD_PARSER int spa_pod_parser_get_rectangle(struct spa_pod_parser *parser, struct spa_rectangle *value)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -220,7 +228,7 @@ SPA_API_IMPL int spa_pod_parser_get_rectangle(struct spa_pod_parser *parser, str
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_fraction(struct spa_pod_parser *parser, struct spa_fraction *value) SPA_API_POD_PARSER int spa_pod_parser_get_fraction(struct spa_pod_parser *parser, struct spa_fraction *value)
{ {
int res = -EPIPE; int res = -EPIPE;
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -229,7 +237,7 @@ SPA_API_IMPL int spa_pod_parser_get_fraction(struct spa_pod_parser *parser, stru
return res; return res;
} }
SPA_API_IMPL int spa_pod_parser_get_pod(struct spa_pod_parser *parser, struct spa_pod **value) SPA_API_POD_PARSER int spa_pod_parser_get_pod(struct spa_pod_parser *parser, struct spa_pod **value)
{ {
struct spa_pod *pod = spa_pod_parser_current(parser); struct spa_pod *pod = spa_pod_parser_current(parser);
if (pod == NULL) if (pod == NULL)
@ -238,7 +246,7 @@ SPA_API_IMPL int spa_pod_parser_get_pod(struct spa_pod_parser *parser, struct sp
spa_pod_parser_advance(parser, pod); spa_pod_parser_advance(parser, pod);
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_parser_push_struct(struct spa_pod_parser *parser, SPA_API_POD_PARSER int spa_pod_parser_push_struct(struct spa_pod_parser *parser,
struct spa_pod_frame *frame) struct spa_pod_frame *frame)
{ {
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -251,7 +259,7 @@ SPA_API_IMPL int spa_pod_parser_push_struct(struct spa_pod_parser *parser,
return 0; return 0;
} }
SPA_API_IMPL int spa_pod_parser_push_object(struct spa_pod_parser *parser, SPA_API_POD_PARSER int spa_pod_parser_push_object(struct spa_pod_parser *parser,
struct spa_pod_frame *frame, uint32_t type, uint32_t *id) struct spa_pod_frame *frame, uint32_t type, uint32_t *id)
{ {
const struct spa_pod *pod = spa_pod_parser_current(parser); const struct spa_pod *pod = spa_pod_parser_current(parser);
@ -268,7 +276,7 @@ SPA_API_IMPL int spa_pod_parser_push_object(struct spa_pod_parser *parser,
return 0; return 0;
} }
SPA_API_IMPL bool spa_pod_parser_can_collect(const struct spa_pod *pod, char type) SPA_API_POD_PARSER bool spa_pod_parser_can_collect(const struct spa_pod *pod, char type)
{ {
if (pod == NULL) if (pod == NULL)
return false; return false;
@ -443,7 +451,7 @@ do { \
} \ } \
} while(false) } while(false)
SPA_API_IMPL int spa_pod_parser_getv(struct spa_pod_parser *parser, va_list args) SPA_API_POD_PARSER int spa_pod_parser_getv(struct spa_pod_parser *parser, va_list args)
{ {
struct spa_pod_frame *f = parser->state.frame; struct spa_pod_frame *f = parser->state.frame;
uint32_t ftype = f ? f->pod.type : (uint32_t)SPA_TYPE_Struct; uint32_t ftype = f ? f->pod.type : (uint32_t)SPA_TYPE_Struct;
@ -496,7 +504,7 @@ SPA_API_IMPL int spa_pod_parser_getv(struct spa_pod_parser *parser, va_list args
return count; return count;
} }
SPA_API_IMPL int spa_pod_parser_get(struct spa_pod_parser *parser, ...) SPA_API_POD_PARSER int spa_pod_parser_get(struct spa_pod_parser *parser, ...)
{ {
int res; int res;
va_list args; va_list args;

View file

@ -15,6 +15,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#include <spa/utils/hook.h> #include <spa/utils/hook.h>
#ifndef SPA_API_CPU
#ifdef SPA_API_IMPL
#define SPA_API_CPU SPA_API_IMPL
#else
#define SPA_API_CPU static inline
#endif
#endif
/** \defgroup spa_cpu CPU /** \defgroup spa_cpu CPU
* Querying CPU properties * Querying CPU properties
*/ */
@ -91,7 +99,7 @@ struct spa_cpu { struct spa_interface iface; };
#define SPA_CPU_VM_ACRN (1 << 13) #define SPA_CPU_VM_ACRN (1 << 13)
#define SPA_CPU_VM_POWERVM (1 << 14) #define SPA_CPU_VM_POWERVM (1 << 14)
SPA_API_IMPL const char *spa_cpu_vm_type_to_string(uint32_t vm_type) SPA_API_CPU const char *spa_cpu_vm_type_to_string(uint32_t vm_type)
{ {
switch(vm_type) { switch(vm_type) {
case SPA_CPU_VM_NONE: case SPA_CPU_VM_NONE:
@ -160,27 +168,27 @@ struct spa_cpu_methods {
int (*zero_denormals) (void *object, bool enable); int (*zero_denormals) (void *object, bool enable);
}; };
SPA_API_IMPL uint32_t spa_cpu_get_flags(struct spa_cpu *c) SPA_API_CPU uint32_t spa_cpu_get_flags(struct spa_cpu *c)
{ {
return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_flags, 0); return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_flags, 0);
} }
SPA_API_IMPL int spa_cpu_force_flags(struct spa_cpu *c, uint32_t flags) SPA_API_CPU int spa_cpu_force_flags(struct spa_cpu *c, uint32_t flags)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_cpu, &c->iface, force_flags, 0, flags); return spa_api_method_r(int, -ENOTSUP, spa_cpu, &c->iface, force_flags, 0, flags);
} }
SPA_API_IMPL uint32_t spa_cpu_get_count(struct spa_cpu *c) SPA_API_CPU uint32_t spa_cpu_get_count(struct spa_cpu *c)
{ {
return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_count, 0); return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_count, 0);
} }
SPA_API_IMPL uint32_t spa_cpu_get_max_align(struct spa_cpu *c) SPA_API_CPU uint32_t spa_cpu_get_max_align(struct spa_cpu *c)
{ {
return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_max_align, 0); return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_max_align, 0);
} }
SPA_API_IMPL uint32_t spa_cpu_get_vm_type(struct spa_cpu *c) SPA_API_CPU uint32_t spa_cpu_get_vm_type(struct spa_cpu *c)
{ {
return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_vm_type, 1); return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_vm_type, 1);
} }
SPA_API_IMPL int spa_cpu_zero_denormals(struct spa_cpu *c, bool enable) SPA_API_CPU int spa_cpu_zero_denormals(struct spa_cpu *c, bool enable)
{ {
return spa_api_method_r(int, -ENOTSUP, spa_cpu, &c->iface, zero_denormals, 2, enable); return spa_api_method_r(int, -ENOTSUP, spa_cpu, &c->iface, zero_denormals, 2, enable);
} }

View file

@ -11,6 +11,14 @@ extern "C" {
#include <spa/support/loop.h> #include <spa/support/loop.h>
#ifndef SPA_API_DBUS
#ifdef SPA_API_IMPL
#define SPA_API_DBUS SPA_API_IMPL
#else
#define SPA_API_DBUS static inline
#endif
#endif
/** \defgroup spa_dbus DBus /** \defgroup spa_dbus DBus
* DBus communication * DBus communication
*/ */
@ -81,19 +89,19 @@ struct spa_dbus_connection {
/** \copydoc spa_dbus_connection.get /** \copydoc spa_dbus_connection.get
* \sa spa_dbus_connection.get */ * \sa spa_dbus_connection.get */
SPA_API_IMPL void *spa_dbus_connection_get(struct spa_dbus_connection *conn) SPA_API_DBUS void *spa_dbus_connection_get(struct spa_dbus_connection *conn)
{ {
return spa_api_func_r(void *, NULL, conn, get, 0); return spa_api_func_r(void *, NULL, conn, get, 0);
} }
/** \copydoc spa_dbus_connection.destroy /** \copydoc spa_dbus_connection.destroy
* \sa spa_dbus_connection.destroy */ * \sa spa_dbus_connection.destroy */
SPA_API_IMPL void spa_dbus_connection_destroy(struct spa_dbus_connection *conn) SPA_API_DBUS void spa_dbus_connection_destroy(struct spa_dbus_connection *conn)
{ {
spa_api_func_v(conn, destroy, 0); spa_api_func_v(conn, destroy, 0);
} }
/** \copydoc spa_dbus_connection.add_listener /** \copydoc spa_dbus_connection.add_listener
* \sa spa_dbus_connection.add_listener */ * \sa spa_dbus_connection.add_listener */
SPA_API_IMPL void spa_dbus_connection_add_listener(struct spa_dbus_connection *conn, SPA_API_DBUS void spa_dbus_connection_add_listener(struct spa_dbus_connection *conn,
struct spa_hook *listener, struct spa_hook *listener,
const struct spa_dbus_connection_events *events, const struct spa_dbus_connection_events *events,
void *data) void *data)
@ -124,7 +132,7 @@ struct spa_dbus_methods {
/** \copydoc spa_dbus_methods.get_connection /** \copydoc spa_dbus_methods.get_connection
* \sa spa_dbus_methods.get_connection * \sa spa_dbus_methods.get_connection
*/ */
SPA_API_IMPL struct spa_dbus_connection * SPA_API_DBUS struct spa_dbus_connection *
spa_dbus_get_connection(struct spa_dbus *dbus, enum spa_dbus_type type) spa_dbus_get_connection(struct spa_dbus *dbus, enum spa_dbus_type type)
{ {
return spa_api_method_r(struct spa_dbus_connection *, NULL, return spa_api_method_r(struct spa_dbus_connection *, NULL,

View file

@ -12,6 +12,14 @@ extern "C" {
#include <spa/utils/hook.h> #include <spa/utils/hook.h>
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#ifndef SPA_API_I18N
#ifdef SPA_API_IMPL
#define SPA_API_I18N SPA_API_IMPL
#else
#define SPA_API_I18N static inline
#endif
#endif
/** \defgroup spa_i18n I18N /** \defgroup spa_i18n I18N
* Gettext interface * Gettext interface
*/ */
@ -53,14 +61,14 @@ struct spa_i18n_methods {
}; };
SPA_FORMAT_ARG_FUNC(2) SPA_FORMAT_ARG_FUNC(2)
SPA_API_IMPL const char * SPA_API_I18N const char *
spa_i18n_text(struct spa_i18n *i18n, const char *msgid) spa_i18n_text(struct spa_i18n *i18n, const char *msgid)
{ {
return spa_api_method_null_r(const char *, msgid, spa_i18n, &i18n->iface, return spa_api_method_null_r(const char *, msgid, spa_i18n, &i18n->iface,
text, 0, msgid); text, 0, msgid);
} }
SPA_API_IMPL const char * SPA_API_I18N const char *
spa_i18n_ntext(struct spa_i18n *i18n, const char *msgid, spa_i18n_ntext(struct spa_i18n *i18n, const char *msgid,
const char *msgid_plural, unsigned long int n) const char *msgid_plural, unsigned long int n)
{ {

View file

@ -19,7 +19,7 @@ extern "C" {
* \{ * \{
*/ */
SPA_API_IMPL SPA_PRINTF_FUNC(7, 0) void spa_log_impl_logtv(void *object SPA_UNUSED, static inline SPA_PRINTF_FUNC(7, 0) void spa_log_impl_logtv(void *object SPA_UNUSED,
enum spa_log_level level, enum spa_log_level level,
const struct spa_log_topic *topic, const struct spa_log_topic *topic,
const char *file, const char *file,
@ -49,7 +49,7 @@ SPA_API_IMPL SPA_PRINTF_FUNC(7, 0) void spa_log_impl_logtv(void *object SPA_UNUS
fputs(location, stderr); fputs(location, stderr);
} }
SPA_API_IMPL SPA_PRINTF_FUNC(7,8) void spa_log_impl_logt(void *object, static inline SPA_PRINTF_FUNC(7,8) void spa_log_impl_logt(void *object,
enum spa_log_level level, enum spa_log_level level,
const struct spa_log_topic *topic, const struct spa_log_topic *topic,
const char *file, const char *file,
@ -63,7 +63,7 @@ SPA_API_IMPL SPA_PRINTF_FUNC(7,8) void spa_log_impl_logt(void *object,
va_end(args); va_end(args);
} }
SPA_API_IMPL SPA_PRINTF_FUNC(6, 0) void spa_log_impl_logv(void *object, static inline SPA_PRINTF_FUNC(6, 0) void spa_log_impl_logv(void *object,
enum spa_log_level level, enum spa_log_level level,
const char *file, const char *file,
int line, int line,
@ -75,7 +75,7 @@ SPA_API_IMPL SPA_PRINTF_FUNC(6, 0) void spa_log_impl_logv(void *object,
spa_log_impl_logtv(object, level, NULL, file, line, func, fmt, args); spa_log_impl_logtv(object, level, NULL, file, line, func, fmt, args);
} }
SPA_API_IMPL SPA_PRINTF_FUNC(6,7) void spa_log_impl_log(void *object, static inline SPA_PRINTF_FUNC(6,7) void spa_log_impl_log(void *object,
enum spa_log_level level, enum spa_log_level level,
const char *file, const char *file,
int line, int line,
@ -88,7 +88,7 @@ SPA_API_IMPL SPA_PRINTF_FUNC(6,7) void spa_log_impl_log(void *object,
va_end(args); va_end(args);
} }
SPA_API_IMPL void spa_log_impl_topic_init(void *object SPA_UNUSED, struct spa_log_topic *topic SPA_UNUSED) static inline void spa_log_impl_topic_init(void *object SPA_UNUSED, struct spa_log_topic *topic SPA_UNUSED)
{ {
/* noop */ /* noop */
} }

View file

@ -15,6 +15,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#include <spa/utils/hook.h> #include <spa/utils/hook.h>
#ifndef SPA_API_LOG
#ifdef SPA_API_IMPL
#define SPA_API_LOG SPA_API_IMPL
#else
#define SPA_API_LOG static inline
#endif
#endif
/** \defgroup spa_log Log /** \defgroup spa_log Log
* Logging interface * Logging interface
*/ */
@ -213,7 +221,7 @@ struct spa_log_methods {
#define SPA_LOG_TOPIC(v, t) \ #define SPA_LOG_TOPIC(v, t) \
(struct spa_log_topic){ .version = (v), .topic = (t)} (struct spa_log_topic){ .version = (v), .topic = (t)}
SPA_API_IMPL void spa_log_topic_init(struct spa_log *log, struct spa_log_topic *topic) SPA_API_LOG void spa_log_topic_init(struct spa_log *log, struct spa_log_topic *topic)
{ {
if (SPA_UNLIKELY(!log)) if (SPA_UNLIKELY(!log))
return; return;
@ -221,7 +229,7 @@ SPA_API_IMPL void spa_log_topic_init(struct spa_log *log, struct spa_log_topic *
spa_interface_call(&log->iface, struct spa_log_methods, topic_init, 1, topic); spa_interface_call(&log->iface, struct spa_log_methods, topic_init, 1, topic);
} }
SPA_API_IMPL bool spa_log_level_topic_enabled(const struct spa_log *log, SPA_API_LOG bool spa_log_level_topic_enabled(const struct spa_log *log,
const struct spa_log_topic *topic, const struct spa_log_topic *topic,
enum spa_log_level level) enum spa_log_level level)
{ {
@ -256,7 +264,7 @@ SPA_API_IMPL bool spa_log_level_topic_enabled(const struct spa_log *log,
/* Transparently calls to version 0 logv if v1 is not supported */ /* Transparently calls to version 0 logv if v1 is not supported */
SPA_PRINTF_FUNC(7, 0) SPA_PRINTF_FUNC(7, 0)
SPA_API_IMPL void spa_log_logtv(struct spa_log *l, enum spa_log_level level, SPA_API_LOG void spa_log_logtv(struct spa_log *l, enum spa_log_level level,
const struct spa_log_topic *topic, const char *file, int line, const struct spa_log_topic *topic, const char *file, int line,
const char *func, const char *fmt, va_list args) const char *func, const char *fmt, va_list args)
{ {

View file

@ -15,6 +15,14 @@ extern "C" {
#include <spa/utils/hook.h> #include <spa/utils/hook.h>
#include <spa/support/system.h> #include <spa/support/system.h>
#ifndef SPA_API_LOOP
#ifdef SPA_API_IMPL
#define SPA_API_LOOP SPA_API_IMPL
#else
#define SPA_API_LOOP static inline
#endif
#endif
/** \defgroup spa_loop Loop /** \defgroup spa_loop Loop
* Event loop interface * Event loop interface
*/ */
@ -127,22 +135,22 @@ struct spa_loop_methods {
void *user_data); void *user_data);
}; };
SPA_API_IMPL int spa_loop_add_source(struct spa_loop *object, struct spa_source *source) SPA_API_LOOP int spa_loop_add_source(struct spa_loop *object, struct spa_source *source)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_loop, &object->iface, add_source, 0, source); spa_loop, &object->iface, add_source, 0, source);
} }
SPA_API_IMPL int spa_loop_update_source(struct spa_loop *object, struct spa_source *source) SPA_API_LOOP int spa_loop_update_source(struct spa_loop *object, struct spa_source *source)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_loop, &object->iface, update_source, 0, source); spa_loop, &object->iface, update_source, 0, source);
} }
SPA_API_IMPL int spa_loop_remove_source(struct spa_loop *object, struct spa_source *source) SPA_API_LOOP int spa_loop_remove_source(struct spa_loop *object, struct spa_source *source)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_loop, &object->iface, remove_source, 0, source); spa_loop, &object->iface, remove_source, 0, source);
} }
SPA_API_IMPL int spa_loop_invoke(struct spa_loop *object, SPA_API_LOOP int spa_loop_invoke(struct spa_loop *object,
spa_invoke_func_t func, uint32_t seq, const void *data, spa_invoke_func_t func, uint32_t seq, const void *data,
size_t size, bool block, void *user_data) size_t size, bool block, void *user_data)
{ {
@ -165,14 +173,14 @@ struct spa_loop_control_hooks {
void (*after) (void *data); void (*after) (void *data);
}; };
SPA_API_IMPL void spa_loop_control_hook_before(struct spa_hook_list *l) SPA_API_LOOP void spa_loop_control_hook_before(struct spa_hook_list *l)
{ {
struct spa_hook *h; struct spa_hook *h;
spa_list_for_each_reverse(h, &l->list, link) spa_list_for_each_reverse(h, &l->list, link)
spa_callbacks_call_fast(&h->cb, struct spa_loop_control_hooks, before, 0); spa_callbacks_call_fast(&h->cb, struct spa_loop_control_hooks, before, 0);
} }
SPA_API_IMPL void spa_loop_control_hook_after(struct spa_hook_list *l) SPA_API_LOOP void spa_loop_control_hook_after(struct spa_hook_list *l)
{ {
struct spa_hook *h; struct spa_hook *h;
spa_list_for_each(h, &l->list, link) spa_list_for_each(h, &l->list, link)
@ -239,39 +247,39 @@ struct spa_loop_control_methods {
int (*check) (void *object); int (*check) (void *object);
}; };
SPA_API_IMPL int spa_loop_control_get_fd(struct spa_loop_control *object) SPA_API_LOOP int spa_loop_control_get_fd(struct spa_loop_control *object)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_loop_control, &object->iface, get_fd, 0); spa_loop_control, &object->iface, get_fd, 0);
} }
SPA_API_IMPL void spa_loop_control_add_hook(struct spa_loop_control *object, SPA_API_LOOP void spa_loop_control_add_hook(struct spa_loop_control *object,
struct spa_hook *hook, const struct spa_loop_control_hooks *hooks, struct spa_hook *hook, const struct spa_loop_control_hooks *hooks,
void *data) void *data)
{ {
spa_api_method_v(spa_loop_control, &object->iface, add_hook, 0, spa_api_method_v(spa_loop_control, &object->iface, add_hook, 0,
hook, hooks, data); hook, hooks, data);
} }
SPA_API_IMPL void spa_loop_control_enter(struct spa_loop_control *object) SPA_API_LOOP void spa_loop_control_enter(struct spa_loop_control *object)
{ {
spa_api_method_v(spa_loop_control, &object->iface, enter, 0); spa_api_method_v(spa_loop_control, &object->iface, enter, 0);
} }
SPA_API_IMPL void spa_loop_control_leave(struct spa_loop_control *object) SPA_API_LOOP void spa_loop_control_leave(struct spa_loop_control *object)
{ {
spa_api_method_v(spa_loop_control, &object->iface, leave, 0); spa_api_method_v(spa_loop_control, &object->iface, leave, 0);
} }
SPA_API_IMPL int spa_loop_control_iterate(struct spa_loop_control *object, SPA_API_LOOP int spa_loop_control_iterate(struct spa_loop_control *object,
int timeout) int timeout)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_loop_control, &object->iface, iterate, 0, timeout); spa_loop_control, &object->iface, iterate, 0, timeout);
} }
SPA_API_IMPL int spa_loop_control_iterate_fast(struct spa_loop_control *object, SPA_API_LOOP int spa_loop_control_iterate_fast(struct spa_loop_control *object,
int timeout) int timeout)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, return spa_api_method_fast_r(int, -ENOTSUP,
spa_loop_control, &object->iface, iterate, 0, timeout); spa_loop_control, &object->iface, iterate, 0, timeout);
} }
SPA_API_IMPL int spa_loop_control_check(struct spa_loop_control *object) SPA_API_LOOP int spa_loop_control_check(struct spa_loop_control *object)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_loop_control, &object->iface, check, 1); spa_loop_control, &object->iface, check, 1);
@ -326,51 +334,51 @@ struct spa_loop_utils_methods {
void (*destroy_source) (void *object, struct spa_source *source); void (*destroy_source) (void *object, struct spa_source *source);
}; };
SPA_API_IMPL struct spa_source * SPA_API_LOOP struct spa_source *
spa_loop_utils_add_io(struct spa_loop_utils *object, int fd, uint32_t mask, spa_loop_utils_add_io(struct spa_loop_utils *object, int fd, uint32_t mask,
bool close, spa_source_io_func_t func, void *data) bool close, spa_source_io_func_t func, void *data)
{ {
return spa_api_method_r(struct spa_source *, NULL, return spa_api_method_r(struct spa_source *, NULL,
spa_loop_utils, &object->iface, add_io, 0, fd, mask, close, func, data); spa_loop_utils, &object->iface, add_io, 0, fd, mask, close, func, data);
} }
SPA_API_IMPL int spa_loop_utils_update_io(struct spa_loop_utils *object, SPA_API_LOOP int spa_loop_utils_update_io(struct spa_loop_utils *object,
struct spa_source *source, uint32_t mask) struct spa_source *source, uint32_t mask)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_loop_utils, &object->iface, update_io, 0, source, mask); spa_loop_utils, &object->iface, update_io, 0, source, mask);
} }
SPA_API_IMPL struct spa_source * SPA_API_LOOP struct spa_source *
spa_loop_utils_add_idle(struct spa_loop_utils *object, bool enabled, spa_loop_utils_add_idle(struct spa_loop_utils *object, bool enabled,
spa_source_idle_func_t func, void *data) spa_source_idle_func_t func, void *data)
{ {
return spa_api_method_r(struct spa_source *, NULL, return spa_api_method_r(struct spa_source *, NULL,
spa_loop_utils, &object->iface, add_idle, 0, enabled, func, data); spa_loop_utils, &object->iface, add_idle, 0, enabled, func, data);
} }
SPA_API_IMPL int spa_loop_utils_enable_idle(struct spa_loop_utils *object, SPA_API_LOOP int spa_loop_utils_enable_idle(struct spa_loop_utils *object,
struct spa_source *source, bool enabled) struct spa_source *source, bool enabled)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_loop_utils, &object->iface, enable_idle, 0, source, enabled); spa_loop_utils, &object->iface, enable_idle, 0, source, enabled);
} }
SPA_API_IMPL struct spa_source * SPA_API_LOOP struct spa_source *
spa_loop_utils_add_event(struct spa_loop_utils *object, spa_source_event_func_t func, void *data) spa_loop_utils_add_event(struct spa_loop_utils *object, spa_source_event_func_t func, void *data)
{ {
return spa_api_method_r(struct spa_source *, NULL, return spa_api_method_r(struct spa_source *, NULL,
spa_loop_utils, &object->iface, add_event, 0, func, data); spa_loop_utils, &object->iface, add_event, 0, func, data);
} }
SPA_API_IMPL int spa_loop_utils_signal_event(struct spa_loop_utils *object, SPA_API_LOOP int spa_loop_utils_signal_event(struct spa_loop_utils *object,
struct spa_source *source) struct spa_source *source)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
spa_loop_utils, &object->iface, signal_event, 0, source); spa_loop_utils, &object->iface, signal_event, 0, source);
} }
SPA_API_IMPL struct spa_source * SPA_API_LOOP struct spa_source *
spa_loop_utils_add_timer(struct spa_loop_utils *object, spa_source_timer_func_t func, void *data) spa_loop_utils_add_timer(struct spa_loop_utils *object, spa_source_timer_func_t func, void *data)
{ {
return spa_api_method_r(struct spa_source *, NULL, return spa_api_method_r(struct spa_source *, NULL,
spa_loop_utils, &object->iface, add_timer, 0, func, data); spa_loop_utils, &object->iface, add_timer, 0, func, data);
} }
SPA_API_IMPL int spa_loop_utils_update_timer(struct spa_loop_utils *object, SPA_API_LOOP int spa_loop_utils_update_timer(struct spa_loop_utils *object,
struct spa_source *source, struct timespec *value, struct spa_source *source, struct timespec *value,
struct timespec *interval, bool absolute) struct timespec *interval, bool absolute)
{ {
@ -378,7 +386,7 @@ SPA_API_IMPL int spa_loop_utils_update_timer(struct spa_loop_utils *object,
spa_loop_utils, &object->iface, update_timer, 0, source, spa_loop_utils, &object->iface, update_timer, 0, source,
value, interval, absolute); value, interval, absolute);
} }
SPA_API_IMPL struct spa_source * SPA_API_LOOP struct spa_source *
spa_loop_utils_add_signal(struct spa_loop_utils *object, int signal_number, spa_loop_utils_add_signal(struct spa_loop_utils *object, int signal_number,
spa_source_signal_func_t func, void *data) spa_source_signal_func_t func, void *data)
{ {
@ -386,7 +394,7 @@ spa_loop_utils_add_signal(struct spa_loop_utils *object, int signal_number,
spa_loop_utils, &object->iface, add_signal, 0, spa_loop_utils, &object->iface, add_signal, 0,
signal_number, func, data); signal_number, func, data);
} }
SPA_API_IMPL void spa_loop_utils_destroy_source(struct spa_loop_utils *object, SPA_API_LOOP void spa_loop_utils_destroy_source(struct spa_loop_utils *object,
struct spa_source *source) struct spa_source *source)
{ {
spa_api_method_v(spa_loop_utils, &object->iface, destroy_source, 0, source); spa_api_method_v(spa_loop_utils, &object->iface, destroy_source, 0, source);

View file

@ -12,6 +12,14 @@ extern "C" {
#include <spa/utils/hook.h> #include <spa/utils/hook.h>
#include <spa/utils/dict.h> #include <spa/utils/dict.h>
#ifndef SPA_API_PLUGIN_LOADER
#ifdef SPA_API_IMPL
#define SPA_API_PLUGIN_LOADER SPA_API_IMPL
#else
#define SPA_API_PLUGIN_LOADER static inline
#endif
#endif
/** \defgroup spa_plugin_loader Plugin Loader /** \defgroup spa_plugin_loader Plugin Loader
* SPA plugin loader * SPA plugin loader
*/ */
@ -48,14 +56,14 @@ struct spa_plugin_loader_methods {
int (*unload)(void *object, struct spa_handle *handle); int (*unload)(void *object, struct spa_handle *handle);
}; };
SPA_API_IMPL struct spa_handle * SPA_API_PLUGIN_LOADER struct spa_handle *
spa_plugin_loader_load(struct spa_plugin_loader *loader, const char *factory_name, const struct spa_dict *info) spa_plugin_loader_load(struct spa_plugin_loader *loader, const char *factory_name, const struct spa_dict *info)
{ {
return spa_api_method_null_r(struct spa_handle *, NULL, spa_plugin_loader, &loader->iface, return spa_api_method_null_r(struct spa_handle *, NULL, spa_plugin_loader, &loader->iface,
load, 0, factory_name, info); load, 0, factory_name, info);
} }
SPA_API_IMPL int SPA_API_PLUGIN_LOADER int
spa_plugin_loader_unload(struct spa_plugin_loader *loader, struct spa_handle *handle) spa_plugin_loader_unload(struct spa_plugin_loader *loader, struct spa_handle *handle)
{ {
return spa_api_method_null_r(int, -1, spa_plugin_loader, &loader->iface, return spa_api_method_null_r(int, -1, spa_plugin_loader, &loader->iface,

View file

@ -15,6 +15,14 @@ extern "C" {
#include <spa/utils/hook.h> #include <spa/utils/hook.h>
#include <spa/utils/dict.h> #include <spa/utils/dict.h>
#ifndef SPA_API_PLUGIN
#ifdef SPA_API_IMPL
#define SPA_API_PLUGIN SPA_API_IMPL
#else
#define SPA_API_PLUGIN static inline
#endif
#endif
/** /**
* \defgroup spa_handle Plugin Handle * \defgroup spa_handle Plugin Handle
* SPA plugin handle and factory interfaces * SPA plugin handle and factory interfaces
@ -54,13 +62,13 @@ struct spa_handle {
int (*clear) (struct spa_handle *handle); int (*clear) (struct spa_handle *handle);
}; };
SPA_API_IMPL int SPA_API_PLUGIN int
spa_handle_get_interface(struct spa_handle *object, spa_handle_get_interface(struct spa_handle *object,
const char *type, void **iface) const char *type, void **iface)
{ {
return spa_api_func_r(int, -ENOTSUP, object, get_interface, 0, type, iface); return spa_api_func_r(int, -ENOTSUP, object, get_interface, 0, type, iface);
} }
SPA_API_IMPL int SPA_API_PLUGIN int
spa_handle_clear(struct spa_handle *object) spa_handle_clear(struct spa_handle *object)
{ {
return spa_api_func_r(int, -ENOTSUP, object, clear, 0); return spa_api_func_r(int, -ENOTSUP, object, clear, 0);
@ -85,7 +93,7 @@ struct spa_support {
}; };
/** Find a support item of the given type */ /** Find a support item of the given type */
SPA_API_IMPL void *spa_support_find(const struct spa_support *support, SPA_API_PLUGIN void *spa_support_find(const struct spa_support *support,
uint32_t n_support, uint32_t n_support,
const char *type) const char *type)
{ {
@ -170,13 +178,13 @@ struct spa_handle_factory {
uint32_t *index); uint32_t *index);
}; };
SPA_API_IMPL size_t SPA_API_PLUGIN size_t
spa_handle_factory_get_size(const struct spa_handle_factory *object, spa_handle_factory_get_size(const struct spa_handle_factory *object,
const struct spa_dict *params) const struct spa_dict *params)
{ {
return spa_api_func_r(size_t, 0, object, get_size, 1, params); return spa_api_func_r(size_t, 0, object, get_size, 1, params);
} }
SPA_API_IMPL int SPA_API_PLUGIN int
spa_handle_factory_init(const struct spa_handle_factory *object, spa_handle_factory_init(const struct spa_handle_factory *object,
struct spa_handle *handle, const struct spa_dict *info, struct spa_handle *handle, const struct spa_dict *info,
const struct spa_support *support, uint32_t n_support) const struct spa_support *support, uint32_t n_support)
@ -184,7 +192,7 @@ spa_handle_factory_init(const struct spa_handle_factory *object,
return spa_api_func_r(int, -ENOTSUP, object, init, 1, handle, info, return spa_api_func_r(int, -ENOTSUP, object, init, 1, handle, info,
support, n_support); support, n_support);
} }
SPA_API_IMPL int SPA_API_PLUGIN int
spa_handle_factory_enum_interface_info(const struct spa_handle_factory *object, spa_handle_factory_enum_interface_info(const struct spa_handle_factory *object,
const struct spa_interface_info **info, uint32_t *index) const struct spa_interface_info **info, uint32_t *index)
{ {

View file

@ -18,6 +18,14 @@ struct itimerspec;
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#include <spa/utils/hook.h> #include <spa/utils/hook.h>
#ifndef SPA_API_SYSTEM
#ifdef SPA_API_IMPL
#define SPA_API_SYSTEM SPA_API_IMPL
#else
#define SPA_API_SYSTEM static inline
#endif
#endif
/** \defgroup spa_system System /** \defgroup spa_system System
* I/O, clock, polling, timer, and signal interfaces * I/O, clock, polling, timer, and signal interfaces
*/ */
@ -98,60 +106,60 @@ struct spa_system_methods {
int (*signalfd_read) (void *object, int fd, int *signal); int (*signalfd_read) (void *object, int fd, int *signal);
}; };
SPA_API_IMPL ssize_t spa_system_read(struct spa_system *object, int fd, void *buf, size_t count) SPA_API_SYSTEM ssize_t spa_system_read(struct spa_system *object, int fd, void *buf, size_t count)
{ {
return spa_api_method_fast_r(ssize_t, -ENOTSUP, spa_system, &object->iface, read, 0, fd, buf, count); return spa_api_method_fast_r(ssize_t, -ENOTSUP, spa_system, &object->iface, read, 0, fd, buf, count);
} }
SPA_API_IMPL ssize_t spa_system_write(struct spa_system *object, int fd, const void *buf, size_t count) SPA_API_SYSTEM ssize_t spa_system_write(struct spa_system *object, int fd, const void *buf, size_t count)
{ {
return spa_api_method_fast_r(ssize_t, -ENOTSUP, spa_system, &object->iface, write, 0, fd, buf, count); return spa_api_method_fast_r(ssize_t, -ENOTSUP, spa_system, &object->iface, write, 0, fd, buf, count);
} }
#define spa_system_ioctl(object,fd,request,...) \ #define spa_system_ioctl(object,fd,request,...) \
spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, ioctl, 0, fd, request, ##__VA_ARGS__) spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, ioctl, 0, fd, request, ##__VA_ARGS__)
SPA_API_IMPL int spa_system_close(struct spa_system *object, int fd) SPA_API_SYSTEM int spa_system_close(struct spa_system *object, int fd)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, close, 0, fd); return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, close, 0, fd);
} }
SPA_API_IMPL int spa_system_clock_gettime(struct spa_system *object, SPA_API_SYSTEM int spa_system_clock_gettime(struct spa_system *object,
int clockid, struct timespec *value) int clockid, struct timespec *value)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, clock_gettime, 0, clockid, value); return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, clock_gettime, 0, clockid, value);
} }
SPA_API_IMPL int spa_system_clock_getres(struct spa_system *object, SPA_API_SYSTEM int spa_system_clock_getres(struct spa_system *object,
int clockid, struct timespec *res) int clockid, struct timespec *res)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, clock_getres, 0, clockid, res); return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, clock_getres, 0, clockid, res);
} }
SPA_API_IMPL int spa_system_pollfd_create(struct spa_system *object, int flags) SPA_API_SYSTEM int spa_system_pollfd_create(struct spa_system *object, int flags)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_create, 0, flags); return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_create, 0, flags);
} }
SPA_API_IMPL int spa_system_pollfd_add(struct spa_system *object, int pfd, int fd, uint32_t events, void *data) SPA_API_SYSTEM int spa_system_pollfd_add(struct spa_system *object, int pfd, int fd, uint32_t events, void *data)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_add, 0, pfd, fd, events, data); return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_add, 0, pfd, fd, events, data);
} }
SPA_API_IMPL int spa_system_pollfd_mod(struct spa_system *object, int pfd, int fd, uint32_t events, void *data) SPA_API_SYSTEM int spa_system_pollfd_mod(struct spa_system *object, int pfd, int fd, uint32_t events, void *data)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_mod, 0, pfd, fd, events, data); return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_mod, 0, pfd, fd, events, data);
} }
SPA_API_IMPL int spa_system_pollfd_del(struct spa_system *object, int pfd, int fd) SPA_API_SYSTEM int spa_system_pollfd_del(struct spa_system *object, int pfd, int fd)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_del, 0, pfd, fd); return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_del, 0, pfd, fd);
} }
SPA_API_IMPL int spa_system_pollfd_wait(struct spa_system *object, int pfd, SPA_API_SYSTEM int spa_system_pollfd_wait(struct spa_system *object, int pfd,
struct spa_poll_event *ev, int n_ev, int timeout) struct spa_poll_event *ev, int n_ev, int timeout)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_wait, 0, pfd, ev, n_ev, timeout); return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_wait, 0, pfd, ev, n_ev, timeout);
} }
SPA_API_IMPL int spa_system_timerfd_create(struct spa_system *object, int clockid, int flags) SPA_API_SYSTEM int spa_system_timerfd_create(struct spa_system *object, int clockid, int flags)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_create, 0, clockid, flags); return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_create, 0, clockid, flags);
} }
SPA_API_IMPL int spa_system_timerfd_settime(struct spa_system *object, SPA_API_SYSTEM int spa_system_timerfd_settime(struct spa_system *object,
int fd, int flags, int fd, int flags,
const struct itimerspec *new_value, const struct itimerspec *new_value,
struct itimerspec *old_value) struct itimerspec *old_value)
@ -160,40 +168,40 @@ SPA_API_IMPL int spa_system_timerfd_settime(struct spa_system *object,
fd, flags, new_value, old_value); fd, flags, new_value, old_value);
} }
SPA_API_IMPL int spa_system_timerfd_gettime(struct spa_system *object, SPA_API_SYSTEM int spa_system_timerfd_gettime(struct spa_system *object,
int fd, struct itimerspec *curr_value) int fd, struct itimerspec *curr_value)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_gettime, 0, return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_gettime, 0,
fd, curr_value); fd, curr_value);
} }
SPA_API_IMPL int spa_system_timerfd_read(struct spa_system *object, int fd, uint64_t *expirations) SPA_API_SYSTEM int spa_system_timerfd_read(struct spa_system *object, int fd, uint64_t *expirations)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_read, 0, return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_read, 0,
fd, expirations); fd, expirations);
} }
SPA_API_IMPL int spa_system_eventfd_create(struct spa_system *object, int flags) SPA_API_SYSTEM int spa_system_eventfd_create(struct spa_system *object, int flags)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_create, 0, flags); return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_create, 0, flags);
} }
SPA_API_IMPL int spa_system_eventfd_write(struct spa_system *object, int fd, uint64_t count) SPA_API_SYSTEM int spa_system_eventfd_write(struct spa_system *object, int fd, uint64_t count)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_write, 0, return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_write, 0,
fd, count); fd, count);
} }
SPA_API_IMPL int spa_system_eventfd_read(struct spa_system *object, int fd, uint64_t *count) SPA_API_SYSTEM int spa_system_eventfd_read(struct spa_system *object, int fd, uint64_t *count)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_read, 0, return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_read, 0,
fd, count); fd, count);
} }
SPA_API_IMPL int spa_system_signalfd_create(struct spa_system *object, int signal, int flags) SPA_API_SYSTEM int spa_system_signalfd_create(struct spa_system *object, int signal, int flags)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, signalfd_create, 0, return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, signalfd_create, 0,
signal, flags); signal, flags);
} }
SPA_API_IMPL int spa_system_signalfd_read(struct spa_system *object, int fd, int *signal) SPA_API_SYSTEM int spa_system_signalfd_read(struct spa_system *object, int fd, int *signal)
{ {
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, signalfd_read, 0, return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, signalfd_read, 0,
fd, signal); fd, signal);

View file

@ -16,6 +16,14 @@ extern "C" {
#include <spa/utils/hook.h> #include <spa/utils/hook.h>
#include <spa/utils/dict.h> #include <spa/utils/dict.h>
#ifndef SPA_API_THREAD
#ifdef SPA_API_IMPL
#define SPA_API_THREAD SPA_API_IMPL
#else
#define SPA_API_THREAD static inline
#endif
#endif
/** \defgroup spa_thread Thread /** \defgroup spa_thread Thread
* Threading utility interfaces * Threading utility interfaces
*/ */
@ -58,7 +66,7 @@ struct spa_thread_utils_methods {
/** \copydoc spa_thread_utils_methods.create /** \copydoc spa_thread_utils_methods.create
* \sa spa_thread_utils_methods.create */ * \sa spa_thread_utils_methods.create */
SPA_API_IMPL struct spa_thread *spa_thread_utils_create(struct spa_thread_utils *o, SPA_API_THREAD struct spa_thread *spa_thread_utils_create(struct spa_thread_utils *o,
const struct spa_dict *props, void *(*start_routine)(void*), void *arg) const struct spa_dict *props, void *(*start_routine)(void*), void *arg)
{ {
return spa_api_method_r(struct spa_thread *, NULL, return spa_api_method_r(struct spa_thread *, NULL,
@ -68,7 +76,7 @@ SPA_API_IMPL struct spa_thread *spa_thread_utils_create(struct spa_thread_utils
/** \copydoc spa_thread_utils_methods.join /** \copydoc spa_thread_utils_methods.join
* \sa spa_thread_utils_methods.join */ * \sa spa_thread_utils_methods.join */
SPA_API_IMPL int spa_thread_utils_join(struct spa_thread_utils *o, SPA_API_THREAD int spa_thread_utils_join(struct spa_thread_utils *o,
struct spa_thread *thread, void **retval) struct spa_thread *thread, void **retval)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
@ -78,7 +86,7 @@ SPA_API_IMPL int spa_thread_utils_join(struct spa_thread_utils *o,
/** \copydoc spa_thread_utils_methods.get_rt_range /** \copydoc spa_thread_utils_methods.get_rt_range
* \sa spa_thread_utils_methods.get_rt_range */ * \sa spa_thread_utils_methods.get_rt_range */
SPA_API_IMPL int spa_thread_utils_get_rt_range(struct spa_thread_utils *o, SPA_API_THREAD int spa_thread_utils_get_rt_range(struct spa_thread_utils *o,
const struct spa_dict *props, int *min, int *max) const struct spa_dict *props, int *min, int *max)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
@ -88,7 +96,7 @@ SPA_API_IMPL int spa_thread_utils_get_rt_range(struct spa_thread_utils *o,
/** \copydoc spa_thread_utils_methods.acquire_rt /** \copydoc spa_thread_utils_methods.acquire_rt
* \sa spa_thread_utils_methods.acquire_rt */ * \sa spa_thread_utils_methods.acquire_rt */
SPA_API_IMPL int spa_thread_utils_acquire_rt(struct spa_thread_utils *o, SPA_API_THREAD int spa_thread_utils_acquire_rt(struct spa_thread_utils *o,
struct spa_thread *thread, int priority) struct spa_thread *thread, int priority)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,
@ -98,7 +106,7 @@ SPA_API_IMPL int spa_thread_utils_acquire_rt(struct spa_thread_utils *o,
/** \copydoc spa_thread_utils_methods.drop_rt /** \copydoc spa_thread_utils_methods.drop_rt
* \sa spa_thread_utils_methods.drop_rt */ * \sa spa_thread_utils_methods.drop_rt */
SPA_API_IMPL int spa_thread_utils_drop_rt(struct spa_thread_utils *o, SPA_API_THREAD int spa_thread_utils_drop_rt(struct spa_thread_utils *o,
struct spa_thread *thread) struct spa_thread *thread)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,

View file

@ -259,6 +259,15 @@ struct spa_fraction {
#define SPA_API_IMPL static inline #define SPA_API_IMPL static inline
#endif #endif
#ifndef SPA_API_UTILS_DEFS
#ifdef SPA_API_IMPL
#define SPA_API_UTILS_DEFS SPA_API_IMPL
#else
#define SPA_API_UTILS_DEFS static inline
#endif
#endif
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define SPA_RESTRICT restrict #define SPA_RESTRICT restrict
#elif defined(__GNUC__) && __GNUC__ >= 4 #elif defined(__GNUC__) && __GNUC__ >= 4
@ -305,7 +314,7 @@ struct spa_fraction {
#endif #endif
#endif #endif
SPA_API_IMPL bool spa_ptrinside(const void *p1, size_t s1, const void *p2, size_t s2, SPA_API_UTILS_DEFS bool spa_ptrinside(const void *p1, size_t s1, const void *p2, size_t s2,
size_t *remaining) size_t *remaining)
{ {
if (SPA_LIKELY((uintptr_t)p1 <= (uintptr_t)p2 && s2 <= s1 && if (SPA_LIKELY((uintptr_t)p1 <= (uintptr_t)p2 && s2 <= s1 &&
@ -320,7 +329,7 @@ SPA_API_IMPL bool spa_ptrinside(const void *p1, size_t s1, const void *p2, size_
} }
} }
SPA_API_IMPL bool spa_ptr_inside_and_aligned(const void *p1, size_t s1, SPA_API_UTILS_DEFS bool spa_ptr_inside_and_aligned(const void *p1, size_t s1,
const void *p2, size_t s2, size_t align, const void *p2, size_t s2, size_t align,
size_t *remaining) size_t *remaining)
{ {

View file

@ -13,6 +13,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#ifndef SPA_API_DICT
#ifdef SPA_API_IMPL
#define SPA_API_DICT SPA_API_IMPL
#else
#define SPA_API_DICT static inline
#endif
#endif
/** /**
* \defgroup spa_dict Dictionary * \defgroup spa_dict Dictionary
* Dictionary data structure * Dictionary data structure
@ -50,14 +58,14 @@ struct spa_dict {
(item) < &(dict)->items[(dict)->n_items]; \ (item) < &(dict)->items[(dict)->n_items]; \
(item)++) (item)++)
SPA_API_IMPL int spa_dict_item_compare(const void *i1, const void *i2) SPA_API_DICT int spa_dict_item_compare(const void *i1, const void *i2)
{ {
const struct spa_dict_item *it1 = (const struct spa_dict_item *)i1, const struct spa_dict_item *it1 = (const struct spa_dict_item *)i1,
*it2 = (const struct spa_dict_item *)i2; *it2 = (const struct spa_dict_item *)i2;
return strcmp(it1->key, it2->key); return strcmp(it1->key, it2->key);
} }
SPA_API_IMPL void spa_dict_qsort(struct spa_dict *dict) SPA_API_DICT void spa_dict_qsort(struct spa_dict *dict)
{ {
if (dict->n_items > 0) if (dict->n_items > 0)
qsort((void*)dict->items, dict->n_items, sizeof(struct spa_dict_item), qsort((void*)dict->items, dict->n_items, sizeof(struct spa_dict_item),
@ -65,7 +73,7 @@ SPA_API_IMPL void spa_dict_qsort(struct spa_dict *dict)
SPA_FLAG_SET(dict->flags, SPA_DICT_FLAG_SORTED); SPA_FLAG_SET(dict->flags, SPA_DICT_FLAG_SORTED);
} }
SPA_API_IMPL const struct spa_dict_item *spa_dict_lookup_item(const struct spa_dict *dict, SPA_API_DICT const struct spa_dict_item *spa_dict_lookup_item(const struct spa_dict *dict,
const char *key) const char *key)
{ {
const struct spa_dict_item *item; const struct spa_dict_item *item;
@ -88,7 +96,7 @@ SPA_API_IMPL const struct spa_dict_item *spa_dict_lookup_item(const struct spa_d
return NULL; return NULL;
} }
SPA_API_IMPL const char *spa_dict_lookup(const struct spa_dict *dict, const char *key) SPA_API_DICT const char *spa_dict_lookup(const struct spa_dict *dict, const char *key)
{ {
const struct spa_dict_item *item = spa_dict_lookup_item(dict, key); const struct spa_dict_item *item = spa_dict_lookup_item(dict, key);
return item ? item->value : NULL; return item ? item->value : NULL;

View file

@ -14,6 +14,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#ifndef SPA_API_DLL
#ifdef SPA_API_IMPL
#define SPA_API_DLL SPA_API_IMPL
#else
#define SPA_API_DLL static inline
#endif
#endif
#define SPA_DLL_BW_MAX 0.128 #define SPA_DLL_BW_MAX 0.128
#define SPA_DLL_BW_MIN 0.016 #define SPA_DLL_BW_MIN 0.016
@ -23,13 +31,13 @@ struct spa_dll {
double w0, w1, w2; double w0, w1, w2;
}; };
SPA_API_IMPL void spa_dll_init(struct spa_dll *dll) SPA_API_DLL void spa_dll_init(struct spa_dll *dll)
{ {
dll->bw = 0.0; dll->bw = 0.0;
dll->z1 = dll->z2 = dll->z3 = 0.0; dll->z1 = dll->z2 = dll->z3 = 0.0;
} }
SPA_API_IMPL void spa_dll_set_bw(struct spa_dll *dll, double bw, unsigned period, unsigned rate) SPA_API_DLL void spa_dll_set_bw(struct spa_dll *dll, double bw, unsigned period, unsigned rate)
{ {
double w = 2 * M_PI * bw * period / rate; double w = 2 * M_PI * bw * period / rate;
dll->w0 = 1.0 - exp (-20.0 * w); dll->w0 = 1.0 - exp (-20.0 * w);
@ -38,7 +46,7 @@ SPA_API_IMPL void spa_dll_set_bw(struct spa_dll *dll, double bw, unsigned period
dll->bw = bw; dll->bw = bw;
} }
SPA_API_IMPL double spa_dll_update(struct spa_dll *dll, double err) SPA_API_DLL double spa_dll_update(struct spa_dll *dll, double err)
{ {
dll->z1 += dll->w0 * (dll->w1 * err - dll->z1); dll->z1 += dll->w0 * (dll->w1 * err - dll->z1);
dll->z2 += dll->w0 * (dll->z1 - dll->z2); dll->z2 += dll->w0 * (dll->z1 - dll->z2);

View file

@ -12,6 +12,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#include <spa/utils/list.h> #include <spa/utils/list.h>
#ifndef SPA_API_HOOK
#ifdef SPA_API_IMPL
#define SPA_API_HOOK SPA_API_IMPL
#else
#define SPA_API_HOOK static inline
#endif
#endif
/** \defgroup spa_interfaces Interfaces /** \defgroup spa_interfaces Interfaces
* *
* \brief Generic implementation of implementation-independent interfaces * \brief Generic implementation of implementation-independent interfaces
@ -411,18 +419,18 @@ struct spa_hook {
}; };
/** Initialize a hook list to the empty list*/ /** Initialize a hook list to the empty list*/
SPA_API_IMPL void spa_hook_list_init(struct spa_hook_list *list) SPA_API_HOOK void spa_hook_list_init(struct spa_hook_list *list)
{ {
spa_list_init(&list->list); spa_list_init(&list->list);
} }
SPA_API_IMPL bool spa_hook_list_is_empty(struct spa_hook_list *list) SPA_API_HOOK bool spa_hook_list_is_empty(struct spa_hook_list *list)
{ {
return spa_list_is_empty(&list->list); return spa_list_is_empty(&list->list);
} }
/** Append a hook. */ /** Append a hook. */
SPA_API_IMPL void spa_hook_list_append(struct spa_hook_list *list, SPA_API_HOOK void spa_hook_list_append(struct spa_hook_list *list,
struct spa_hook *hook, struct spa_hook *hook,
const void *funcs, void *data) const void *funcs, void *data)
{ {
@ -432,7 +440,7 @@ SPA_API_IMPL void spa_hook_list_append(struct spa_hook_list *list,
} }
/** Prepend a hook */ /** Prepend a hook */
SPA_API_IMPL void spa_hook_list_prepend(struct spa_hook_list *list, SPA_API_HOOK void spa_hook_list_prepend(struct spa_hook_list *list,
struct spa_hook *hook, struct spa_hook *hook,
const void *funcs, void *data) const void *funcs, void *data)
{ {
@ -442,7 +450,7 @@ SPA_API_IMPL void spa_hook_list_prepend(struct spa_hook_list *list,
} }
/** Remove a hook */ /** Remove a hook */
SPA_API_IMPL void spa_hook_remove(struct spa_hook *hook) SPA_API_HOOK void spa_hook_remove(struct spa_hook *hook)
{ {
if (spa_list_is_initialized(&hook->link)) if (spa_list_is_initialized(&hook->link))
spa_list_remove(&hook->link); spa_list_remove(&hook->link);
@ -451,14 +459,14 @@ SPA_API_IMPL void spa_hook_remove(struct spa_hook *hook)
} }
/** Remove all hooks from the list */ /** Remove all hooks from the list */
SPA_API_IMPL void spa_hook_list_clean(struct spa_hook_list *list) SPA_API_HOOK void spa_hook_list_clean(struct spa_hook_list *list)
{ {
struct spa_hook *h; struct spa_hook *h;
spa_list_consume(h, &list->list, link) spa_list_consume(h, &list->list, link)
spa_hook_remove(h); spa_hook_remove(h);
} }
SPA_API_IMPL void SPA_API_HOOK void
spa_hook_list_isolate(struct spa_hook_list *list, spa_hook_list_isolate(struct spa_hook_list *list,
struct spa_hook_list *save, struct spa_hook_list *save,
struct spa_hook *hook, struct spa_hook *hook,
@ -472,7 +480,7 @@ spa_hook_list_isolate(struct spa_hook_list *list,
spa_hook_list_append(list, hook, funcs, data); spa_hook_list_append(list, hook, funcs, data);
} }
SPA_API_IMPL void SPA_API_HOOK void
spa_hook_list_join(struct spa_hook_list *list, spa_hook_list_join(struct spa_hook_list *list,
struct spa_hook_list *save) struct spa_hook_list *save)
{ {

View file

@ -20,6 +20,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#include <spa/utils/string.h> #include <spa/utils/string.h>
#ifndef SPA_API_JSON
#ifdef SPA_API_IMPL
#define SPA_API_JSON SPA_API_IMPL
#else
#define SPA_API_JSON static inline
#endif
#endif
/** \defgroup spa_json JSON /** \defgroup spa_json JSON
* Relaxed JSON variant parsing * Relaxed JSON variant parsing
*/ */
@ -41,13 +49,13 @@ struct spa_json {
#define SPA_JSON_INIT(data,size) ((struct spa_json) { (data), (data)+(size), NULL, 0, 0 }) #define SPA_JSON_INIT(data,size) ((struct spa_json) { (data), (data)+(size), NULL, 0, 0 })
SPA_API_IMPL void spa_json_init(struct spa_json * iter, const char *data, size_t size) SPA_API_JSON void spa_json_init(struct spa_json * iter, const char *data, size_t size)
{ {
*iter = SPA_JSON_INIT(data, size); *iter = SPA_JSON_INIT(data, size);
} }
#define SPA_JSON_ENTER(iter) ((struct spa_json) { (iter)->cur, (iter)->end, (iter), (iter)->state & 0xff0, 0 }) #define SPA_JSON_ENTER(iter) ((struct spa_json) { (iter)->cur, (iter)->end, (iter), (iter)->state & 0xff0, 0 })
SPA_API_IMPL void spa_json_enter(struct spa_json * iter, struct spa_json * sub) SPA_API_JSON void spa_json_enter(struct spa_json * iter, struct spa_json * sub)
{ {
*sub = SPA_JSON_ENTER(iter); *sub = SPA_JSON_ENTER(iter);
} }
@ -58,7 +66,7 @@ SPA_API_IMPL void spa_json_enter(struct spa_json * iter, struct spa_json * sub)
/** Get the next token. \a value points to the token and the return value /** Get the next token. \a value points to the token and the return value
* is the length. Returns -1 on parse error, 0 on end of input. */ * is the length. Returns -1 on parse error, 0 on end of input. */
SPA_API_IMPL int spa_json_next(struct spa_json * iter, const char **value) SPA_API_JSON int spa_json_next(struct spa_json * iter, const char **value)
{ {
int utf8_remain = 0, err = 0; int utf8_remain = 0, err = 0;
enum { enum {
@ -312,7 +320,7 @@ error:
* *
* \since 1.1.0 * \since 1.1.0
*/ */
SPA_API_IMPL bool spa_json_get_error(struct spa_json *iter, const char *start, SPA_API_JSON bool spa_json_get_error(struct spa_json *iter, const char *start,
struct spa_error_location *loc) struct spa_error_location *loc)
{ {
static const char *reasons[] = { static const char *reasons[] = {
@ -358,31 +366,31 @@ SPA_API_IMPL bool spa_json_get_error(struct spa_json *iter, const char *start,
return true; return true;
} }
SPA_API_IMPL int spa_json_is_container(const char *val, int len) SPA_API_JSON int spa_json_is_container(const char *val, int len)
{ {
return len > 0 && (*val == '{' || *val == '['); return len > 0 && (*val == '{' || *val == '[');
} }
/* object */ /* object */
SPA_API_IMPL int spa_json_is_object(const char *val, int len) SPA_API_JSON int spa_json_is_object(const char *val, int len)
{ {
return len > 0 && *val == '{'; return len > 0 && *val == '{';
} }
/* array */ /* array */
SPA_API_IMPL bool spa_json_is_array(const char *val, int len) SPA_API_JSON bool spa_json_is_array(const char *val, int len)
{ {
return len > 0 && *val == '['; return len > 0 && *val == '[';
} }
/* null */ /* null */
SPA_API_IMPL bool spa_json_is_null(const char *val, int len) SPA_API_JSON bool spa_json_is_null(const char *val, int len)
{ {
return len == 4 && strncmp(val, "null", 4) == 0; return len == 4 && strncmp(val, "null", 4) == 0;
} }
/* float */ /* float */
SPA_API_IMPL int spa_json_parse_float(const char *val, int len, float *result) SPA_API_JSON int spa_json_parse_float(const char *val, int len, float *result)
{ {
char buf[96]; char buf[96];
char *end; char *end;
@ -405,13 +413,13 @@ SPA_API_IMPL int spa_json_parse_float(const char *val, int len, float *result)
return len > 0 && end == buf + len; return len > 0 && end == buf + len;
} }
SPA_API_IMPL bool spa_json_is_float(const char *val, int len) SPA_API_JSON bool spa_json_is_float(const char *val, int len)
{ {
float dummy; float dummy;
return spa_json_parse_float(val, len, &dummy); return spa_json_parse_float(val, len, &dummy);
} }
SPA_API_IMPL char *spa_json_format_float(char *str, int size, float val) SPA_API_JSON char *spa_json_format_float(char *str, int size, float val)
{ {
if (SPA_UNLIKELY(!isnormal(val))) { if (SPA_UNLIKELY(!isnormal(val))) {
if (isinf(val)) if (isinf(val))
@ -423,7 +431,7 @@ SPA_API_IMPL char *spa_json_format_float(char *str, int size, float val)
} }
/* int */ /* int */
SPA_API_IMPL int spa_json_parse_int(const char *val, int len, int *result) SPA_API_JSON int spa_json_parse_int(const char *val, int len, int *result)
{ {
char buf[64]; char buf[64];
char *end; char *end;
@ -437,29 +445,29 @@ SPA_API_IMPL int spa_json_parse_int(const char *val, int len, int *result)
*result = strtol(buf, &end, 0); *result = strtol(buf, &end, 0);
return len > 0 && end == buf + len; return len > 0 && end == buf + len;
} }
SPA_API_IMPL bool spa_json_is_int(const char *val, int len) SPA_API_JSON bool spa_json_is_int(const char *val, int len)
{ {
int dummy; int dummy;
return spa_json_parse_int(val, len, &dummy); return spa_json_parse_int(val, len, &dummy);
} }
/* bool */ /* bool */
SPA_API_IMPL bool spa_json_is_true(const char *val, int len) SPA_API_JSON bool spa_json_is_true(const char *val, int len)
{ {
return len == 4 && strncmp(val, "true", 4) == 0; return len == 4 && strncmp(val, "true", 4) == 0;
} }
SPA_API_IMPL bool spa_json_is_false(const char *val, int len) SPA_API_JSON bool spa_json_is_false(const char *val, int len)
{ {
return len == 5 && strncmp(val, "false", 5) == 0; return len == 5 && strncmp(val, "false", 5) == 0;
} }
SPA_API_IMPL bool spa_json_is_bool(const char *val, int len) SPA_API_JSON bool spa_json_is_bool(const char *val, int len)
{ {
return spa_json_is_true(val, len) || spa_json_is_false(val, len); return spa_json_is_true(val, len) || spa_json_is_false(val, len);
} }
SPA_API_IMPL int spa_json_parse_bool(const char *val, int len, bool *result) SPA_API_JSON int spa_json_parse_bool(const char *val, int len, bool *result)
{ {
if ((*result = spa_json_is_true(val, len))) if ((*result = spa_json_is_true(val, len)))
return 1; return 1;
@ -469,12 +477,12 @@ SPA_API_IMPL int spa_json_parse_bool(const char *val, int len, bool *result)
} }
/* string */ /* string */
SPA_API_IMPL bool spa_json_is_string(const char *val, int len) SPA_API_JSON bool spa_json_is_string(const char *val, int len)
{ {
return len > 1 && *val == '"'; return len > 1 && *val == '"';
} }
SPA_API_IMPL int spa_json_parse_hex(const char *p, int num, uint32_t *res) SPA_API_JSON int spa_json_parse_hex(const char *p, int num, uint32_t *res)
{ {
int i; int i;
*res = 0; *res = 0;
@ -493,7 +501,7 @@ SPA_API_IMPL int spa_json_parse_hex(const char *p, int num, uint32_t *res)
return 1; return 1;
} }
SPA_API_IMPL int spa_json_parse_stringn(const char *val, int len, char *result, int maxlen) SPA_API_JSON int spa_json_parse_stringn(const char *val, int len, char *result, int maxlen)
{ {
const char *p; const char *p;
if (maxlen <= len) if (maxlen <= len)
@ -556,12 +564,12 @@ SPA_API_IMPL int spa_json_parse_stringn(const char *val, int len, char *result,
return 1; return 1;
} }
SPA_API_IMPL int spa_json_parse_string(const char *val, int len, char *result) SPA_API_JSON int spa_json_parse_string(const char *val, int len, char *result)
{ {
return spa_json_parse_stringn(val, len, result, len+1); return spa_json_parse_stringn(val, len, result, len+1);
} }
SPA_API_IMPL int spa_json_encode_string(char *str, int size, const char *val) SPA_API_JSON int spa_json_encode_string(char *str, int size, const char *val)
{ {
int len = 0; int len = 0;
static const char hex[] = { "0123456789abcdef" }; static const char hex[] = { "0123456789abcdef" };

View file

@ -15,6 +15,14 @@ extern "C" {
#include <spa/pod/builder.h> #include <spa/pod/builder.h>
#include <spa/debug/types.h> #include <spa/debug/types.h>
#ifndef SPA_API_JSON_POD
#ifdef SPA_API_IMPL
#define SPA_API_JSON_POD SPA_API_IMPL
#else
#define SPA_API_JSON_POD static inline
#endif
#endif
/** \defgroup spa_json_pod JSON to POD /** \defgroup spa_json_pod JSON to POD
* JSON to POD conversion * JSON to POD conversion
*/ */
@ -24,7 +32,7 @@ extern "C" {
* \{ * \{
*/ */
SPA_API_IMPL int spa_json_to_pod_part(struct spa_pod_builder *b, uint32_t flags, uint32_t id, SPA_API_JSON_POD int spa_json_to_pod_part(struct spa_pod_builder *b, uint32_t flags, uint32_t id,
const struct spa_type_info *info, struct spa_json *iter, const char *value, int len) const struct spa_type_info *info, struct spa_json *iter, const char *value, int len)
{ {
const struct spa_type_info *ti; const struct spa_type_info *ti;
@ -135,7 +143,7 @@ SPA_API_IMPL int spa_json_to_pod_part(struct spa_pod_builder *b, uint32_t flags,
return 0; return 0;
} }
SPA_API_IMPL int spa_json_to_pod_checked(struct spa_pod_builder *b, uint32_t flags, SPA_API_JSON_POD int spa_json_to_pod_checked(struct spa_pod_builder *b, uint32_t flags,
const struct spa_type_info *info, const char *value, int len, const struct spa_type_info *info, const char *value, int len,
struct spa_error_location *loc) struct spa_error_location *loc)
{ {
@ -157,7 +165,7 @@ error:
return res; return res;
} }
SPA_API_IMPL int spa_json_to_pod(struct spa_pod_builder *b, uint32_t flags, SPA_API_JSON_POD int spa_json_to_pod(struct spa_pod_builder *b, uint32_t flags,
const struct spa_type_info *info, const char *value, int len) const struct spa_type_info *info, const char *value, int len)
{ {
return spa_json_to_pod_checked(b, flags, info, value, len, NULL); return spa_json_to_pod_checked(b, flags, info, value, len, NULL);

View file

@ -19,6 +19,14 @@ extern "C" {
#include <spa/utils/json-core.h> #include <spa/utils/json-core.h>
#ifndef SPA_API_JSON_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_JSON_UTILS SPA_API_IMPL
#else
#define SPA_API_JSON_UTILS static inline
#endif
#endif
/** \defgroup spa_json_utils JSON Utils /** \defgroup spa_json_utils JSON Utils
* Relaxed JSON variant parsing Utils * Relaxed JSON variant parsing Utils
*/ */
@ -28,14 +36,14 @@ extern "C" {
* \{ * \{
*/ */
SPA_API_IMPL int spa_json_begin(struct spa_json * iter, const char *data, size_t size, const char **val) SPA_API_JSON_UTILS int spa_json_begin(struct spa_json * iter, const char *data, size_t size, const char **val)
{ {
spa_json_init(iter, data, size); spa_json_init(iter, data, size);
return spa_json_next(iter, val); return spa_json_next(iter, val);
} }
/* float */ /* float */
SPA_API_IMPL int spa_json_get_float(struct spa_json *iter, float *res) SPA_API_JSON_UTILS int spa_json_get_float(struct spa_json *iter, float *res)
{ {
const char *value; const char *value;
int len; int len;
@ -45,7 +53,7 @@ SPA_API_IMPL int spa_json_get_float(struct spa_json *iter, float *res)
} }
/* int */ /* int */
SPA_API_IMPL int spa_json_get_int(struct spa_json *iter, int *res) SPA_API_JSON_UTILS int spa_json_get_int(struct spa_json *iter, int *res)
{ {
const char *value; const char *value;
int len; int len;
@ -55,7 +63,7 @@ SPA_API_IMPL int spa_json_get_int(struct spa_json *iter, int *res)
} }
/* bool */ /* bool */
SPA_API_IMPL int spa_json_get_bool(struct spa_json *iter, bool *res) SPA_API_JSON_UTILS int spa_json_get_bool(struct spa_json *iter, bool *res)
{ {
const char *value; const char *value;
int len; int len;
@ -65,7 +73,7 @@ SPA_API_IMPL int spa_json_get_bool(struct spa_json *iter, bool *res)
} }
/* string */ /* string */
SPA_API_IMPL int spa_json_get_string(struct spa_json *iter, char *res, int maxlen) SPA_API_JSON_UTILS int spa_json_get_string(struct spa_json *iter, char *res, int maxlen)
{ {
const char *value; const char *value;
int len; int len;
@ -75,7 +83,7 @@ SPA_API_IMPL int spa_json_get_string(struct spa_json *iter, char *res, int maxle
} }
SPA_API_IMPL int spa_json_enter_container(struct spa_json *iter, struct spa_json *sub, char type) SPA_API_JSON_UTILS int spa_json_enter_container(struct spa_json *iter, struct spa_json *sub, char type)
{ {
const char *value; const char *value;
int len; int len;
@ -89,7 +97,7 @@ SPA_API_IMPL int spa_json_enter_container(struct spa_json *iter, struct spa_json
return 1; return 1;
} }
SPA_API_IMPL int spa_json_begin_container(struct spa_json * iter, SPA_API_JSON_UTILS int spa_json_begin_container(struct spa_json * iter,
const char *data, size_t size, char type, bool relax) const char *data, size_t size, char type, bool relax)
{ {
int res; int res;
@ -106,7 +114,7 @@ SPA_API_IMPL int spa_json_begin_container(struct spa_json * iter,
* *
* \return Length of container including {} or [], or 0 on error. * \return Length of container including {} or [], or 0 on error.
*/ */
SPA_API_IMPL int spa_json_container_len(struct spa_json *iter, const char *value, int len SPA_UNUSED) SPA_API_JSON_UTILS int spa_json_container_len(struct spa_json *iter, const char *value, int len SPA_UNUSED)
{ {
const char *val; const char *val;
struct spa_json sub; struct spa_json sub;
@ -119,20 +127,20 @@ SPA_API_IMPL int spa_json_container_len(struct spa_json *iter, const char *value
} }
/* object */ /* object */
SPA_API_IMPL int spa_json_enter_object(struct spa_json *iter, struct spa_json *sub) SPA_API_JSON_UTILS int spa_json_enter_object(struct spa_json *iter, struct spa_json *sub)
{ {
return spa_json_enter_container(iter, sub, '{'); return spa_json_enter_container(iter, sub, '{');
} }
SPA_API_IMPL int spa_json_begin_object_relax(struct spa_json * iter, const char *data, size_t size) SPA_API_JSON_UTILS int spa_json_begin_object_relax(struct spa_json * iter, const char *data, size_t size)
{ {
return spa_json_begin_container(iter, data, size, '{', true); return spa_json_begin_container(iter, data, size, '{', true);
} }
SPA_API_IMPL int spa_json_begin_object(struct spa_json * iter, const char *data, size_t size) SPA_API_JSON_UTILS int spa_json_begin_object(struct spa_json * iter, const char *data, size_t size)
{ {
return spa_json_begin_container(iter, data, size, '{', false); return spa_json_begin_container(iter, data, size, '{', false);
} }
SPA_API_IMPL int spa_json_object_next(struct spa_json *iter, char *key, int maxkeylen, const char **value) SPA_API_JSON_UTILS int spa_json_object_next(struct spa_json *iter, char *key, int maxkeylen, const char **value)
{ {
int res1, res2; int res1, res2;
while (true) { while (true) {
@ -145,7 +153,7 @@ SPA_API_IMPL int spa_json_object_next(struct spa_json *iter, char *key, int maxk
} }
} }
SPA_API_IMPL int spa_json_object_find(struct spa_json *iter, const char *key, const char **value) SPA_API_JSON_UTILS int spa_json_object_find(struct spa_json *iter, const char *key, const char **value)
{ {
struct spa_json obj = SPA_JSON_SAVE(iter); struct spa_json obj = SPA_JSON_SAVE(iter);
int res, len = strlen(key) + 3; int res, len = strlen(key) + 3;
@ -157,7 +165,7 @@ SPA_API_IMPL int spa_json_object_find(struct spa_json *iter, const char *key, co
return -ENOENT; return -ENOENT;
} }
SPA_API_IMPL int spa_json_str_object_find(const char *obj, size_t obj_len, SPA_API_JSON_UTILS int spa_json_str_object_find(const char *obj, size_t obj_len,
const char *key, char *value, size_t maxlen) const char *key, char *value, size_t maxlen)
{ {
struct spa_json iter; struct spa_json iter;
@ -172,15 +180,15 @@ SPA_API_IMPL int spa_json_str_object_find(const char *obj, size_t obj_len,
} }
/* array */ /* array */
SPA_API_IMPL int spa_json_enter_array(struct spa_json *iter, struct spa_json *sub) SPA_API_JSON_UTILS int spa_json_enter_array(struct spa_json *iter, struct spa_json *sub)
{ {
return spa_json_enter_container(iter, sub, '['); return spa_json_enter_container(iter, sub, '[');
} }
SPA_API_IMPL int spa_json_begin_array_relax(struct spa_json * iter, const char *data, size_t size) SPA_API_JSON_UTILS int spa_json_begin_array_relax(struct spa_json * iter, const char *data, size_t size)
{ {
return spa_json_begin_container(iter, data, size, '[', true); return spa_json_begin_container(iter, data, size, '[', true);
} }
SPA_API_IMPL int spa_json_begin_array(struct spa_json * iter, const char *data, size_t size) SPA_API_JSON_UTILS int spa_json_begin_array(struct spa_json * iter, const char *data, size_t size)
{ {
return spa_json_begin_container(iter, data, size, '[', false); return spa_json_begin_container(iter, data, size, '[', false);
} }
@ -197,7 +205,7 @@ SPA_API_IMPL int spa_json_begin_array(struct spa_json * iter, const char *data,
return count; \ return count; \
} }
SPA_API_IMPL int spa_json_str_array_uint32(const char *arr, size_t arr_len, SPA_API_JSON_UTILS int spa_json_str_array_uint32(const char *arr, size_t arr_len,
uint32_t *values, size_t max) uint32_t *values, size_t max)
{ {
spa_json_make_str_array_unpack(32,uint32_t, atoi); spa_json_make_str_array_unpack(32,uint32_t, atoi);

View file

@ -11,6 +11,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#ifndef SPA_API_LIST
#ifdef SPA_API_IMPL
#define SPA_API_LIST SPA_API_IMPL
#else
#define SPA_API_LIST static inline
#endif
#endif
/** /**
* \defgroup spa_list List * \defgroup spa_list List
* Doubly linked list data structure * Doubly linked list data structure
@ -28,19 +36,19 @@ struct spa_list {
#define SPA_LIST_INIT(list) ((struct spa_list){ (list), (list) }) #define SPA_LIST_INIT(list) ((struct spa_list){ (list), (list) })
SPA_API_IMPL void spa_list_init(struct spa_list *list) SPA_API_LIST void spa_list_init(struct spa_list *list)
{ {
*list = SPA_LIST_INIT(list); *list = SPA_LIST_INIT(list);
} }
SPA_API_IMPL int spa_list_is_initialized(struct spa_list *list) SPA_API_LIST int spa_list_is_initialized(struct spa_list *list)
{ {
return !!list->prev; return !!list->prev;
} }
#define spa_list_is_empty(l) ((l)->next == (l)) #define spa_list_is_empty(l) ((l)->next == (l))
SPA_API_IMPL void spa_list_insert(struct spa_list *list, struct spa_list *elem) SPA_API_LIST void spa_list_insert(struct spa_list *list, struct spa_list *elem)
{ {
elem->prev = list; elem->prev = list;
elem->next = list->next; elem->next = list->next;
@ -48,7 +56,7 @@ SPA_API_IMPL void spa_list_insert(struct spa_list *list, struct spa_list *elem)
elem->next->prev = elem; elem->next->prev = elem;
} }
SPA_API_IMPL void spa_list_insert_list(struct spa_list *list, struct spa_list *other) SPA_API_LIST void spa_list_insert_list(struct spa_list *list, struct spa_list *other)
{ {
if (spa_list_is_empty(other)) if (spa_list_is_empty(other))
return; return;
@ -58,7 +66,7 @@ SPA_API_IMPL void spa_list_insert_list(struct spa_list *list, struct spa_list *o
list->next = other->next; list->next = other->next;
} }
SPA_API_IMPL void spa_list_remove(struct spa_list *elem) SPA_API_LIST void spa_list_remove(struct spa_list *elem)
{ {
elem->prev->next = elem->next; elem->prev->next = elem->next;
elem->next->prev = elem->prev; elem->next->prev = elem->prev;

View file

@ -14,6 +14,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#ifndef SPA_API_RATELIMIT
#ifdef SPA_API_IMPL
#define SPA_API_RATELIMIT SPA_API_IMPL
#else
#define SPA_API_RATELIMIT static inline
#endif
#endif
struct spa_ratelimit { struct spa_ratelimit {
uint64_t interval; uint64_t interval;
uint64_t begin; uint64_t begin;
@ -22,7 +30,7 @@ struct spa_ratelimit {
unsigned n_suppressed; unsigned n_suppressed;
}; };
SPA_API_IMPL int spa_ratelimit_test(struct spa_ratelimit *r, uint64_t now) SPA_API_RATELIMIT int spa_ratelimit_test(struct spa_ratelimit *r, uint64_t now)
{ {
unsigned suppressed = 0; unsigned suppressed = 0;
if (r->begin + r->interval < now) { if (r->begin + r->interval < now) {

View file

@ -25,6 +25,14 @@ struct spa_ringbuffer;
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#ifndef SPA_API_RINGBUFFER
#ifdef SPA_API_IMPL
#define SPA_API_RINGBUFFER SPA_API_IMPL
#else
#define SPA_API_RINGBUFFER static inline
#endif
#endif
/** /**
* A ringbuffer type. * A ringbuffer type.
*/ */
@ -40,7 +48,7 @@ struct spa_ringbuffer {
* *
* \param rbuf a spa_ringbuffer * \param rbuf a spa_ringbuffer
*/ */
SPA_API_IMPL void spa_ringbuffer_init(struct spa_ringbuffer *rbuf) SPA_API_RINGBUFFER void spa_ringbuffer_init(struct spa_ringbuffer *rbuf)
{ {
*rbuf = SPA_RINGBUFFER_INIT(); *rbuf = SPA_RINGBUFFER_INIT();
} }
@ -51,7 +59,7 @@ SPA_API_IMPL void spa_ringbuffer_init(struct spa_ringbuffer *rbuf)
* \param rbuf a spa_ringbuffer * \param rbuf a spa_ringbuffer
* \param size the target size of \a rbuf * \param size the target size of \a rbuf
*/ */
SPA_API_IMPL void spa_ringbuffer_set_avail(struct spa_ringbuffer *rbuf, uint32_t size) SPA_API_RINGBUFFER void spa_ringbuffer_set_avail(struct spa_ringbuffer *rbuf, uint32_t size)
{ {
rbuf->readindex = 0; rbuf->readindex = 0;
rbuf->writeindex = size; rbuf->writeindex = size;
@ -67,7 +75,7 @@ SPA_API_IMPL void spa_ringbuffer_set_avail(struct spa_ringbuffer *rbuf, uint32_t
* there was an underrun. values > rbuf->size means there * there was an underrun. values > rbuf->size means there
* was an overrun. * was an overrun.
*/ */
SPA_API_IMPL int32_t spa_ringbuffer_get_read_index(struct spa_ringbuffer *rbuf, uint32_t *index) SPA_API_RINGBUFFER int32_t spa_ringbuffer_get_read_index(struct spa_ringbuffer *rbuf, uint32_t *index)
{ {
*index = __atomic_load_n(&rbuf->readindex, __ATOMIC_RELAXED); *index = __atomic_load_n(&rbuf->readindex, __ATOMIC_RELAXED);
return (int32_t) (__atomic_load_n(&rbuf->writeindex, __ATOMIC_ACQUIRE) - *index); return (int32_t) (__atomic_load_n(&rbuf->writeindex, __ATOMIC_ACQUIRE) - *index);
@ -84,7 +92,7 @@ SPA_API_IMPL int32_t spa_ringbuffer_get_read_index(struct spa_ringbuffer *rbuf,
* \param data destination memory * \param data destination memory
* \param len number of bytes to read * \param len number of bytes to read
*/ */
SPA_API_IMPL void SPA_API_RINGBUFFER void
spa_ringbuffer_read_data(struct spa_ringbuffer *rbuf SPA_UNUSED, spa_ringbuffer_read_data(struct spa_ringbuffer *rbuf SPA_UNUSED,
const void *buffer, uint32_t size, const void *buffer, uint32_t size,
uint32_t offset, void *data, uint32_t len) uint32_t offset, void *data, uint32_t len)
@ -101,7 +109,7 @@ spa_ringbuffer_read_data(struct spa_ringbuffer *rbuf SPA_UNUSED,
* \param rbuf a spa_ringbuffer * \param rbuf a spa_ringbuffer
* \param index new index * \param index new index
*/ */
SPA_API_IMPL void spa_ringbuffer_read_update(struct spa_ringbuffer *rbuf, int32_t index) SPA_API_RINGBUFFER void spa_ringbuffer_read_update(struct spa_ringbuffer *rbuf, int32_t index)
{ {
__atomic_store_n(&rbuf->readindex, index, __ATOMIC_RELEASE); __atomic_store_n(&rbuf->readindex, index, __ATOMIC_RELEASE);
} }
@ -117,7 +125,7 @@ SPA_API_IMPL void spa_ringbuffer_read_update(struct spa_ringbuffer *rbuf, int32_
* was an overrun. Subtract from the buffer size to get * was an overrun. Subtract from the buffer size to get
* the number of bytes available for writing. * the number of bytes available for writing.
*/ */
SPA_API_IMPL int32_t spa_ringbuffer_get_write_index(struct spa_ringbuffer *rbuf, uint32_t *index) SPA_API_RINGBUFFER int32_t spa_ringbuffer_get_write_index(struct spa_ringbuffer *rbuf, uint32_t *index)
{ {
*index = __atomic_load_n(&rbuf->writeindex, __ATOMIC_RELAXED); *index = __atomic_load_n(&rbuf->writeindex, __ATOMIC_RELAXED);
return (int32_t) (*index - __atomic_load_n(&rbuf->readindex, __ATOMIC_ACQUIRE)); return (int32_t) (*index - __atomic_load_n(&rbuf->readindex, __ATOMIC_ACQUIRE));
@ -134,7 +142,7 @@ SPA_API_IMPL int32_t spa_ringbuffer_get_write_index(struct spa_ringbuffer *rbuf,
* \param data source memory * \param data source memory
* \param len number of bytes to write * \param len number of bytes to write
*/ */
SPA_API_IMPL void SPA_API_RINGBUFFER void
spa_ringbuffer_write_data(struct spa_ringbuffer *rbuf SPA_UNUSED, spa_ringbuffer_write_data(struct spa_ringbuffer *rbuf SPA_UNUSED,
void *buffer, uint32_t size, void *buffer, uint32_t size,
uint32_t offset, const void *data, uint32_t len) uint32_t offset, const void *data, uint32_t len)
@ -151,7 +159,7 @@ spa_ringbuffer_write_data(struct spa_ringbuffer *rbuf SPA_UNUSED,
* \param rbuf a spa_ringbuffer * \param rbuf a spa_ringbuffer
* \param index new index * \param index new index
*/ */
SPA_API_IMPL void spa_ringbuffer_write_update(struct spa_ringbuffer *rbuf, int32_t index) SPA_API_RINGBUFFER void spa_ringbuffer_write_update(struct spa_ringbuffer *rbuf, int32_t index)
{ {
__atomic_store_n(&rbuf->writeindex, index, __ATOMIC_RELEASE); __atomic_store_n(&rbuf->writeindex, index, __ATOMIC_RELEASE);
} }

View file

@ -17,6 +17,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#ifndef SPA_API_STRING
#ifdef SPA_API_IMPL
#define SPA_API_STRING SPA_API_IMPL
#else
#define SPA_API_STRING static inline
#endif
#endif
/** /**
* \defgroup spa_string String handling * \defgroup spa_string String handling
* String handling utilities * String handling utilities
@ -33,7 +41,7 @@ extern "C" {
* If both \a a and \a b are NULL, the two are considered equal. * If both \a a and \a b are NULL, the two are considered equal.
* *
*/ */
SPA_API_IMPL bool spa_streq(const char *s1, const char *s2) SPA_API_STRING bool spa_streq(const char *s1, const char *s2)
{ {
return SPA_LIKELY(s1 && s2) ? strcmp(s1, s2) == 0 : s1 == s2; return SPA_LIKELY(s1 && s2) ? strcmp(s1, s2) == 0 : s1 == s2;
} }
@ -43,7 +51,7 @@ SPA_API_IMPL bool spa_streq(const char *s1, const char *s2)
* *
* If both \a a and \a b are NULL, the two are considered equal. * If both \a a and \a b are NULL, the two are considered equal.
*/ */
SPA_API_IMPL bool spa_strneq(const char *s1, const char *s2, size_t len) SPA_API_STRING bool spa_strneq(const char *s1, const char *s2, size_t len)
{ {
return SPA_LIKELY(s1 && s2) ? strncmp(s1, s2, len) == 0 : s1 == s2; return SPA_LIKELY(s1 && s2) ? strncmp(s1, s2, len) == 0 : s1 == s2;
} }
@ -54,7 +62,7 @@ SPA_API_IMPL bool spa_strneq(const char *s1, const char *s2, size_t len)
* A \a s is NULL, it never starts with the given \a prefix. A \a prefix of * A \a s is NULL, it never starts with the given \a prefix. A \a prefix of
* NULL is a bug in the caller. * NULL is a bug in the caller.
*/ */
SPA_API_IMPL bool spa_strstartswith(const char *s, const char *prefix) SPA_API_STRING bool spa_strstartswith(const char *s, const char *prefix)
{ {
if (SPA_UNLIKELY(s == NULL)) if (SPA_UNLIKELY(s == NULL))
return false; return false;
@ -70,7 +78,7 @@ SPA_API_IMPL bool spa_strstartswith(const char *s, const char *prefix)
* A \a s is NULL, it never ends with the given \a suffix. A \a suffix of * A \a s is NULL, it never ends with the given \a suffix. A \a suffix of
* NULL is a bug in the caller. * NULL is a bug in the caller.
*/ */
SPA_API_IMPL bool spa_strendswith(const char *s, const char *suffix) SPA_API_STRING bool spa_strendswith(const char *s, const char *suffix)
{ {
size_t l1, l2; size_t l1, l2;
@ -92,7 +100,7 @@ SPA_API_IMPL bool spa_strendswith(const char *s, const char *suffix)
* *
* \return true on success, false otherwise * \return true on success, false otherwise
*/ */
SPA_API_IMPL bool spa_atoi32(const char *str, int32_t *val, int base) SPA_API_STRING bool spa_atoi32(const char *str, int32_t *val, int base)
{ {
char *endptr; char *endptr;
long v; long v;
@ -120,7 +128,7 @@ SPA_API_IMPL bool spa_atoi32(const char *str, int32_t *val, int base)
* *
* \return true on success, false otherwise * \return true on success, false otherwise
*/ */
SPA_API_IMPL bool spa_atou32(const char *str, uint32_t *val, int base) SPA_API_STRING bool spa_atou32(const char *str, uint32_t *val, int base)
{ {
char *endptr; char *endptr;
unsigned long long v; unsigned long long v;
@ -148,7 +156,7 @@ SPA_API_IMPL bool spa_atou32(const char *str, uint32_t *val, int base)
* *
* \return true on success, false otherwise * \return true on success, false otherwise
*/ */
SPA_API_IMPL bool spa_atoi64(const char *str, int64_t *val, int base) SPA_API_STRING bool spa_atoi64(const char *str, int64_t *val, int base)
{ {
char *endptr; char *endptr;
long long v; long long v;
@ -173,7 +181,7 @@ SPA_API_IMPL bool spa_atoi64(const char *str, int64_t *val, int base)
* *
* \return true on success, false otherwise * \return true on success, false otherwise
*/ */
SPA_API_IMPL bool spa_atou64(const char *str, uint64_t *val, int base) SPA_API_STRING bool spa_atou64(const char *str, uint64_t *val, int base)
{ {
char *endptr; char *endptr;
unsigned long long v; unsigned long long v;
@ -196,7 +204,7 @@ SPA_API_IMPL bool spa_atou64(const char *str, uint64_t *val, int base)
* *
* \return true on success, false otherwise * \return true on success, false otherwise
*/ */
SPA_API_IMPL bool spa_atob(const char *str) SPA_API_STRING bool spa_atob(const char *str)
{ {
return spa_streq(str, "true") || spa_streq(str, "1"); return spa_streq(str, "true") || spa_streq(str, "1");
} }
@ -210,7 +218,7 @@ SPA_API_IMPL bool spa_atob(const char *str)
* number on error. * number on error.
*/ */
SPA_PRINTF_FUNC(3, 0) SPA_PRINTF_FUNC(3, 0)
SPA_API_IMPL int spa_vscnprintf(char *buffer, size_t size, const char *format, va_list args) SPA_API_STRING int spa_vscnprintf(char *buffer, size_t size, const char *format, va_list args)
{ {
int r; int r;
@ -233,7 +241,7 @@ SPA_API_IMPL int spa_vscnprintf(char *buffer, size_t size, const char *format, v
* number on error. * number on error.
*/ */
SPA_PRINTF_FUNC(3, 4) SPA_PRINTF_FUNC(3, 4)
SPA_API_IMPL int spa_scnprintf(char *buffer, size_t size, const char *format, ...) SPA_API_STRING int spa_scnprintf(char *buffer, size_t size, const char *format, ...)
{ {
int r; int r;
va_list args; va_list args;
@ -253,7 +261,7 @@ SPA_API_IMPL int spa_scnprintf(char *buffer, size_t size, const char *format, ..
* *
* \return the result float. * \return the result float.
*/ */
SPA_API_IMPL float spa_strtof(const char *str, char **endptr) SPA_API_STRING float spa_strtof(const char *str, char **endptr)
{ {
#ifndef __LOCALE_C_ONLY #ifndef __LOCALE_C_ONLY
static locale_t locale = NULL; static locale_t locale = NULL;
@ -279,7 +287,7 @@ SPA_API_IMPL float spa_strtof(const char *str, char **endptr)
* *
* \return true on success, false otherwise * \return true on success, false otherwise
*/ */
SPA_API_IMPL bool spa_atof(const char *str, float *val) SPA_API_STRING bool spa_atof(const char *str, float *val)
{ {
char *endptr; char *endptr;
float v; float v;
@ -303,7 +311,7 @@ SPA_API_IMPL bool spa_atof(const char *str, float *val)
* *
* \return the result float. * \return the result float.
*/ */
SPA_API_IMPL double spa_strtod(const char *str, char **endptr) SPA_API_STRING double spa_strtod(const char *str, char **endptr)
{ {
#ifndef __LOCALE_C_ONLY #ifndef __LOCALE_C_ONLY
static locale_t locale = NULL; static locale_t locale = NULL;
@ -329,7 +337,7 @@ SPA_API_IMPL double spa_strtod(const char *str, char **endptr)
* *
* \return true on success, false otherwise * \return true on success, false otherwise
*/ */
SPA_API_IMPL bool spa_atod(const char *str, double *val) SPA_API_STRING bool spa_atod(const char *str, double *val)
{ {
char *endptr; char *endptr;
double v; double v;
@ -346,7 +354,7 @@ SPA_API_IMPL bool spa_atod(const char *str, double *val)
return true; return true;
} }
SPA_API_IMPL char *spa_dtoa(char *str, size_t size, double val) SPA_API_STRING char *spa_dtoa(char *str, size_t size, double val)
{ {
int i, l; int i, l;
l = spa_scnprintf(str, size, "%f", val); l = spa_scnprintf(str, size, "%f", val);
@ -362,7 +370,7 @@ struct spa_strbuf {
size_t pos; size_t pos;
}; };
SPA_API_IMPL void spa_strbuf_init(struct spa_strbuf *buf, char *buffer, size_t maxsize) SPA_API_STRING void spa_strbuf_init(struct spa_strbuf *buf, char *buffer, size_t maxsize)
{ {
buf->buffer = buffer; buf->buffer = buffer;
buf->maxsize = maxsize; buf->maxsize = maxsize;
@ -372,7 +380,7 @@ SPA_API_IMPL void spa_strbuf_init(struct spa_strbuf *buf, char *buffer, size_t m
} }
SPA_PRINTF_FUNC(2, 3) SPA_PRINTF_FUNC(2, 3)
SPA_API_IMPL int spa_strbuf_append(struct spa_strbuf *buf, const char *fmt, ...) SPA_API_STRING int spa_strbuf_append(struct spa_strbuf *buf, const char *fmt, ...)
{ {
size_t remain = buf->maxsize - buf->pos; size_t remain = buf->maxsize - buf->pos;
ssize_t written; ssize_t written;

View file

@ -12,6 +12,14 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#include <spa/utils/string.h> #include <spa/utils/string.h>
#ifndef SPA_API_TYPE
#ifdef SPA_API_IMPL
#define SPA_API_TYPE SPA_API_IMPL
#else
#define SPA_API_TYPE static inline
#endif
#endif
/** \defgroup spa_types Types /** \defgroup spa_types Types
* Data type information enumerations * Data type information enumerations
*/ */
@ -124,12 +132,12 @@ struct spa_type_info {
const struct spa_type_info *values; const struct spa_type_info *values;
}; };
SPA_API_IMPL bool spa_type_is_a(const char *type, const char *parent) SPA_API_TYPE bool spa_type_is_a(const char *type, const char *parent)
{ {
return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0; return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0;
} }
SPA_API_IMPL const char *spa_type_short_name(const char *name) SPA_API_TYPE const char *spa_type_short_name(const char *name)
{ {
const char *h; const char *h;
if ((h = strrchr(name, ':')) != NULL) if ((h = strrchr(name, ':')) != NULL)
@ -137,7 +145,7 @@ SPA_API_IMPL const char *spa_type_short_name(const char *name)
return name; return name;
} }
SPA_API_IMPL uint32_t spa_type_from_short_name(const char *name, SPA_API_TYPE uint32_t spa_type_from_short_name(const char *name,
const struct spa_type_info *info, uint32_t unknown) const struct spa_type_info *info, uint32_t unknown)
{ {
int i; int i;
@ -147,7 +155,7 @@ SPA_API_IMPL uint32_t spa_type_from_short_name(const char *name,
} }
return unknown; return unknown;
} }
SPA_API_IMPL const char * spa_type_to_name(uint32_t type, SPA_API_TYPE const char * spa_type_to_name(uint32_t type,
const struct spa_type_info *info, const char *unknown) const struct spa_type_info *info, const char *unknown)
{ {
int i; int i;
@ -158,7 +166,7 @@ SPA_API_IMPL const char * spa_type_to_name(uint32_t type,
return unknown; return unknown;
} }
SPA_API_IMPL const char * spa_type_to_short_name(uint32_t type, SPA_API_TYPE const char * spa_type_to_short_name(uint32_t type,
const struct spa_type_info *info, const char *unknown) const struct spa_type_info *info, const char *unknown)
{ {
const char *n = spa_type_to_name(type, info, unknown); const char *n = spa_type_to_name(type, info, unknown);

View file

@ -18,6 +18,7 @@
#include <spa/utils/ringbuffer.h> #include <spa/utils/ringbuffer.h>
#include <spa/param/profiler.h> #include <spa/param/profiler.h>
#define PW_API_PROFILER SPA_EXPORT
#include <pipewire/private.h> #include <pipewire/private.h>
#include <pipewire/impl.h> #include <pipewire/impl.h>
#include <pipewire/extensions/profiler.h> #include <pipewire/extensions/profiler.h>

View file

@ -6,6 +6,8 @@
#include <pipewire/pipewire.h> #include <pipewire/pipewire.h>
#include <pipewire/impl.h> #include <pipewire/impl.h>
#include <pipewire/private.h> #include <pipewire/private.h>
#define PW_API_SECURITY_CONTEXT SPA_EXPORT
#include <pipewire/extensions/security-context.h> #include <pipewire/extensions/security-context.h>
PW_LOG_TOPIC_EXTERN(mod_topic); PW_LOG_TOPIC_EXTERN(mod_topic);

View file

@ -13,6 +13,11 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#ifndef PW_API_ARRAY
#define PW_API_ARRAY static inline
#endif
/** \defgroup pw_array Array /** \defgroup pw_array Array
* *
* \brief An array object * \brief An array object
@ -71,7 +76,7 @@ struct pw_array {
/** Initialize the array with given extend. Extend needs to be > 0 or else /** Initialize the array with given extend. Extend needs to be > 0 or else
* the array will not be able to expand. */ * the array will not be able to expand. */
SPA_API_IMPL void pw_array_init(struct pw_array *arr, size_t extend) PW_API_ARRAY void pw_array_init(struct pw_array *arr, size_t extend)
{ {
arr->data = NULL; arr->data = NULL;
arr->size = arr->alloc = 0; arr->size = arr->alloc = 0;
@ -79,7 +84,7 @@ SPA_API_IMPL void pw_array_init(struct pw_array *arr, size_t extend)
} }
/** Clear the array. This should be called when pw_array_init() was called. */ /** Clear the array. This should be called when pw_array_init() was called. */
SPA_API_IMPL void pw_array_clear(struct pw_array *arr) PW_API_ARRAY void pw_array_clear(struct pw_array *arr)
{ {
if (arr->extend > 0) if (arr->extend > 0)
free(arr->data); free(arr->data);
@ -87,7 +92,7 @@ SPA_API_IMPL void pw_array_clear(struct pw_array *arr)
} }
/** Initialize a static array. */ /** Initialize a static array. */
SPA_API_IMPL void pw_array_init_static(struct pw_array *arr, void *data, size_t size) PW_API_ARRAY void pw_array_init_static(struct pw_array *arr, void *data, size_t size)
{ {
arr->data = data; arr->data = data;
arr->alloc = size; arr->alloc = size;
@ -95,13 +100,13 @@ SPA_API_IMPL void pw_array_init_static(struct pw_array *arr, void *data, size_t
} }
/** Reset the array */ /** Reset the array */
SPA_API_IMPL void pw_array_reset(struct pw_array *arr) PW_API_ARRAY void pw_array_reset(struct pw_array *arr)
{ {
arr->size = 0; arr->size = 0;
} }
/** Make sure \a size bytes can be added to the array */ /** Make sure \a size bytes can be added to the array */
SPA_API_IMPL int pw_array_ensure_size(struct pw_array *arr, size_t size) PW_API_ARRAY int pw_array_ensure_size(struct pw_array *arr, size_t size)
{ {
size_t alloc, need; size_t alloc, need;
@ -124,7 +129,7 @@ SPA_API_IMPL int pw_array_ensure_size(struct pw_array *arr, size_t size)
/** Add \a ref size bytes to \a arr. A pointer to memory that can /** Add \a ref size bytes to \a arr. A pointer to memory that can
* hold at least \a size bytes is returned or NULL when an error occurred * hold at least \a size bytes is returned or NULL when an error occurred
* and errno will be set.*/ * and errno will be set.*/
SPA_API_IMPL void *pw_array_add(struct pw_array *arr, size_t size) PW_API_ARRAY void *pw_array_add(struct pw_array *arr, size_t size)
{ {
void *p; void *p;
@ -139,7 +144,7 @@ SPA_API_IMPL void *pw_array_add(struct pw_array *arr, size_t size)
/** Add a pointer to array. Returns 0 on success and a negative errno style /** Add a pointer to array. Returns 0 on success and a negative errno style
* error on failure. */ * error on failure. */
SPA_API_IMPL int pw_array_add_ptr(struct pw_array *arr, void *ptr) PW_API_ARRAY int pw_array_add_ptr(struct pw_array *arr, void *ptr)
{ {
void **p = (void **)pw_array_add(arr, sizeof(void*)); void **p = (void **)pw_array_add(arr, sizeof(void*));
if (p == NULL) if (p == NULL)

View file

@ -24,6 +24,10 @@ extern "C" {
#define PW_VERSION_PROFILER 3 #define PW_VERSION_PROFILER 3
struct pw_profiler; struct pw_profiler;
#ifndef PW_API_PROFILER
#define PW_API_PROFILER static inline
#endif
#define PW_EXTENSION_MODULE_PROFILER PIPEWIRE_MODULE_PREFIX "module-profiler" #define PW_EXTENSION_MODULE_PROFILER PIPEWIRE_MODULE_PREFIX "module-profiler"
#define PW_PROFILER_PERM_MASK PW_PERM_R #define PW_PROFILER_PERM_MASK PW_PERM_R
@ -53,7 +57,7 @@ struct pw_profiler_methods {
void *data); void *data);
}; };
SPA_API_IMPL int pw_profiler_add_listener(struct pw_profiler *object, PW_API_PROFILER int pw_profiler_add_listener(struct pw_profiler *object,
struct spa_hook *listener, struct spa_hook *listener,
const struct pw_profiler_events *events, const struct pw_profiler_events *events,
void *data) void *data)

View file

@ -26,6 +26,10 @@ extern "C" {
#define PW_VERSION_SECURITY_CONTEXT 3 #define PW_VERSION_SECURITY_CONTEXT 3
struct pw_security_context; struct pw_security_context;
#ifndef PW_API_SECURITY_CONTEXT
#define PW_API_SECURITY_CONTEXT static inline
#endif
#define PW_EXTENSION_MODULE_SECURITY_CONTEXT PIPEWIRE_MODULE_PREFIX "module-security-context" #define PW_EXTENSION_MODULE_SECURITY_CONTEXT PIPEWIRE_MODULE_PREFIX "module-security-context"
#define PW_SECURITY_CONTEXT_EVENT_NUM 0 #define PW_SECURITY_CONTEXT_EVENT_NUM 0
@ -94,7 +98,7 @@ struct pw_security_context_methods {
const struct spa_dict *props); const struct spa_dict *props);
}; };
SPA_API_IMPL int pw_security_context_add_listener(struct pw_security_context *object, PW_API_SECURITY_CONTEXT int pw_security_context_add_listener(struct pw_security_context *object,
struct spa_hook *listener, struct spa_hook *listener,
const struct pw_security_context_events *events, const struct pw_security_context_events *events,
void *data) void *data)
@ -104,7 +108,7 @@ SPA_API_IMPL int pw_security_context_add_listener(struct pw_security_context *ob
listener, events, data); listener, events, data);
} }
SPA_API_IMPL int pw_security_context_create(struct pw_security_context *object, PW_API_SECURITY_CONTEXT int pw_security_context_create(struct pw_security_context *object,
int listen_fd, int close_fd, const struct spa_dict *props) int listen_fd, int close_fd, const struct spa_dict *props)
{ {
return spa_api_method_r(int, -ENOTSUP, return spa_api_method_r(int, -ENOTSUP,

View file

@ -15,6 +15,10 @@ extern "C" {
#include <spa/utils/defs.h> #include <spa/utils/defs.h>
#include <pipewire/array.h> #include <pipewire/array.h>
#ifndef PW_API_MAP
#define PW_API_MAP static inline
#endif
/** \defgroup pw_map Map /** \defgroup pw_map Map
* *
* \brief A map that holds pointers to objects indexed by id * \brief A map that holds pointers to objects indexed by id
@ -93,7 +97,7 @@ struct pw_map {
* \param size the initial size of the map * \param size the initial size of the map
* \param extend the amount to bytes to grow the map with when needed * \param extend the amount to bytes to grow the map with when needed
*/ */
SPA_API_IMPL void pw_map_init(struct pw_map *map, size_t size, size_t extend) PW_API_MAP void pw_map_init(struct pw_map *map, size_t size, size_t extend)
{ {
pw_array_init(&map->items, extend * sizeof(union pw_map_item)); pw_array_init(&map->items, extend * sizeof(union pw_map_item));
pw_array_ensure_size(&map->items, size * sizeof(union pw_map_item)); pw_array_ensure_size(&map->items, size * sizeof(union pw_map_item));
@ -103,7 +107,7 @@ SPA_API_IMPL void pw_map_init(struct pw_map *map, size_t size, size_t extend)
/** Clear a map and free the data storage. All previously returned ids /** Clear a map and free the data storage. All previously returned ids
* must be treated as invalid. * must be treated as invalid.
*/ */
SPA_API_IMPL void pw_map_clear(struct pw_map *map) PW_API_MAP void pw_map_clear(struct pw_map *map)
{ {
pw_array_clear(&map->items); pw_array_clear(&map->items);
} }
@ -111,7 +115,7 @@ SPA_API_IMPL void pw_map_clear(struct pw_map *map)
/** Reset a map but keep previously allocated storage. All previously /** Reset a map but keep previously allocated storage. All previously
* returned ids must be treated as invalid. * returned ids must be treated as invalid.
*/ */
SPA_API_IMPL void pw_map_reset(struct pw_map *map) PW_API_MAP void pw_map_reset(struct pw_map *map)
{ {
pw_array_reset(&map->items); pw_array_reset(&map->items);
map->free_list = SPA_ID_INVALID; map->free_list = SPA_ID_INVALID;
@ -123,7 +127,7 @@ SPA_API_IMPL void pw_map_reset(struct pw_map *map)
* \return the id where the item was inserted or SPA_ID_INVALID when the * \return the id where the item was inserted or SPA_ID_INVALID when the
* item can not be inserted. * item can not be inserted.
*/ */
SPA_API_IMPL uint32_t pw_map_insert_new(struct pw_map *map, void *data) PW_API_MAP uint32_t pw_map_insert_new(struct pw_map *map, void *data)
{ {
union pw_map_item *start, *item; union pw_map_item *start, *item;
uint32_t id; uint32_t id;
@ -150,7 +154,7 @@ SPA_API_IMPL uint32_t pw_map_insert_new(struct pw_map *map, void *data)
* \param data the data to insert * \param data the data to insert
* \return 0 on success, -ENOSPC value when the index is invalid or a negative errno * \return 0 on success, -ENOSPC value when the index is invalid or a negative errno
*/ */
SPA_API_IMPL int pw_map_insert_at(struct pw_map *map, uint32_t id, void *data) PW_API_MAP int pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)
{ {
size_t size = pw_map_get_size(map); size_t size = pw_map_get_size(map);
union pw_map_item *item; union pw_map_item *item;
@ -175,7 +179,7 @@ SPA_API_IMPL int pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)
* \param map the map to remove from * \param map the map to remove from
* \param id the index to remove * \param id the index to remove
*/ */
SPA_API_IMPL void pw_map_remove(struct pw_map *map, uint32_t id) PW_API_MAP void pw_map_remove(struct pw_map *map, uint32_t id)
{ {
if (pw_map_id_is_free(map, id)) if (pw_map_id_is_free(map, id))
return; return;
@ -189,7 +193,7 @@ SPA_API_IMPL void pw_map_remove(struct pw_map *map, uint32_t id)
* \param id the index to look at * \param id the index to look at
* \return the item at \a id or NULL when no such item exists * \return the item at \a id or NULL when no such item exists
*/ */
SPA_API_IMPL void *pw_map_lookup(const struct pw_map *map, uint32_t id) PW_API_MAP void *pw_map_lookup(const struct pw_map *map, uint32_t id)
{ {
if (SPA_LIKELY(pw_map_check_id(map, id))) { if (SPA_LIKELY(pw_map_check_id(map, id))) {
union pw_map_item *item = pw_map_get_item(map, id); union pw_map_item *item = pw_map_get_item(map, id);
@ -207,7 +211,7 @@ SPA_API_IMPL void *pw_map_lookup(const struct pw_map *map, uint32_t id)
* \param data data to pass to \a func * \param data data to pass to \a func
* \return the result of the last call to \a func or 0 when all callbacks returned 0. * \return the result of the last call to \a func or 0 when all callbacks returned 0.
*/ */
SPA_API_IMPL int pw_map_for_each(const struct pw_map *map, PW_API_MAP int pw_map_for_each(const struct pw_map *map,
int (*func) (void *item_data, void *data), void *data) int (*func) (void *item_data, void *data), void *data)
{ {
union pw_map_item *item; union pw_map_item *item;

View file

@ -18,6 +18,7 @@
#include <spa/utils/list.h> #include <spa/utils/list.h>
#include <spa/buffer/buffer.h> #include <spa/buffer/buffer.h>
#define PW_API_MEM SPA_EXPORT
#include <pipewire/log.h> #include <pipewire/log.h>
#include <pipewire/map.h> #include <pipewire/map.h>
#include <pipewire/mem.h> #include <pipewire/mem.h>

View file

@ -11,6 +11,10 @@
extern "C" { extern "C" {
#endif #endif
#ifndef PW_API_MEM
#define PW_API_MEM static inline
#endif
/** \defgroup pw_memblock Memory Blocks /** \defgroup pw_memblock Memory Blocks
* Memory allocation and pools. * Memory allocation and pools.
*/ */
@ -123,7 +127,7 @@ struct pw_memblock * pw_mempool_import(struct pw_mempool *pool,
void pw_memblock_free(struct pw_memblock *mem); void pw_memblock_free(struct pw_memblock *mem);
/** Unref a memblock */ /** Unref a memblock */
SPA_API_IMPL void pw_memblock_unref(struct pw_memblock *mem) PW_API_MEM void pw_memblock_unref(struct pw_memblock *mem)
{ {
if (--mem->ref == 0) if (--mem->ref == 0)
pw_memblock_free(mem); pw_memblock_free(mem);
@ -173,7 +177,7 @@ struct pw_map_range {
/** Calculate parameters to mmap() memory into \a range so that /** Calculate parameters to mmap() memory into \a range so that
* \a size bytes at \a offset can be mapped with mmap(). */ * \a size bytes at \a offset can be mapped with mmap(). */
SPA_API_IMPL void pw_map_range_init(struct pw_map_range *range, PW_API_MEM void pw_map_range_init(struct pw_map_range *range,
uint32_t offset, uint32_t size, uint32_t offset, uint32_t size,
uint32_t page_size) uint32_t page_size)
{ {

View file

@ -12,6 +12,7 @@
#include <spa/utils/result.h> #include <spa/utils/result.h>
#include <spa/debug/log.h> #include <spa/debug/log.h>
#define PW_API_PROPERTIES SPA_EXPORT
#include "pipewire/array.h" #include "pipewire/array.h"
#include "pipewire/log.h" #include "pipewire/log.h"
#include "pipewire/utils.h" #include "pipewire/utils.h"

View file

@ -15,6 +15,10 @@ extern "C" {
#include <spa/utils/dict.h> #include <spa/utils/dict.h>
#include <spa/utils/string.h> #include <spa/utils/string.h>
#ifndef PW_API_PROPERTIES
#define PW_API_PROPERTIES static inline
#endif
/** \defgroup pw_properties Properties /** \defgroup pw_properties Properties
* *
* Properties are used to pass around arbitrary key/value pairs. * Properties are used to pass around arbitrary key/value pairs.
@ -101,7 +105,7 @@ pw_properties_fetch_int64(const struct pw_properties *properties, const char *ke
int int
pw_properties_fetch_bool(const struct pw_properties *properties, const char *key, bool *value); pw_properties_fetch_bool(const struct pw_properties *properties, const char *key, bool *value);
SPA_API_IMPL uint32_t PW_API_PROPERTIES uint32_t
pw_properties_get_uint32(const struct pw_properties *properties, const char *key, uint32_t deflt) pw_properties_get_uint32(const struct pw_properties *properties, const char *key, uint32_t deflt)
{ {
uint32_t val = deflt; uint32_t val = deflt;
@ -109,7 +113,7 @@ pw_properties_get_uint32(const struct pw_properties *properties, const char *key
return val; return val;
} }
SPA_API_IMPL int32_t PW_API_PROPERTIES int32_t
pw_properties_get_int32(const struct pw_properties *properties, const char *key, int32_t deflt) pw_properties_get_int32(const struct pw_properties *properties, const char *key, int32_t deflt)
{ {
int32_t val = deflt; int32_t val = deflt;
@ -117,7 +121,7 @@ pw_properties_get_int32(const struct pw_properties *properties, const char *key,
return val; return val;
} }
SPA_API_IMPL uint64_t PW_API_PROPERTIES uint64_t
pw_properties_get_uint64(const struct pw_properties *properties, const char *key, uint64_t deflt) pw_properties_get_uint64(const struct pw_properties *properties, const char *key, uint64_t deflt)
{ {
uint64_t val = deflt; uint64_t val = deflt;
@ -125,7 +129,7 @@ pw_properties_get_uint64(const struct pw_properties *properties, const char *key
return val; return val;
} }
SPA_API_IMPL int64_t PW_API_PROPERTIES int64_t
pw_properties_get_int64(const struct pw_properties *properties, const char *key, int64_t deflt) pw_properties_get_int64(const struct pw_properties *properties, const char *key, int64_t deflt)
{ {
int64_t val = deflt; int64_t val = deflt;
@ -134,7 +138,7 @@ pw_properties_get_int64(const struct pw_properties *properties, const char *key,
} }
SPA_API_IMPL bool PW_API_PROPERTIES bool
pw_properties_get_bool(const struct pw_properties *properties, const char *key, bool deflt) pw_properties_get_bool(const struct pw_properties *properties, const char *key, bool deflt)
{ {
bool val = deflt; bool val = deflt;
@ -152,31 +156,31 @@ pw_properties_iterate(const struct pw_properties *properties, void **state);
#define PW_PROPERTIES_FLAG_COLORS (1<<4) #define PW_PROPERTIES_FLAG_COLORS (1<<4)
int pw_properties_serialize_dict(FILE *f, const struct spa_dict *dict, uint32_t flags); int pw_properties_serialize_dict(FILE *f, const struct spa_dict *dict, uint32_t flags);
SPA_API_IMPL bool pw_properties_parse_bool(const char *value) { PW_API_PROPERTIES bool pw_properties_parse_bool(const char *value) {
return spa_atob(value); return spa_atob(value);
} }
SPA_API_IMPL int pw_properties_parse_int(const char *value) { PW_API_PROPERTIES int pw_properties_parse_int(const char *value) {
int v; int v;
return spa_atoi32(value, &v, 0) ? v: 0; return spa_atoi32(value, &v, 0) ? v: 0;
} }
SPA_API_IMPL int64_t pw_properties_parse_int64(const char *value) { PW_API_PROPERTIES int64_t pw_properties_parse_int64(const char *value) {
int64_t v; int64_t v;
return spa_atoi64(value, &v, 0) ? v : 0; return spa_atoi64(value, &v, 0) ? v : 0;
} }
SPA_API_IMPL uint64_t pw_properties_parse_uint64(const char *value) { PW_API_PROPERTIES uint64_t pw_properties_parse_uint64(const char *value) {
uint64_t v; uint64_t v;
return spa_atou64(value, &v, 0) ? v : 0; return spa_atou64(value, &v, 0) ? v : 0;
} }
SPA_API_IMPL float pw_properties_parse_float(const char *value) { PW_API_PROPERTIES float pw_properties_parse_float(const char *value) {
float v; float v;
return spa_atof(value, &v) ? v : 0.0f; return spa_atof(value, &v) ? v : 0.0f;
} }
SPA_API_IMPL double pw_properties_parse_double(const char *value) { PW_API_PROPERTIES double pw_properties_parse_double(const char *value) {
double v; double v;
return spa_atod(value, &v) ? v : 0.0; return spa_atod(value, &v) ? v : 0.0;
} }