mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-20 06:46:31 -04:00
add per type API defines
This commit is contained in:
parent
b03f2f7afa
commit
31802d4994
85 changed files with 1137 additions and 509 deletions
|
|
@ -23,7 +23,15 @@ extern "C" {
|
|||
#include <spa/debug/types.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;
|
||||
|
||||
|
|
@ -98,7 +106,7 @@ SPA_API_IMPL int spa_debugc_buffer(struct spa_debug_context *ctx, int indent, co
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,13 +26,22 @@ extern "C" {
|
|||
#define spa_debug(_fmt,...) spa_debugn(_fmt"\n", ## __VA_ARGS__)
|
||||
#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 {
|
||||
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__)
|
||||
|
||||
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)
|
||||
{
|
||||
int i, skip = loc->col > 80 ? loc->col - 40 : 0, lc = loc->col-skip-1;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,15 @@ extern "C" {
|
|||
#include <spa/debug/context.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;
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_context ctx;
|
||||
FILE *f;
|
||||
};
|
||||
|
||||
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);
|
||||
va_list args;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,16 @@ extern "C" {
|
|||
#include <spa/param/type-info.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,
|
||||
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;
|
||||
}
|
||||
|
||||
SPA_API_IMPL int
|
||||
SPA_API_DEBUG_FORMAT int
|
||||
spa_debug_format_value(const struct spa_type_info *info,
|
||||
uint32_t type, void *body, uint32_t size)
|
||||
{
|
||||
|
|
@ -108,7 +117,7 @@ spa_debug_format_value(const struct spa_type_info *info,
|
|||
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 char *media_type;
|
||||
|
|
@ -198,7 +207,7 @@ SPA_API_IMPL int spa_debugc_format(struct spa_debug_context *ctx, int indent,
|
|||
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)
|
||||
{
|
||||
return spa_debugc_format(NULL, indent, info, format);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,14 @@ extern "C" {
|
|||
#include <spa/debug/mem.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
|
||||
* \{
|
||||
|
|
@ -36,7 +44,7 @@ struct spa_debug_log_ctx {
|
|||
};
|
||||
|
||||
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);
|
||||
va_list args;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,15 @@ extern "C" {
|
|||
|
||||
#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;
|
||||
char buffer[512];
|
||||
|
|
@ -36,7 +44,7 @@ SPA_API_IMPL int spa_debugc_mem(struct spa_debug_context *ctx, int indent, const
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,15 @@ extern "C" {
|
|||
#include <spa/debug/context.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" " 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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,15 @@ extern "C" {
|
|||
#include <spa/pod/pod.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,
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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_API_IMPL int
|
||||
SPA_API_DEBUG_POD int
|
||||
spa_debug_pod_value(int indent, const struct spa_type_info *info,
|
||||
uint32_t type, void *body, uint32_t 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)
|
||||
{
|
||||
return spa_debugc_pod(NULL, indent, info, pod);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,16 @@ extern "C" {
|
|||
|
||||
#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;
|
||||
|
||||
|
|
@ -37,19 +46,19 @@ SPA_API_IMPL const struct spa_type_info *spa_debug_type_find(const struct spa_ty
|
|||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
return NULL;
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
return SPA_ID_INVALID;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue