forked from UrbanLienert/blocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJuceThread.cpp
More file actions
58 lines (48 loc) · 1.36 KB
/
JuceThread.cpp
File metadata and controls
58 lines (48 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// JuceThread.cpp
// Blocks
//
// Created by Urban Lienert on 23.02.20.
// Copyright © 2020 Urban Lienert. All rights reserved.
//
#include "JuceThread.hpp"
using namespace juce;
JuceThread::JuceThread (const String &threadName, t_outlet *a, t_outlet *b, t_outlet *c, t_outlet *d, bool loadDefaultProgram, size_t threadStackSize)
:Thread(threadName, threadStackSize)
{
out_A = a;
out_B = b;
out_C = c;
out_D = d;
loadProgram = loadDefaultProgram;
blockReady = false;
}
JuceThread::~JuceThread() {
}
void JuceThread::startThread() {
Thread::startThread();
}
bool JuceThread::stopThread(int timeOutMilliseconds) {
return Thread::stopThread(timeOutMilliseconds);
}
void JuceThread::run() {
ScopedJuceInitialiser_GUI platform;
if (!MessageManager::getInstanceWithoutCreating()->isThisTheMessageThread()) {
error("there's already a 'blocks' object running");
blockReady = true;
return;
}
mBlockFinder = {std::make_unique<BlockFinder>()};
mBlockFinder->out_A = out_A;
mBlockFinder->out_B = out_B;
mBlockFinder->out_C = out_C;
mBlockFinder->out_D = out_D;
mBlockFinder->loadPrgram = loadProgram;
blockReady = true;
do
{
MessageManager::getInstanceWithoutCreating()->runDispatchLoopUntil(10);
}
while (!threadShouldExit());
mBlockFinder = nullptr;
}