Corrected the segfault upon launching
This commit is contained in:
parent
ee42a8925c
commit
7091d997b3
2 changed files with 21 additions and 17 deletions
|
|
@ -22,6 +22,7 @@ public:
|
|||
{
|
||||
for (int i = 0; i < config::numVoices; ++i)
|
||||
voices.push_back(std::make_unique<Voice>(ccState));
|
||||
garbageCollectionThread = std::thread(&Synth::garbageCollection, this);
|
||||
}
|
||||
|
||||
~Synth()
|
||||
|
|
@ -142,6 +143,20 @@ private:
|
|||
return freeVoice->get();
|
||||
}
|
||||
|
||||
void garbageCollection()
|
||||
{
|
||||
while (!threadsShouldQuit) {
|
||||
auto activeVoices { 0 };
|
||||
for (auto& voice : voices) {
|
||||
voice->garbageCollect();
|
||||
if (!voice->isFree())
|
||||
activeVoices++;
|
||||
}
|
||||
DBG("Active voices:" << activeVoices << " | Stray buffers: " << FilePool::getFileBuffers());
|
||||
std::this_thread::sleep_for(1s);
|
||||
}
|
||||
}
|
||||
|
||||
bool hasGlobal { false };
|
||||
bool hasControl { false };
|
||||
int numGroups { 0 };
|
||||
|
|
@ -174,18 +189,7 @@ private:
|
|||
std::uniform_real_distribution<float> randomDistribution { 0, 1 };
|
||||
|
||||
bool threadsShouldQuit { false };
|
||||
std::thread garbageCollectionThread { [&]() {
|
||||
while (!threadsShouldQuit) {
|
||||
auto activeVoices { 0 };
|
||||
for (auto& voice : voices) {
|
||||
voice->garbageCollect();
|
||||
if (!voice->isFree())
|
||||
activeVoices++;
|
||||
}
|
||||
DBG("Active voices:" << activeVoices << " | Stray buffers: " << FilePool::getFileBuffers());
|
||||
std::this_thread::sleep_for(1s);
|
||||
}
|
||||
} };
|
||||
std::thread garbageCollectionThread;
|
||||
|
||||
float getUniform()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -217,14 +217,14 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
Region* region;
|
||||
Region* region { nullptr };
|
||||
|
||||
enum class State {
|
||||
idle,
|
||||
playing,
|
||||
release
|
||||
};
|
||||
State state;
|
||||
State state { State::idle };
|
||||
bool noteIsOff { false };
|
||||
|
||||
TriggerType triggerType;
|
||||
|
|
@ -237,11 +237,11 @@ private:
|
|||
float baseGain { 1.0 };
|
||||
float baseFrequency { 440.0 };
|
||||
|
||||
uint32_t sourcePosition;
|
||||
uint32_t initialDelay;
|
||||
uint32_t sourcePosition { 0 };
|
||||
uint32_t initialDelay { 0 };
|
||||
|
||||
std::atomic<bool> dataReady { false };
|
||||
std::unique_ptr<StereoBuffer<float>, std::function<void(StereoBuffer<float>*)>> fileData;
|
||||
std::unique_ptr<StereoBuffer<float>, std::function<void(StereoBuffer<float>*)>> fileData { nullptr };
|
||||
|
||||
Buffer<float> tempBuffer1;
|
||||
Buffer<float> tempBuffer2;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue