+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
c · 70 lines · 1.4 KB · SPDX: MIT
main
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 #include <stdio.h>
9 #include <stdarg.h>
10 #include <ctype.h>
11  
12 #include <spa/utils/defs.h>
13 #include <spa/support/log.h>
14 #include <spa/debug/context.h>
15 #include <spa/debug/dict.h>
16 #include <spa/debug/format.h>
17 #include <spa/debug/mem.h>
18 #include <spa/debug/pod.h>
19  
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23  
24 /**
25 * \addtogroup spa_debug
26 * \{
27 */
28  
29 #ifndef SPA_API_DEBUG_FILE
30 #ifdef SPA_API_IMPL
31 #define SPA_API_DEBUG_FILE SPA_API_IMPL
32 #else
33 #define SPA_API_DEBUG_FILE static inline
34 #endif
35 #endif
36  
37 struct spa_debug_file_ctx {
38 struct spa_debug_context ctx;
39 FILE *f;
40 };
41  
42 SPA_PRINTF_FUNC(2,3)
43 SPA_API_DEBUG_FILE void spa_debug_file_log(struct spa_debug_context *ctx, const char *fmt, ...)
44 {
45 struct spa_debug_file_ctx *c = SPA_CONTAINER_OF(ctx, struct spa_debug_file_ctx, ctx);
46 va_list args;
47 va_start(args, fmt);
48 vfprintf(c->f, fmt, args); fputc('\n', c->f);
49 va_end(args);
50 }
51  
52 #define SPA_DEBUG_FILE_INIT(_f) \
53 (struct spa_debug_file_ctx){ { spa_debug_file_log }, _f, }
54  
55 #define spa_debug_file_error_location(f,loc,fmt,...) \
56 ({ \
57 struct spa_debug_file_ctx c = SPA_DEBUG_FILE_INIT(f); \
58 if (fmt) spa_debugc(&c.ctx, fmt, __VA_ARGS__); \
59 spa_debugc_error_location(&c.ctx, loc); \
60 })
61  
62 /**
63 * \}
64 */
65  
66 #ifdef __cplusplus
67 } /* extern "C" */
68 #endif
69  
70 #endif /* SPA_DEBUG_FILE_H */