mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-16 07:00:00 -05:00
add per type API defines
This commit is contained in:
parent
b03f2f7afa
commit
31802d4994
85 changed files with 1137 additions and 509 deletions
|
|
@ -259,6 +259,15 @@ struct spa_fraction {
|
|||
#define SPA_API_IMPL static inline
|
||||
#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
|
||||
#define SPA_RESTRICT restrict
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
|
|
@ -305,7 +314,7 @@ struct spa_fraction {
|
|||
#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)
|
||||
{
|
||||
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,
|
||||
size_t *remaining)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,6 +13,14 @@ extern "C" {
|
|||
|
||||
#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
|
||||
* Dictionary data structure
|
||||
|
|
@ -50,14 +58,14 @@ struct spa_dict {
|
|||
(item) < &(dict)->items[(dict)->n_items]; \
|
||||
(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,
|
||||
*it2 = (const struct spa_dict_item *)i2;
|
||||
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)
|
||||
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_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 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;
|
||||
}
|
||||
|
||||
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);
|
||||
return item ? item->value : NULL;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,14 @@ extern "C" {
|
|||
|
||||
#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_MIN 0.016
|
||||
|
||||
|
|
@ -23,13 +31,13 @@ struct spa_dll {
|
|||
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->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;
|
||||
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;
|
||||
}
|
||||
|
||||
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->z2 += dll->w0 * (dll->z1 - dll->z2);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,14 @@ extern "C" {
|
|||
#include <spa/utils/defs.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
|
||||
*
|
||||
* \brief Generic implementation of implementation-independent interfaces
|
||||
|
|
@ -411,18 +419,18 @@ struct spa_hook {
|
|||
};
|
||||
|
||||
/** 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_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);
|
||||
}
|
||||
|
||||
/** 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,
|
||||
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 */
|
||||
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,
|
||||
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 */
|
||||
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))
|
||||
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 */
|
||||
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;
|
||||
spa_list_consume(h, &list->list, link)
|
||||
spa_hook_remove(h);
|
||||
}
|
||||
|
||||
SPA_API_IMPL void
|
||||
SPA_API_HOOK void
|
||||
spa_hook_list_isolate(struct spa_hook_list *list,
|
||||
struct spa_hook_list *save,
|
||||
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_API_IMPL void
|
||||
SPA_API_HOOK void
|
||||
spa_hook_list_join(struct spa_hook_list *list,
|
||||
struct spa_hook_list *save)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,6 +20,14 @@ extern "C" {
|
|||
#include <spa/utils/defs.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
|
||||
* 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 })
|
||||
|
||||
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);
|
||||
}
|
||||
#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);
|
||||
}
|
||||
|
|
@ -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
|
||||
* 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;
|
||||
enum {
|
||||
|
|
@ -312,7 +320,7 @@ error:
|
|||
*
|
||||
* \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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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 == '[');
|
||||
}
|
||||
|
||||
/* 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 == '{';
|
||||
}
|
||||
|
||||
/* 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 == '[';
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* 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 *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;
|
||||
}
|
||||
|
||||
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;
|
||||
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 (isinf(val))
|
||||
|
|
@ -423,7 +431,7 @@ SPA_API_IMPL char *spa_json_format_float(char *str, int size, float val)
|
|||
}
|
||||
|
||||
/* 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 *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);
|
||||
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;
|
||||
return spa_json_parse_int(val, len, &dummy);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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)))
|
||||
return 1;
|
||||
|
|
@ -469,12 +477,12 @@ SPA_API_IMPL int spa_json_parse_bool(const char *val, int len, bool *result)
|
|||
}
|
||||
|
||||
/* 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 == '"';
|
||||
}
|
||||
|
||||
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;
|
||||
*res = 0;
|
||||
|
|
@ -493,7 +501,7 @@ SPA_API_IMPL int spa_json_parse_hex(const char *p, int num, uint32_t *res)
|
|||
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;
|
||||
if (maxlen <= len)
|
||||
|
|
@ -556,12 +564,12 @@ SPA_API_IMPL int spa_json_parse_stringn(const char *val, int len, char *result,
|
|||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
static const char hex[] = { "0123456789abcdef" };
|
||||
|
|
|
|||
|
|
@ -15,6 +15,14 @@ extern "C" {
|
|||
#include <spa/pod/builder.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
|
||||
* 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 *ti;
|
||||
|
|
@ -135,7 +143,7 @@ SPA_API_IMPL int spa_json_to_pod_part(struct spa_pod_builder *b, uint32_t flags,
|
|||
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,
|
||||
struct spa_error_location *loc)
|
||||
{
|
||||
|
|
@ -157,7 +165,7 @@ error:
|
|||
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)
|
||||
{
|
||||
return spa_json_to_pod_checked(b, flags, info, value, len, NULL);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,14 @@ extern "C" {
|
|||
|
||||
#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
|
||||
* 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);
|
||||
return spa_json_next(iter, val);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
int len;
|
||||
|
|
@ -45,7 +53,7 @@ SPA_API_IMPL int spa_json_get_float(struct spa_json *iter, float *res)
|
|||
}
|
||||
|
||||
/* 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;
|
||||
int len;
|
||||
|
|
@ -55,7 +63,7 @@ SPA_API_IMPL int spa_json_get_int(struct spa_json *iter, int *res)
|
|||
}
|
||||
|
||||
/* 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;
|
||||
int len;
|
||||
|
|
@ -65,7 +73,7 @@ SPA_API_IMPL int spa_json_get_bool(struct spa_json *iter, bool *res)
|
|||
}
|
||||
|
||||
/* 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;
|
||||
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;
|
||||
int len;
|
||||
|
|
@ -89,7 +97,7 @@ SPA_API_IMPL int spa_json_enter_container(struct spa_json *iter, struct spa_json
|
|||
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)
|
||||
{
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
struct spa_json sub;
|
||||
|
|
@ -119,20 +127,20 @@ SPA_API_IMPL int spa_json_container_len(struct spa_json *iter, const char *value
|
|||
}
|
||||
|
||||
/* 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, '{');
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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 */
|
||||
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, '[');
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
@ -197,7 +205,7 @@ SPA_API_IMPL int spa_json_begin_array(struct spa_json * iter, const char *data,
|
|||
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)
|
||||
{
|
||||
spa_json_make_str_array_unpack(32,uint32_t, atoi);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,14 @@ extern "C" {
|
|||
|
||||
#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
|
||||
* Doubly linked list data structure
|
||||
|
|
@ -28,19 +36,19 @@ struct spa_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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#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->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;
|
||||
}
|
||||
|
||||
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))
|
||||
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;
|
||||
}
|
||||
|
||||
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->next->prev = elem->prev;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,14 @@ extern "C" {
|
|||
|
||||
#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 {
|
||||
uint64_t interval;
|
||||
uint64_t begin;
|
||||
|
|
@ -22,7 +30,7 @@ struct spa_ratelimit {
|
|||
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;
|
||||
if (r->begin + r->interval < now) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,14 @@ struct spa_ringbuffer;
|
|||
|
||||
#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.
|
||||
*/
|
||||
|
|
@ -40,7 +48,7 @@ struct 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();
|
||||
}
|
||||
|
|
@ -51,7 +59,7 @@ SPA_API_IMPL void spa_ringbuffer_init(struct spa_ringbuffer *rbuf)
|
|||
* \param rbuf a spa_ringbuffer
|
||||
* \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->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
|
||||
* 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);
|
||||
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 len number of bytes to read
|
||||
*/
|
||||
SPA_API_IMPL void
|
||||
SPA_API_RINGBUFFER void
|
||||
spa_ringbuffer_read_data(struct spa_ringbuffer *rbuf SPA_UNUSED,
|
||||
const void *buffer, uint32_t size,
|
||||
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 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);
|
||||
}
|
||||
|
|
@ -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
|
||||
* 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);
|
||||
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 len number of bytes to write
|
||||
*/
|
||||
SPA_API_IMPL void
|
||||
SPA_API_RINGBUFFER void
|
||||
spa_ringbuffer_write_data(struct spa_ringbuffer *rbuf SPA_UNUSED,
|
||||
void *buffer, uint32_t size,
|
||||
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 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,14 @@ extern "C" {
|
|||
|
||||
#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
|
||||
* String handling utilities
|
||||
|
|
@ -33,7 +41,7 @@ extern "C" {
|
|||
* 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;
|
||||
}
|
||||
|
|
@ -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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
|
@ -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
|
||||
* 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))
|
||||
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
|
||||
* 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;
|
||||
|
||||
|
|
@ -92,7 +100,7 @@ SPA_API_IMPL bool spa_strendswith(const char *s, const char *suffix)
|
|||
*
|
||||
* \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;
|
||||
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
|
||||
*/
|
||||
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;
|
||||
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
|
||||
*/
|
||||
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;
|
||||
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
|
||||
*/
|
||||
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;
|
||||
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
|
||||
*/
|
||||
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");
|
||||
}
|
||||
|
|
@ -210,7 +218,7 @@ SPA_API_IMPL bool spa_atob(const char *str)
|
|||
* number on error.
|
||||
*/
|
||||
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;
|
||||
|
||||
|
|
@ -233,7 +241,7 @@ SPA_API_IMPL int spa_vscnprintf(char *buffer, size_t size, const char *format, v
|
|||
* number on error.
|
||||
*/
|
||||
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;
|
||||
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.
|
||||
*/
|
||||
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
|
||||
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
|
||||
*/
|
||||
SPA_API_IMPL bool spa_atof(const char *str, float *val)
|
||||
SPA_API_STRING bool spa_atof(const char *str, float *val)
|
||||
{
|
||||
char *endptr;
|
||||
float v;
|
||||
|
|
@ -303,7 +311,7 @@ SPA_API_IMPL bool spa_atof(const char *str, float *val)
|
|||
*
|
||||
* \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
|
||||
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
|
||||
*/
|
||||
SPA_API_IMPL bool spa_atod(const char *str, double *val)
|
||||
SPA_API_STRING bool spa_atod(const char *str, double *val)
|
||||
{
|
||||
char *endptr;
|
||||
double v;
|
||||
|
|
@ -346,7 +354,7 @@ SPA_API_IMPL bool spa_atod(const char *str, double *val)
|
|||
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;
|
||||
l = spa_scnprintf(str, size, "%f", val);
|
||||
|
|
@ -362,7 +370,7 @@ struct spa_strbuf {
|
|||
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->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_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;
|
||||
ssize_t written;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,14 @@ extern "C" {
|
|||
#include <spa/utils/defs.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
|
||||
* Data type information enumerations
|
||||
*/
|
||||
|
|
@ -124,12 +132,12 @@ struct spa_type_info {
|
|||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
if ((h = strrchr(name, ':')) != NULL)
|
||||
|
|
@ -137,7 +145,7 @@ SPA_API_IMPL const char *spa_type_short_name(const char *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)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -147,7 +155,7 @@ SPA_API_IMPL uint32_t spa_type_from_short_name(const char *name,
|
|||
}
|
||||
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)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -158,7 +166,7 @@ SPA_API_IMPL const char * spa_type_to_name(uint32_t type,
|
|||
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 char *n = spa_type_to_name(type, info, unknown);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue