RAM2118 commited on
Commit
9d2dc5e
·
verified ·
1 Parent(s): 2be9229

Fix: PluginBridgeProcessor.cpp use flat include for IPCProtocol.h (Source/Shared in include dirs)

Browse files
Source/Plugin/PluginBridgeProcessor.cpp CHANGED
@@ -1,6 +1,6 @@
1
  #include "PluginBridgeProcessor.h"
2
  #include "PluginBridgeEditor.h"
3
- #include "../Shared/IPCProtocol.h"
4
 
5
  #include "json.hpp"
6
  using json = nlohmann::json;
@@ -11,7 +11,6 @@ PluginBridgeProcessor::PluginBridgeProcessor()
11
  .withOutput("Output", juce::AudioChannelSet::stereo(), true)),
12
  mcpServer(PluginBridgeConstants::kDefaultMcpPort, helper)
13
  {
14
- // Set up crash callback
15
  helper.onHelperCrashed = [this]()
16
  {
17
  pluginLoaded = false;
@@ -34,7 +33,6 @@ void PluginBridgeProcessor::prepareToPlay(double sampleRate, int samplesPerBlock
34
  currentSampleRate = sampleRate;
35
  currentBlockSize = samplesPerBlock;
36
 
37
- // If helper is connected, configure it
38
  if (helper.isHelperRunning())
39
  {
40
  json cmd = {{"cmd", "configure"},
@@ -43,7 +41,6 @@ void PluginBridgeProcessor::prepareToPlay(double sampleRate, int samplesPerBlock
43
  {"channels", 2}};
44
  helper.sendCommand(cmd.dump());
45
 
46
- // Update shared memory header
47
  auto* header = helper.getSharedAudio().getHeader();
48
  if (header)
49
  {
@@ -67,7 +64,6 @@ void PluginBridgeProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce:
67
  for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
68
  buffer.clear(i, 0, buffer.getNumSamples());
69
 
70
- // If no plugin loaded or helper not running, pass through
71
  if (!pluginLoaded || !helper.isHelperRunning())
72
  return;
73
 
@@ -77,26 +73,21 @@ void PluginBridgeProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce:
77
  int numChannels = buffer.getNumChannels();
78
  int numSamples = buffer.getNumSamples();
79
 
80
- // Write input to shared memory
81
  const float* inputPtrs[2] = {
82
  buffer.getReadPointer(0),
83
  numChannels > 1 ? buffer.getReadPointer(1) : buffer.getReadPointer(0)
84
  };
85
  shm.writeInput(inputPtrs, numChannels, numSamples);
86
 
87
- // Update header
88
  auto* header = shm.getHeader();
89
  header->blockSize.store((uint32_t)numSamples);
90
  header->numChannels.store((uint32_t)numChannels);
91
  header->state.store(kStateInputReady);
92
 
93
- // Signal helper: input is ready
94
  helper.getInputSem().signal();
95
 
96
- // Wait for helper to finish processing (with timeout)
97
  if (helper.getOutputSem().wait(IPC::kProcessBlockTimeoutMs))
98
  {
99
- // Read output from shared memory
100
  float* outputPtrs[2] = {
101
  buffer.getWritePointer(0),
102
  numChannels > 1 ? buffer.getWritePointer(1) : buffer.getWritePointer(0)
@@ -104,11 +95,6 @@ void PluginBridgeProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce:
104
  shm.readOutput(outputPtrs, numChannels, numSamples);
105
  header->state.store(kStateIdle);
106
  }
107
- else
108
- {
109
- // Timeout — helper might be stuck or crashed. Pass through silence.
110
- // (Don't pass through input — if plugin was supposed to process, silence is safer)
111
- }
112
  }
113
 
114
  juce::AudioProcessorEditor* PluginBridgeProcessor::createEditor()
@@ -121,7 +107,6 @@ void PluginBridgeProcessor::getStateInformation(juce::MemoryBlock& destData)
121
  juce::ValueTree state("PluginBridgeState");
122
  state.setProperty("pluginPath", pluginPath, nullptr);
123
 
124
- // Get plugin state from helper
125
  if (pluginLoaded && helper.isHelperRunning())
126
  {
127
  auto response = helper.sendCommand("{\"cmd\":\"get_state\"}");
@@ -146,7 +131,6 @@ void PluginBridgeProcessor::setStateInformation(const void* data, int sizeInByte
146
  {
147
  loadPlugin(path);
148
 
149
- // Restore plugin state after loading
150
  auto pluginState = state.getProperty("pluginState").toString();
151
  if (pluginState.isNotEmpty() && helper.isHelperRunning())
152
  {
@@ -169,7 +153,6 @@ int PluginBridgeProcessor::getMcpServerPort() const
169
 
170
  void PluginBridgeProcessor::loadPlugin(const juce::String& path)
171
  {
172
- // Spawn helper if not running
173
  if (!helper.isHelperRunning())
174
  {
175
  if (!helper.spawnHelper())
@@ -178,7 +161,6 @@ void PluginBridgeProcessor::loadPlugin(const juce::String& path)
178
  return;
179
  }
180
 
181
- // Configure helper with current audio settings
182
  json configCmd = {{"cmd", "configure"},
183
  {"sampleRate", currentSampleRate},
184
  {"blockSize", currentBlockSize},
@@ -186,7 +168,6 @@ void PluginBridgeProcessor::loadPlugin(const juce::String& path)
186
  helper.sendCommand(configCmd.dump());
187
  }
188
 
189
- // Send load command
190
  json loadCmd = {{"cmd", "load"},
191
  {"path", path.toStdString()},
192
  {"sampleRate", currentSampleRate},
 
1
  #include "PluginBridgeProcessor.h"
2
  #include "PluginBridgeEditor.h"
3
+ #include "IPCProtocol.h"
4
 
5
  #include "json.hpp"
6
  using json = nlohmann::json;
 
11
  .withOutput("Output", juce::AudioChannelSet::stereo(), true)),
12
  mcpServer(PluginBridgeConstants::kDefaultMcpPort, helper)
13
  {
 
14
  helper.onHelperCrashed = [this]()
15
  {
16
  pluginLoaded = false;
 
33
  currentSampleRate = sampleRate;
34
  currentBlockSize = samplesPerBlock;
35
 
 
36
  if (helper.isHelperRunning())
37
  {
38
  json cmd = {{"cmd", "configure"},
 
41
  {"channels", 2}};
42
  helper.sendCommand(cmd.dump());
43
 
 
44
  auto* header = helper.getSharedAudio().getHeader();
45
  if (header)
46
  {
 
64
  for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
65
  buffer.clear(i, 0, buffer.getNumSamples());
66
 
 
67
  if (!pluginLoaded || !helper.isHelperRunning())
68
  return;
69
 
 
73
  int numChannels = buffer.getNumChannels();
74
  int numSamples = buffer.getNumSamples();
75
 
 
76
  const float* inputPtrs[2] = {
77
  buffer.getReadPointer(0),
78
  numChannels > 1 ? buffer.getReadPointer(1) : buffer.getReadPointer(0)
79
  };
80
  shm.writeInput(inputPtrs, numChannels, numSamples);
81
 
 
82
  auto* header = shm.getHeader();
83
  header->blockSize.store((uint32_t)numSamples);
84
  header->numChannels.store((uint32_t)numChannels);
85
  header->state.store(kStateInputReady);
86
 
 
87
  helper.getInputSem().signal();
88
 
 
89
  if (helper.getOutputSem().wait(IPC::kProcessBlockTimeoutMs))
90
  {
 
91
  float* outputPtrs[2] = {
92
  buffer.getWritePointer(0),
93
  numChannels > 1 ? buffer.getWritePointer(1) : buffer.getWritePointer(0)
 
95
  shm.readOutput(outputPtrs, numChannels, numSamples);
96
  header->state.store(kStateIdle);
97
  }
 
 
 
 
 
98
  }
99
 
100
  juce::AudioProcessorEditor* PluginBridgeProcessor::createEditor()
 
107
  juce::ValueTree state("PluginBridgeState");
108
  state.setProperty("pluginPath", pluginPath, nullptr);
109
 
 
110
  if (pluginLoaded && helper.isHelperRunning())
111
  {
112
  auto response = helper.sendCommand("{\"cmd\":\"get_state\"}");
 
131
  {
132
  loadPlugin(path);
133
 
 
134
  auto pluginState = state.getProperty("pluginState").toString();
135
  if (pluginState.isNotEmpty() && helper.isHelperRunning())
136
  {
 
153
 
154
  void PluginBridgeProcessor::loadPlugin(const juce::String& path)
155
  {
 
156
  if (!helper.isHelperRunning())
157
  {
158
  if (!helper.spawnHelper())
 
161
  return;
162
  }
163
 
 
164
  json configCmd = {{"cmd", "configure"},
165
  {"sampleRate", currentSampleRate},
166
  {"blockSize", currentBlockSize},
 
168
  helper.sendCommand(configCmd.dump());
169
  }
170
 
 
171
  json loadCmd = {{"cmd", "load"},
172
  {"path", path.toStdString()},
173
  {"sampleRate", currentSampleRate},