20 |
|
|
21 |
#include "lscpinstrumentloader.h" |
#include "lscpinstrumentloader.h" |
22 |
|
|
23 |
LSCPInstrumentLoader::LSCPInstrumentLoader() : Thread(false, 0, -4) { |
LSCPInstrumentLoader::LSCPInstrumentLoader() : Thread(true, false, 0, -4) { |
24 |
pQueue = new RingBuffer<command_t>(INSTRUMENT_LOADER_QUEUE_SIZE); |
pQueue = new RingBuffer<command_t>(INSTRUMENT_LOADER_QUEUE_SIZE); |
25 |
} |
} |
26 |
|
|
39 |
* @param pEngine - engine on which the instrument should be loaded |
* @param pEngine - engine on which the instrument should be loaded |
40 |
*/ |
*/ |
41 |
void LSCPInstrumentLoader::StartNewLoad(String Filename, uint uiInstrumentIndex, Engine* pEngine) { |
void LSCPInstrumentLoader::StartNewLoad(String Filename, uint uiInstrumentIndex, Engine* pEngine) { |
42 |
|
// already tell the engine which instrument to load |
43 |
|
pEngine->PrepareLoadInstrument(Filename.c_str(), uiInstrumentIndex); |
44 |
|
|
45 |
command_t cmd; |
command_t cmd; |
46 |
cmd.pFilename = new String(Filename); |
cmd.pEngine = pEngine; |
|
cmd.uiInstrumentIndex = uiInstrumentIndex; |
|
|
cmd.pEngine = pEngine; |
|
47 |
pQueue->push(&cmd); |
pQueue->push(&cmd); |
48 |
StartThread(); // ensure thread is running |
StartThread(); // ensure thread is running |
49 |
conditionJobsLeft.Set(true); // wake up thread |
conditionJobsLeft.Set(true); // wake up thread |
56 |
command_t cmd; |
command_t cmd; |
57 |
pQueue->pop(&cmd); |
pQueue->pop(&cmd); |
58 |
try { |
try { |
59 |
cmd.pEngine->LoadInstrument(cmd.pFilename->c_str(), cmd.uiInstrumentIndex); |
cmd.pEngine->LoadInstrument(); |
60 |
} |
} |
61 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
62 |
e.PrintMessage(); |
e.PrintMessage(); |
63 |
} |
} |
|
delete cmd.pFilename; |
|
64 |
// Always re-enable the engine. |
// Always re-enable the engine. |
65 |
cmd.pEngine->Enable(); |
cmd.pEngine->Enable(); |
66 |
} |
} |