46 |
void InstrumentManagerThread::StartNewLoad(String Filename, uint uiInstrumentIndex, EngineChannel* pEngineChannel) { |
void InstrumentManagerThread::StartNewLoad(String Filename, uint uiInstrumentIndex, EngineChannel* pEngineChannel) { |
47 |
dmsg(1,("Scheduling '%s' (Index=%d) to be loaded in background (if not loaded yet).\n",Filename.c_str(),uiInstrumentIndex)); |
dmsg(1,("Scheduling '%s' (Index=%d) to be loaded in background (if not loaded yet).\n",Filename.c_str(),uiInstrumentIndex)); |
48 |
|
|
49 |
static bool listenerRegistered = false; |
// the listener only needs to be registered once in the |
50 |
if (!listenerRegistered) { |
// Sampler, but as we don't know if Sampler has been |
51 |
pEngineChannel->GetSampler()->AddChannelCountListener(&eventHandler); |
// recreated, we simply remove and add every time |
52 |
listenerRegistered = true; |
pEngineChannel->GetSampler()->RemoveChannelCountListener(&eventHandler); |
53 |
} |
pEngineChannel->GetSampler()->AddChannelCountListener(&eventHandler); |
|
|
|
54 |
|
|
55 |
command_t cmd; |
command_t cmd; |
56 |
cmd.type = command_t::DIRECT_LOAD; |
cmd.type = command_t::DIRECT_LOAD; |
101 |
TestCancel(); |
TestCancel(); |
102 |
#endif |
#endif |
103 |
|
|
104 |
while (!queue.empty()) { |
while (true) { |
105 |
command_t cmd; |
command_t cmd; |
106 |
|
|
107 |
// grab a new command from the queue |
// grab a new command from the queue |
108 |
mutex.Lock(); |
mutex.Lock(); |
109 |
cmd = queue.front(); |
bool empty = queue.empty(); |
110 |
queue.pop_front(); |
if (!empty) { |
111 |
|
cmd = queue.front(); |
112 |
|
queue.pop_front(); |
113 |
|
} |
114 |
mutex.Unlock(); |
mutex.Unlock(); |
115 |
|
if (empty) break; |
116 |
|
|
117 |
try { |
try { |
118 |
switch (cmd.type) { |
switch (cmd.type) { |