-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.cpp
More file actions
388 lines (315 loc) · 10.5 KB
/
setup.cpp
File metadata and controls
388 lines (315 loc) · 10.5 KB
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
//=================================\\
// [ OWNER ]
// CREATOR : Vladislav Khudash
// AGE : 17
// LOCATION : Ukraine
//
// [ PINFO ]
// DATE : 10.03.2026
// PROJECT : PIPEWIRE-SETUPER
// PLATFORM : LINUX
//=================================\\
#include <string>
#include <iostream>
#include <fstream>
#include <filesystem>
static inline void write_file(const std::string &p, const std::string &dt) {
std::ofstream f(p);
if (!f.is_open()) {
std::cerr << p << " [-]\n";
return;
}
f << dt;
if (f.fail()) {
std::cerr << "Failed writing file: " << p << " [*]\n";
return;
}
f.close();
std::cout << p << " [+]\n";
}
int main() {
const char *home = getenv("HOME");
if (!home) {
std::cerr << "Cannot determine HOME directory [*]\n";
return 1;
}
const std::string uconfig = std::string(home) + "/.config";
if (!std::filesystem::is_directory(uconfig)) {
std::cerr << "DO NOT SUPPORT OS [*]\n";
return 1;
}
if (system("which pipewire > /dev/null 2>&1") != 0) {
std::cerr << "PipeWire not installed [*]\n";
return 1;
}
const std::string pw_dir = uconfig + "/pipewire";
std::error_code ec;
std::filesystem::create_directories(pw_dir, ec);
if (ec) {
std::cerr << "Failed creating PipeWire directory: " << ec.message() << " [*]\n";
return 1;
}
const std::string pipewire_conf = pw_dir + "/pipewire.conf";
const std::string pipewire_pulse_conf = pw_dir + "/pipewire-pulse.conf";
const std::string client_conf = pw_dir + "/client.conf";
const std::string client_rt_conf = pw_dir + "/client-rt.conf";
const std::string jack_conf = pw_dir + "/jack.conf";
std::cout << "Start setuping PipeWire for current USER [*]\n";
write_file(pipewire_conf, R"CONFIG(context.properties = {
core.daemon = true
core.name = pipewire-0
default.clock.rate = 48000
default.clock.allowed-rates = [48000]
default.clock.quantum = 512
default.clock.min-quantum = 512
default.clock.max-quantum = 1024
default.clock.quantum-limit = 8192
link.max-buffers = 32
module.x11.bell = true
module.access = true
module.jackdbus-detect = true
vm.overrides = { default.clock.min-quantum = 512 }
}
context.spa-libs = {
audio.convert.* = audioconvert/libspa-audioconvert
avb.* = avb/libspa-avb
api.alsa.* = alsa/libspa-alsa
api.v4l2.* = v4l2/libspa-v4l2
api.libcamera.* = libcamera/libspa-libcamera
api.bluez5.* = bluez5/libspa-bluez5
api.vulkan.* = vulkan/libspa-vulkan
api.jack.* = jack/libspa-jack
support.* = support/libspa-support
}
context.modules = [
{ name = libpipewire-module-rt
args = { nice.level = -2 rt.prio = 50 }
flags = [ ifexists nofail ]
}
{ name = libpipewire-module-protocol-native }
{ name = libpipewire-module-profiler }
{ name = libpipewire-module-metadata }
{ name = libpipewire-module-spa-device-factory }
{ name = libpipewire-module-spa-node-factory }
{ name = libpipewire-module-client-node }
{ name = libpipewire-module-client-device }
{ name = libpipewire-module-portal flags = [ ifexists nofail ] }
{ name = libpipewire-module-access condition = [ { module.access = true } ] }
{ name = libpipewire-module-adapter }
{ name = libpipewire-module-link-factory }
{ name = libpipewire-module-session-manager }
{ name = libpipewire-module-x11-bell
flags = [ ifexists nofail ]
condition = [ { module.x11.bell = true } ]
}
{ name = libpipewire-module-jackdbus-detect
flags = [ ifexists nofail ]
condition = [ { module.jackdbus-detect = true } ]
}
]
context.objects = [
{ factory = spa-node-factory
args = {
factory.name = api.alsa.pcm.sink
node.name = HighQuality-Sink
node.description = "ALSA Output (Low-Latency)"
audio.format = "S32LE"
audio.rate = 48000
audio.channels = 2
resample.quality = 10
channelmix.normalize = false
channelmix.upmix = false
channelmix.upmix-method = psd
node.latency = 512/48000
}
}
{ factory = spa-node-factory
args = {
factory.name = api.alsa.pcm.source
node.name = HighQuality-Source
node.description = "ALSA Input (Low-Latency)"
audio.format = "S32LE"
audio.rate = 48000
audio.channels = 2
resample.quality = 10
node.latency = 512/48000
}
}
]
alsa.properties = {
alsa.access = [ MMAP_INTERLEAVED MMAP_NONINTERLEAVED ]
alsa.format = [ "S32LE" "F32LE" ]
alsa.rate = { min=48000 max=48000 }
alsa.channels = { min=2 max=2 }
alsa.period-bytes = { min=2048 max=65536 }
alsa.buffer-bytes = { min=8192 max=131072 }
alsa.volume-method = "physical"
}
context.exec = []
pulse.cmd = [
{ cmd = "load-module" args = "module-always-sink" flags = [] }
]
stream.properties = {
node.latency = 512/48000
dither.method = "shibata"
}
pulse.properties = {
server.address = ["unix:native"]
vm.overrides = { pulse.min.quantum = 512/48000 }
}
pulse.rules = [
{ matches = [] actions = {} }
]
)CONFIG");
write_file(pipewire_pulse_conf, R"(context.properties = {
default.clock.rate = 48000
default.clock.quantum = 512
default.clock.min-quantum = 512
default.clock.max-quantum = 1024
default.clock.quantum-limit = 8192
}
context.spa-libs = {
audio.convert.* = audioconvert/libspa-audioconvert
support.* = support/libspa-support
}
context.modules = [
{ name = libpipewire-module-rt args = { nice.level = -2 } flags = [ ifexists nofail ] }
{ name = libpipewire-module-protocol-native }
{ name = libpipewire-module-client-node }
{ name = libpipewire-module-adapter }
{ name = libpipewire-module-metadata }
{ name = libpipewire-module-protocol-pulse }
]
context.exec = []
pulse.cmd = [
{ cmd = "load-module" args = "module-always-sink" flags = [] }
]
stream.properties = {
node.latency = 512/48000
resample.quality = 10
channelmix.normalize = false
channelmix.upmix = false
channelmix.upmix-method = psd
audio.format = "S32LE"
dither.method = "shibata"
}
pulse.properties = {
server.address = ["unix:native"]
pulse.default.format = "S32LE"
vm.overrides = { pulse.min.quantum = 512/48000 }
}
pulse.rules = [
{ matches = [] actions = {} }
]
)");
write_file(client_conf, R"(context.properties = {
log.level = 0
}
context.spa-libs = {
audio.convert.* = audioconvert/libspa-audioconvert
api.alsa.* = alsa/libspa-alsa
support.* = support/libspa-support
}
context.modules = [
{ name = libpipewire-module-protocol-native }
{ name = libpipewire-module-client-node }
{ name = libpipewire-module-client-device }
{ name = libpipewire-module-adapter }
{ name = libpipewire-module-metadata }
{ name = libpipewire-module-session-manager }
]
stream.properties = {
audio.format = "S32LE"
audio.rate = 48000
node.latency = 512/48000
resample.quality = 10
dither.method = "shibata"
dither.noise = 2
channelmix.normalize = false
channelmix.mix-lfe = true
channelmix.upmix = false
channelmix.upmix-method = psd
}
)");
write_file(client_rt_conf, R"(context.properties = {
log.level = 0
default.clock.rate = 48000
default.clock.allowed-rates = [ 44100 48000 ]
default.clock.quantum = 512
default.clock.min-quantum = 512
default.clock.max-quantum = 1024
default.clock.quantum-limit = 8192
}
context.spa-libs = {
audio.convert.* = audioconvert/libspa-audioconvert
api.alsa.* = alsa/libspa-alsa
support.* = support/libspa-support
}
context.modules = [
{ name = libpipewire-module-rt
args = { rt.prio = 50 nice.level = -1 }
flags = [ ifexists nofail ]
}
{ name = libpipewire-module-protocol-native }
{ name = libpipewire-module-client-node }
{ name = libpipewire-module-client-device }
{ name = libpipewire-module-adapter }
{ name = libpipewire-module-metadata }
{ name = libpipewire-module-session-manager }
]
context.objects = [
{ factory = spa-device-factory
args = { factory.name = api.alsa.enum.udev }
}
]
stream.properties = {
node.latency = 512/48000
resample.quality = 10
dither.method = "shibata"
dither.noise = 2
channelmix.normalize = false
channelmix.mix-lfe = true
channelmix.upmix = false
channelmix.upmix-method = psd
audio.format = "S32LE"
audio.rate = 48000
}
alsa.properties = {
alsa.access = [ MMAP_INTERLEAVED MMAP_NONINTERLEAVED RW_INTERLEAVED RW_NONINTERLEAVED ]
alsa.format = [ FLOAT S32 ]
alsa.rate = { min=44100 max=48000 }
alsa.channels = { min=2 max=2 }
alsa.period-bytes = { min=1024 max=65536 }
alsa.buffer-bytes = { min=8192 max=131072 }
alsa.volume-method = "physical"
}
)");
write_file(jack_conf, R"(context.properties = {
log.level = 0
}
context.spa-libs = {
audio.convert.* = audioconvert/libspa-audioconvert
support.* = support/libspa-support
}
context.modules = [
{ name = libpipewire-module-rt args = { rt.prio = 50 nice.level = -1 } flags = [ ifexists nofail ] }
{ name = libpipewire-module-protocol-native }
{ name = libpipewire-module-client-node }
{ name = libpipewire-module-metadata }
]
jack.properties = {
node.latency = 512/48000
node.rate = 48000
node.quantum = 512
node.lock-quantum = true
jack.self-connect-mode = allow
jack.merge-monitor = false
resample.quality = 10
}
)");
if (system("systemctl --user restart pipewire.service pipewire-pulse.service wireplumber.service") != 0) {
std::cerr << "Failed restarting PipeWire services [*]\n";
}
std::cout << "Setuped PipeWire for current USER [+]\n";
return 0;
}