Out-of-process rebuild: Add Plugin/HelperConnection.h/.cpp — spawns helper, IPC, crash detection
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768#pragma once
#include <juce_core/juce_core.h>#include <string>#include <thread>#include <atomic>#include <functional>#include <mutex>
#include "../Shared/SharedAudioBuffer.h"#include "../Shared/IPCProtocol.h"
class HelperConnection : private juce::Timer{public: HelperConnection(); ~HelperConnection();
// Lifecycle bool spawnHelper(); void killHelper(); bool isHelperRunning() const { return helperRunning.load(); }
// Audio bridge SharedAudioBuffer& getSharedAudio() { return sharedAudio; } SharedSemaphore& getInputSem() { return inputSem; } SharedSemaphore& getOutputSem() { return outputSem; }
// Send commands (blocking — waits for response) std::string sendCommand(const std::string& json);
// State enum class State { Disconnected, Starting, Connected, Crashed }; State getState() const { return state.load(); }
// Callbacks std::function<void()> onHelperReady; std::function<void()> onHelperCrashed; std::function<void(int, float)> onParamChanged;
private: void timerCallback() override; void ipcListenLoop(); void handleNotification(const std::string& json);
// Helper process pid_t helperPid = 0; std::atomic<bool> helperRunning{false}; std::atomic<State> state{State::Disconnected};
// Shared memory SharedAudioBuffer sharedAudio; SharedSemaphore inputSem; SharedSemaphore outputSem;
// IPC socket (parent is server) int serverSocketFd = -1; int clientSocketFd = -1; // connection from helper std::thread ipcThread; std::atomic<bool> ipcRunning{false};
// Command/response synchronization std::mutex commandMutex; std::string lastResponse; std::atomic<bool> responseReady{false};
int myPid;};Source/Plugin/HelperConnection.hAdded+68