RAM2118 commited on
Commit
31b4607
·
verified ·
1 Parent(s): a4a5519

Out-of-process rebuild: Add Shared/IPCProtocol.h — message definitions for parent↔helper IPC

Browse files
Files changed (1) hide show
  1. Source/Shared/IPCProtocol.h +98 -0
Source/Shared/IPCProtocol.h ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ #include <string>
4
+ #include <cstdint>
5
+
6
+ // IPC Protocol between PluginBridge (parent) and PluginBridgeHelper (child)
7
+ // Transport: Unix domain socket, newline-delimited JSON messages
8
+ //
9
+ // Flow:
10
+ // Parent → Helper: commands (load plugin, get/set params, show GUI, quit)
11
+ // Helper → Parent: responses + notifications (param changes from GUI, crash)
12
+
13
+ namespace IPC {
14
+
15
+ // Socket path (unique per instance using PID)
16
+ inline std::string getSocketPath(int parentPid)
17
+ {
18
+ return "/tmp/pluginbridge_" + std::to_string(parentPid) + ".sock";
19
+ }
20
+
21
+ // Shared memory name (unique per instance)
22
+ inline std::string getShmName(int parentPid)
23
+ {
24
+ return "pluginbridge_audio_" + std::to_string(parentPid);
25
+ }
26
+
27
+ // Semaphore names
28
+ inline std::string getInputSemName(int parentPid)
29
+ {
30
+ return "pb_input_" + std::to_string(parentPid);
31
+ }
32
+
33
+ inline std::string getOutputSemName(int parentPid)
34
+ {
35
+ return "pb_output_" + std::to_string(parentPid);
36
+ }
37
+
38
+ // --- Message Types (Parent → Helper) ---
39
+
40
+ // Load a plugin by file path
41
+ // {"cmd":"load","path":"/Library/Audio/Plug-Ins/VST3/Pro-Q 4.vst3"}
42
+ // Response: {"ok":true,"name":"Pro-Q 4","params":737} or {"ok":false,"error":"..."}
43
+
44
+ // Unload current plugin
45
+ // {"cmd":"unload"}
46
+ // Response: {"ok":true}
47
+
48
+ // Search parameters by keyword
49
+ // {"cmd":"search_param","keyword":"gain"}
50
+ // Response: {"ok":true,"results":[{"i":12,"n":"Band 1 Gain","v":0.5,"t":"0.0 dB"},...]}
51
+
52
+ // Get parameter values by index
53
+ // {"cmd":"get_params","ids":[12,13,14]}
54
+ // Response: {"ok":true,"values":{"12":0.5,"13":0.7,"14":0.0}}
55
+
56
+ // Set parameter values
57
+ // {"cmd":"set_params","values":{"12":0.75,"13":0.3}}
58
+ // Response: {"ok":true}
59
+
60
+ // Show/hide plugin GUI
61
+ // {"cmd":"show_gui"}
62
+ // {"cmd":"hide_gui"}
63
+ // Response: {"ok":true}
64
+
65
+ // Get plugin state (for save)
66
+ // {"cmd":"get_state"}
67
+ // Response: {"ok":true,"state":"<base64-encoded state>"}
68
+
69
+ // Set plugin state (for restore)
70
+ // {"cmd":"set_state","state":"<base64-encoded state>"}
71
+ // Response: {"ok":true}
72
+
73
+ // Configure audio
74
+ // {"cmd":"configure","sampleRate":44100,"blockSize":512,"channels":2}
75
+ // Response: {"ok":true}
76
+
77
+ // Quit helper
78
+ // {"cmd":"quit"}
79
+ // No response (process exits)
80
+
81
+ // --- Message Types (Helper → Parent, unsolicited notifications) ---
82
+
83
+ // Parameter changed from GUI interaction
84
+ // {"notify":"param_changed","index":12,"value":0.75}
85
+
86
+ // Plugin crashed (sent if helper catches it before dying)
87
+ // {"notify":"crashed","error":"..."}
88
+
89
+ // Helper ready (sent after startup)
90
+ // {"notify":"ready"}
91
+
92
+ // --- Constants ---
93
+
94
+ static constexpr int kMaxMessageSize = 65536; // 64KB max for state blobs
95
+ static constexpr int kHelperTimeoutMs = 5000; // 5s to start up
96
+ static constexpr int kProcessBlockTimeoutMs = 50; // 50ms max wait in processBlock
97
+
98
+ } // namespace IPC