1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
/* PipeWire
*
* Copyright © 2020 Wim Taymans
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef PULSE_SERVER_DEFS_H
#define PULSE_SERVER_DEFS_H
#include <pipewire/node.h>
#define FLAG_SHMDATA 0x80000000LU
#define FLAG_SHMDATA_MEMFD_BLOCK 0x20000000LU
#define FLAG_SHMRELEASE 0x40000000LU
#define FLAG_SHMREVOKE 0xC0000000LU
#define FLAG_SHMMASK 0xFF000000LU
#define FLAG_SEEKMASK 0x000000FFLU
#define FLAG_SHMWRITABLE 0x00800000LU
#define SEEK_RELATIVE 0
#define SEEK_ABSOLUTE 1
#define SEEK_RELATIVE_ON_READ 2
#define SEEK_RELATIVE_END 3
#define FRAME_SIZE_MAX_ALLOW (1024*1024*16)
#define PROTOCOL_FLAG_MASK 0xffff0000u
#define PROTOCOL_VERSION_MASK 0x0000ffffu
#define PROTOCOL_VERSION 35
#define NATIVE_COOKIE_LENGTH 256
#define MAX_TAG_SIZE (64*1024)
#define MIN_BUFFERS 1u
#define MAX_BUFFERS 4u
#define MAXLENGTH (4u*1024*1024) /* 4MB */
#define SCACHE_ENTRY_SIZE_MAX (1024*1024*16)
#define MODULE_INDEX_MASK 0xfffffffu
#define MODULE_EXTENSION_FLAG (1u << 28)
#define MODULE_FLAG (1u << 29)
#define DEFAULT_SINK "@DEFAULT_SINK@"
#define DEFAULT_SOURCE "@DEFAULT_SOURCE@"
#define DEFAULT_MONITOR "@DEFAULT_MONITOR@"
enum error_code {
ERR_OK = 0, /**< No error */
ERR_ACCESS, /**< Access failure */
ERR_COMMAND, /**< Unknown command */
ERR_INVALID, /**< Invalid argument */
ERR_EXIST, /**< Entity exists */
ERR_NOENTITY, /**< No such entity */
ERR_CONNECTIONREFUSED, /**< Connection refused */
ERR_PROTOCOL, /**< Protocol error */
ERR_TIMEOUT, /**< Timeout */
ERR_AUTHKEY, /**< No authentication key */
ERR_INTERNAL, /**< Internal error */
ERR_CONNECTIONTERMINATED, /**< Connection terminated */
ERR_KILLED, /**< Entity killed */
ERR_INVALIDSERVER, /**< Invalid server */
ERR_MODINITFAILED, /**< Module initialization failed */
ERR_BADSTATE, /**< Bad state */
ERR_NODATA, /**< No data */
ERR_VERSION, /**< Incompatible protocol version */
ERR_TOOLARGE, /**< Data too large */
ERR_NOTSUPPORTED, /**< Operation not supported \since 0.9.5 */
ERR_UNKNOWN, /**< The error code was unknown to the client */
ERR_NOEXTENSION, /**< Extension does not exist. \since 0.9.12 */
ERR_OBSOLETE, /**< Obsolete functionality. \since 0.9.15 */
ERR_NOTIMPLEMENTED, /**< Missing implementation. \since 0.9.15 */
ERR_FORKED, /**< The caller forked without calling execve() and tried to reuse the context. \since 0.9.15 */
ERR_IO, /**< An IO error happened. \since 0.9.16 */
ERR_BUSY, /**< Device or resource busy. \since 0.9.17 */
ERR_MAX /**< Not really an error but the first invalid error code */
};
static inline int res_to_err(int res)
{
switch (res) {
case 0: return ERR_OK;
case -EACCES: case -EPERM: return ERR_ACCESS;
case -ENOTTY: return ERR_COMMAND;
case -EINVAL: return ERR_INVALID;
case -EEXIST: return ERR_EXIST;
case -ENOENT: case -ESRCH: case -ENXIO: case -ENODEV: return ERR_NOENTITY;
case -ECONNREFUSED:
#ifdef ENONET
case -ENONET:
#endif
case -EHOSTDOWN: case -ENETDOWN: return ERR_CONNECTIONREFUSED;
case -EPROTO: case -EBADMSG: return ERR_PROTOCOL;
case -ETIMEDOUT:
#ifdef ETIME
case -ETIME:
#endif
return ERR_TIMEOUT;
#ifdef ENOKEY
case -ENOKEY: return ERR_AUTHKEY;
#endif
case -ECONNRESET: case -EPIPE: return ERR_CONNECTIONTERMINATED;
#ifdef EBADFD
case -EBADFD: return ERR_BADSTATE;
#endif
#ifdef ENODATA
case -ENODATA: return ERR_NODATA;
#endif
case -EOVERFLOW: case -E2BIG: case -EFBIG:
case -ERANGE: case -ENAMETOOLONG: return ERR_TOOLARGE;
case -ENOTSUP: case -EPROTONOSUPPORT: case -ESOCKTNOSUPPORT: return ERR_NOTSUPPORTED;
case -ENOSYS: return ERR_NOTIMPLEMENTED;
case -EIO: return ERR_IO;
case -EBUSY: return ERR_BUSY;
case -ENFILE: case -EMFILE: return ERR_INTERNAL;
}
return ERR_UNKNOWN;
}
enum {
SUBSCRIPTION_MASK_NULL = 0x0000U,
SUBSCRIPTION_MASK_SINK = 0x0001U,
SUBSCRIPTION_MASK_SOURCE = 0x0002U,
SUBSCRIPTION_MASK_SINK_INPUT = 0x0004U,
SUBSCRIPTION_MASK_SOURCE_OUTPUT = 0x0008U,
SUBSCRIPTION_MASK_MODULE = 0x0010U,
SUBSCRIPTION_MASK_CLIENT = 0x0020U,
SUBSCRIPTION_MASK_SAMPLE_CACHE = 0x0040U,
SUBSCRIPTION_MASK_SERVER = 0x0080U,
SUBSCRIPTION_MASK_AUTOLOAD = 0x0100U,
SUBSCRIPTION_MASK_CARD = 0x0200U,
SUBSCRIPTION_MASK_ALL = 0x02ffU
};
enum {
SUBSCRIPTION_EVENT_SINK = 0x0000U,
SUBSCRIPTION_EVENT_SOURCE = 0x0001U,
SUBSCRIPTION_EVENT_SINK_INPUT = 0x0002U,
SUBSCRIPTION_EVENT_SOURCE_OUTPUT = 0x0003U,
SUBSCRIPTION_EVENT_MODULE = 0x0004U,
SUBSCRIPTION_EVENT_CLIENT = 0x0005U,
SUBSCRIPTION_EVENT_SAMPLE_CACHE = 0x0006U,
SUBSCRIPTION_EVENT_SERVER = 0x0007U,
SUBSCRIPTION_EVENT_AUTOLOAD = 0x0008U,
SUBSCRIPTION_EVENT_CARD = 0x0009U,
SUBSCRIPTION_EVENT_FACILITY_MASK = 0x000FU,
SUBSCRIPTION_EVENT_NEW = 0x0000U,
SUBSCRIPTION_EVENT_CHANGE = 0x0010U,
SUBSCRIPTION_EVENT_REMOVE = 0x0020U,
SUBSCRIPTION_EVENT_TYPE_MASK = 0x0030U
};
enum {
STATE_INVALID = -1,
STATE_RUNNING = 0,
STATE_IDLE = 1,
STATE_SUSPENDED = 2,
STATE_INIT = -2,
STATE_UNLINKED = -3
};
static inline int node_state(enum pw_node_state state)
{
switch (state) {
case PW_NODE_STATE_ERROR:
return STATE_UNLINKED;
case PW_NODE_STATE_CREATING:
return STATE_INIT;
case PW_NODE_STATE_SUSPENDED:
return STATE_SUSPENDED;
case PW_NODE_STATE_IDLE:
return STATE_IDLE;
case PW_NODE_STATE_RUNNING:
return STATE_RUNNING;
}
return STATE_INVALID;
}
enum {
SINK_HW_VOLUME_CTRL = 0x0001U,
SINK_LATENCY = 0x0002U,
SINK_HARDWARE = 0x0004U,
SINK_NETWORK = 0x0008U,
SINK_HW_MUTE_CTRL = 0x0010U,
SINK_DECIBEL_VOLUME = 0x0020U,
SINK_FLAT_VOLUME = 0x0040U,
SINK_DYNAMIC_LATENCY = 0x0080U,
SINK_SET_FORMATS = 0x0100U,
};
enum {
SOURCE_HW_VOLUME_CTRL = 0x0001U,
SOURCE_LATENCY = 0x0002U,
SOURCE_HARDWARE = 0x0004U,
SOURCE_NETWORK = 0x0008U,
SOURCE_HW_MUTE_CTRL = 0x0010U,
SOURCE_DECIBEL_VOLUME = 0x0020U,
SOURCE_DYNAMIC_LATENCY = 0x0040U,
SOURCE_FLAT_VOLUME = 0x0080U,
};
static const char * const port_types[] = {
"unknown",
"aux",
"speaker",
"headphones",
"line",
"mic",
"headset",
"handset",
"earpiece",
"spdif",
"hdmi",
"tv",
"radio",
"video",
"usb",
"bluetooth",
"portable",
"handsfree",
"car",
"hifi",
"phone",
"network",
"analog",
};
static inline uint32_t port_type_value(const char *port_type)
{
uint32_t i;
for (i = 0; i < SPA_N_ELEMENTS(port_types); i++) {
if (strcmp(port_types[i], port_type) == 0)
return i;
}
return 0;
}
#define METADATA_DEFAULT_SINK "default.audio.sink"
#define METADATA_DEFAULT_SOURCE "default.audio.source"
#define METADATA_CONFIG_DEFAULT_SINK "default.configured.audio.sink"
#define METADATA_CONFIG_DEFAULT_SOURCE "default.configured.audio.source"
#define METADATA_TARGET_NODE "target.node"
#define METADATA_TARGET_OBJECT "target.object"
#endif /* PULSE_SERVER_DEFS_H */
|