| // IPC Protocol between PluginBridge (parent) and PluginBridgeHelper (child) | |
| // | |
| // v0.4 Architecture: | |
| // - Audio: POSIX shared memory (zero-copy, same as v0.2) | |
| // - Sync: Named semaphores (same as v0.2) | |
| // - Commands: Unix domain socket, newline-delimited JSON | |
| // - GUI: CARemoteLayerServer in Helper β Mach port β CARemoteLayerClient in Host | |
| // | |
| // The Mach port for CARemoteLayerServer is transferred via NSMachBootstrapServer | |
| // using the name "com.pluginbridge.layer.<parentPid>" | |
| namespace IPC { | |
| // Socket path (unique per instance using PID) | |
| inline std::string getSocketPath(int parentPid) | |
| { | |
| return "/tmp/pluginbridge_" + std::to_string(parentPid) + ".sock"; | |
| } | |
| // Shared memory name | |
| inline std::string getShmName(int parentPid) | |
| { | |
| return "pluginbridge_audio_" + std::to_string(parentPid); | |
| } | |
| // Semaphore names | |
| inline std::string getInputSemName(int parentPid) | |
| { | |
| return "pb_input_" + std::to_string(parentPid); | |
| } | |
| inline std::string getOutputSemName(int parentPid) | |
| { | |
| return "pb_output_" + std::to_string(parentPid); | |
| } | |
| // Mach bootstrap port name for CARemoteLayerServer | |
| inline std::string getLayerPortName(int parentPid) | |
| { | |
| return "com.pluginbridge.layer." + std::to_string(parentPid); | |
| } | |
| // --- Message Types (Parent β Helper) --- | |
| // {"cmd":"load","path":"/path/to/plugin.vst3","sampleRate":44100,"blockSize":512} | |
| // {"cmd":"unload"} | |
| // {"cmd":"search_param","keyword":"gain"} | |
| // {"cmd":"get_params","ids":[0,1,2]} | |
| // {"cmd":"set_params","values":{"0":0.5,"1":0.75}} | |
| // {"cmd":"show_gui"} | |
| // {"cmd":"hide_gui"} | |
| // {"cmd":"get_state"} | |
| // {"cmd":"set_state","state":"<base64>"} | |
| // {"cmd":"configure","sampleRate":44100,"blockSize":512,"channels":2} | |
| // {"cmd":"quit"} | |
| // | |
| // --- Mouse/Keyboard forwarding (Parent β Helper) --- | |
| // {"cmd":"mouse","type":"down","x":120.5,"y":45.0,"button":0} | |
| // {"cmd":"mouse","type":"up","x":120.5,"y":45.0,"button":0} | |
| // {"cmd":"mouse","type":"move","x":130.0,"y":50.0} | |
| // {"cmd":"mouse","type":"drag","x":135.0,"y":52.0,"button":0} | |
| // {"cmd":"mouse","type":"scroll","x":120.5,"y":45.0,"dx":0,"dy":-3.0} | |
| // {"cmd":"key","type":"down","keyCode":36,"chars":"a","modifiers":0} | |
| // {"cmd":"key","type":"up","keyCode":36,"chars":"a","modifiers":0} | |
| // | |
| // --- Notifications (Helper β Parent) --- | |
| // {"notify":"ready","layerPortName":"com.pluginbridge.layer.12345","width":800,"height":600} | |
| // {"notify":"param_changed","index":5,"value":0.75} | |
| // {"notify":"resized","width":900,"height":650} | |
| // {"notify":"crashed","error":"..."} | |
| // --- Constants --- | |
| static constexpr int kMaxMessageSize = 65536; | |
| static constexpr int kHelperTimeoutMs = 10000; // 10s for startup (CARemoteLayer init takes time) | |
| static constexpr int kProcessBlockTimeoutMs = 50; // 50ms max wait in processBlock | |
| } // namespace IPC | |