RAM2118 commited on
Commit
a902ad7
·
verified ·
1 Parent(s): a119e77

Fix: HelperPluginHost.cpp use flat include for Constants.h

Browse files
Files changed (1) hide show
  1. Source/Helper/HelperPluginHost.cpp +4 -11
Source/Helper/HelperPluginHost.cpp CHANGED
@@ -1,5 +1,5 @@
1
  #include "HelperPluginHost.h"
2
- #include "../Shared/Constants.h"
3
  #include <juce_audio_basics/juce_audio_basics.h>
4
 
5
  HelperPluginHost::HelperPluginHost()
@@ -104,28 +104,25 @@ void HelperPluginHost::startProcessing()
104
  {
105
  if (processing.load()) return;
106
  processing.store(true);
107
-
108
  audioThread = std::thread([this]() { audioProcessingLoop(); });
109
  }
110
 
111
  void HelperPluginHost::stopProcessing()
112
  {
113
  processing.store(false);
114
- if (inputSem) inputSem->signal(); // wake thread so it can exit
115
  if (audioThread.joinable())
116
  audioThread.join();
117
  }
118
 
119
  void HelperPluginHost::audioProcessingLoop()
120
  {
121
- // Set thread to realtime priority
122
  juce::Thread::setCurrentThreadPriority(10);
123
 
124
  while (processing.load())
125
  {
126
- // Wait for parent to signal input is ready
127
  if (!inputSem->wait(100))
128
- continue; // timeout — check if still processing
129
 
130
  if (!processing.load()) break;
131
  if (!plugin || !sharedAudio) continue;
@@ -134,22 +131,18 @@ void HelperPluginHost::audioProcessingLoop()
134
  int numChannels = header->numChannels.load();
135
  int blockSize = header->blockSize.load();
136
 
137
- // Read input from shared memory into local buffer
138
  juce::AudioBuffer<float> buffer(numChannels, blockSize);
139
  float* channelPtrs[2] = { buffer.getWritePointer(0),
140
  numChannels > 1 ? buffer.getWritePointer(1) : nullptr };
141
  sharedAudio->readInput(channelPtrs, numChannels, blockSize);
142
 
143
- // Process
144
  juce::MidiBuffer midi;
145
  plugin->processBlock(buffer, midi);
146
 
147
- // Write output to shared memory
148
  const float* constPtrs[2] = { buffer.getReadPointer(0),
149
  numChannels > 1 ? buffer.getReadPointer(1) : nullptr };
150
  sharedAudio->writeOutput(constPtrs, numChannels, blockSize);
151
 
152
- // Signal parent that output is ready
153
  header->state.store(kStateOutputReady);
154
  outputSem->signal();
155
  }
@@ -229,7 +222,7 @@ bool HelperPluginHost::setParams(const std::map<int, float>& values)
229
  void HelperPluginHost::showGui()
230
  {
231
  if (!plugin || !plugin->hasEditor()) return;
232
- if (guiWindow) return; // already showing
233
 
234
  juce::MessageManager::callAsync([this]()
235
  {
 
1
  #include "HelperPluginHost.h"
2
+ #include "Constants.h"
3
  #include <juce_audio_basics/juce_audio_basics.h>
4
 
5
  HelperPluginHost::HelperPluginHost()
 
104
  {
105
  if (processing.load()) return;
106
  processing.store(true);
 
107
  audioThread = std::thread([this]() { audioProcessingLoop(); });
108
  }
109
 
110
  void HelperPluginHost::stopProcessing()
111
  {
112
  processing.store(false);
113
+ if (inputSem) inputSem->signal();
114
  if (audioThread.joinable())
115
  audioThread.join();
116
  }
117
 
118
  void HelperPluginHost::audioProcessingLoop()
119
  {
 
120
  juce::Thread::setCurrentThreadPriority(10);
121
 
122
  while (processing.load())
123
  {
 
124
  if (!inputSem->wait(100))
125
+ continue;
126
 
127
  if (!processing.load()) break;
128
  if (!plugin || !sharedAudio) continue;
 
131
  int numChannels = header->numChannels.load();
132
  int blockSize = header->blockSize.load();
133
 
 
134
  juce::AudioBuffer<float> buffer(numChannels, blockSize);
135
  float* channelPtrs[2] = { buffer.getWritePointer(0),
136
  numChannels > 1 ? buffer.getWritePointer(1) : nullptr };
137
  sharedAudio->readInput(channelPtrs, numChannels, blockSize);
138
 
 
139
  juce::MidiBuffer midi;
140
  plugin->processBlock(buffer, midi);
141
 
 
142
  const float* constPtrs[2] = { buffer.getReadPointer(0),
143
  numChannels > 1 ? buffer.getReadPointer(1) : nullptr };
144
  sharedAudio->writeOutput(constPtrs, numChannels, blockSize);
145
 
 
146
  header->state.store(kStateOutputReady);
147
  outputSem->signal();
148
  }
 
222
  void HelperPluginHost::showGui()
223
  {
224
  if (!plugin || !plugin->hasEditor()) return;
225
+ if (guiWindow) return;
226
 
227
  juce::MessageManager::callAsync([this]()
228
  {