PipeWire 1.2.6

Loading...
Searching...
No Matches
file.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2022 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_DEBUG_FILE_H
6#define SPA_DEBUG_FILE_H
7
8#ifdef __cplusplus
9 extern "C" {
10#endif
11
12#include <stdio.h>
13#include <stdarg.h>
14#include <ctype.h>
15
16#include <spa/utils/defs.h>
17#include <spa/support/log.h>
18#include <spa/debug/context.h>
19#include <spa/debug/dict.h>
20#include <spa/debug/format.h>
21#include <spa/debug/mem.h>
22#include <spa/debug/pod.h>
23
29 struct spa_debug_file_ctx {
30 struct spa_debug_context ctx;
31 FILE *f;
32};
33
34 SPA_PRINTF_FUNC(2,3)
35static inline void spa_debug_file_log(struct spa_debug_context *ctx, const char *fmt, ...)
36{
37 struct spa_debug_file_ctx *c = SPA_CONTAINER_OF(ctx, struct spa_debug_file_ctx, ctx);
38 va_list args;
39 va_start(args, fmt);
40 vfprintf(c->f, fmt, args); fputc('\n', c->f);
41 va_end(args);
42}
43
44#define SPA_DEBUG_FILE_INIT(_f) \
45 (struct spa_debug_file_ctx){ { spa_debug_file_log }, _f, }
46
47#define spa_debug_file_error_location(f,loc,fmt,...) \
48({ \
49 struct spa_debug_file_ctx c = SPA_DEBUG_FILE_INIT(f); \
50 if (fmt) spa_debugc(&c.ctx, fmt, __VA_ARGS__); \
51 spa_debugc_error_location(&c.ctx, loc); \
52})
53
58#ifdef __cplusplus
59} /* extern "C" */
60#endif
61
62#endif /* SPA_DEBUG_FILE_H */
dict.h
spa/debug/dict.h
format.h
spa/debug/format.h
pod.h
spa/debug/pod.h
defs.h
spa/utils/defs.h
spa_debug_file_log
static void spa_debug_file_log(struct spa_debug_context *ctx, const char *fmt,...)
Definition file.h:40
SPA_CONTAINER_OF
#define SPA_CONTAINER_OF(p, t, m)
Definition defs.h:235
SPA_PRINTF_FUNC
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition defs.h:295
context.h
spa/debug/context.h
mem.h
spa/debug/mem.h
log.h
spa/support/log.h
spa_debug_context
Definition context.h:34
spa_debug_file_ctx
Definition file.h:34
spa_debug_file_ctx::f
FILE * f
Definition file.h:36
spa_debug_file_ctx::ctx
struct spa_debug_context ctx
Definition file.h:35