PipeWire  0.3.59
vararg.h
Go to the documentation of this file.
1 /* Simple Plugin API
2  *
3  * Copyright © 2019 Wim Taymans
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef SPA_POD_VARARG_H
26 #define SPA_POD_VARARG_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <stdarg.h>
33 
34 #include <spa/pod/pod.h>
35 
41 #define SPA_POD_Prop(key,...) \
42  key, ##__VA_ARGS__
43 
44 #define SPA_POD_Control(offset,type,...) \
45  offset, type, ##__VA_ARGS__
46 
47 #define SPA_CHOICE_RANGE(def,min,max) 3,(def),(min),(max)
48 #define SPA_CHOICE_STEP(def,min,max,step) 4,(def),(min),(max),(step)
49 #define SPA_CHOICE_ENUM(n_vals,...) (n_vals),##__VA_ARGS__
50 #define SPA_CHOICE_FLAGS(flags) 1, (flags)
51 #define SPA_CHOICE_BOOL(def) 3,(def),(def),!(def)
52 
53 #define SPA_POD_Bool(val) "b", val
54 #define SPA_POD_CHOICE_Bool(def) "?eb", SPA_CHOICE_BOOL(def)
55 
56 #define SPA_POD_Id(val) "I", val
57 #define SPA_POD_CHOICE_ENUM_Id(n_vals,...) "?eI", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)
58 
59 #define SPA_POD_Int(val) "i", val
60 #define SPA_POD_CHOICE_ENUM_Int(n_vals,...) "?ei", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)
61 #define SPA_POD_CHOICE_RANGE_Int(def,min,max) "?ri", SPA_CHOICE_RANGE(def, min, max)
62 #define SPA_POD_CHOICE_STEP_Int(def,min,max,step) "?si", SPA_CHOICE_STEP(def, min, max, step)
63 #define SPA_POD_CHOICE_FLAGS_Int(flags) "?fi", SPA_CHOICE_FLAGS(flags)
64 
65 #define SPA_POD_Long(val) "l", val
66 #define SPA_POD_CHOICE_ENUM_Long(n_vals,...) "?el", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)
67 #define SPA_POD_CHOICE_RANGE_Long(def,min,max) "?rl", SPA_CHOICE_RANGE(def, min, max)
68 #define SPA_POD_CHOICE_STEP_Long(def,min,max,step) "?sl", SPA_CHOICE_STEP(def, min, max, step)
69 #define SPA_POD_CHOICE_FLAGS_Long(flags) "?fl", SPA_CHOICE_FLAGS(flags)
70 
71 #define SPA_POD_Float(val) "f", val
72 #define SPA_POD_CHOICE_ENUM_Float(n_vals,...) "?ef", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)
73 #define SPA_POD_CHOICE_RANGE_Float(def,min,max) "?rf", SPA_CHOICE_RANGE(def, min, max)
74 #define SPA_POD_CHOICE_STEP_Float(def,min,max,step) "?sf", SPA_CHOICE_STEP(def, min, max, step)
75 
76 #define SPA_POD_Double(val) "d", val
77 #define SPA_POD_CHOICE_ENUM_Double(n_vals,...) "?ed", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)
78 #define SPA_POD_CHOICE_RANGE_Double(def,min,max) "?rd", SPA_CHOICE_RANGE(def, min, max)
79 #define SPA_POD_CHOICE_STEP_Double(def,min,max,step) "?sd", SPA_CHOICE_STEP(def, min, max, step)
80 
81 #define SPA_POD_String(val) "s",val
82 #define SPA_POD_Stringn(val,len) "S",val,len
83 
84 #define SPA_POD_Bytes(val,len) "y",val,len
85 
86 #define SPA_POD_Rectangle(val) "R",val
87 #define SPA_POD_CHOICE_ENUM_Rectangle(n_vals,...) "?eR", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)
88 #define SPA_POD_CHOICE_RANGE_Rectangle(def,min,max) "?rR", SPA_CHOICE_RANGE((def),(min),(max))
89 #define SPA_POD_CHOICE_STEP_Rectangle(def,min,max,step) "?sR", SPA_CHOICE_STEP((def),(min),(max),(step))
90 
91 #define SPA_POD_Fraction(val) "F",val
92 #define SPA_POD_CHOICE_ENUM_Fraction(n_vals,...) "?eF", SPA_CHOICE_ENUM(n_vals, __VA_ARGS__)
93 #define SPA_POD_CHOICE_RANGE_Fraction(def,min,max) "?rF", SPA_CHOICE_RANGE((def),(min),(max))
94 #define SPA_POD_CHOICE_STEP_Fraction(def,min,max,step) "?sF", SPA_CHOICE_STEP(def, min, max, step)
95 
96 #define SPA_POD_Array(csize,ctype,n_vals,vals) "a", csize,ctype,n_vals,vals
97 #define SPA_POD_Pointer(type,val) "p", type,val
98 #define SPA_POD_Fd(val) "h", val
99 #define SPA_POD_None() "P", NULL
100 #define SPA_POD_Pod(val) "P", val
101 #define SPA_POD_PodObject(val) "O", val
102 #define SPA_POD_PodStruct(val) "T", val
103 #define SPA_POD_PodChoice(val) "V", val
104 
109 #ifdef __cplusplus
110 } /* extern "C" */
111 #endif
112 
113 #endif /* SPA_POD_VARARG_H */
spa/pod/pod.h