1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
* Copyright (C) 2005 - 2007 Christian Schoenebeck * |
4 |
* * |
* * |
5 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
20 |
|
|
21 |
#include "InstrumentManagerThread.h" |
#include "InstrumentManagerThread.h" |
22 |
|
|
23 |
|
#include "../common/global_private.h" |
24 |
|
|
25 |
namespace LinuxSampler { |
namespace LinuxSampler { |
26 |
|
|
27 |
InstrumentManagerThread::InstrumentManagerThread() : Thread(true, false, 0, -4) { |
InstrumentManagerThread::InstrumentManagerThread() : Thread(true, false, 0, -4) { |
42 |
* @param pEngineChannel - engine channel on which the instrument should be loaded |
* @param pEngineChannel - engine channel on which the instrument should be loaded |
43 |
*/ |
*/ |
44 |
void InstrumentManagerThread::StartNewLoad(String Filename, uint uiInstrumentIndex, EngineChannel* pEngineChannel) { |
void InstrumentManagerThread::StartNewLoad(String Filename, uint uiInstrumentIndex, EngineChannel* pEngineChannel) { |
45 |
dmsg(1,("Scheduling '%s' (Index=%d) to be loaded in background (if not loaded yet).",Filename.c_str(),uiInstrumentIndex)); |
dmsg(1,("Scheduling '%s' (Index=%d) to be loaded in background (if not loaded yet).\n",Filename.c_str(),uiInstrumentIndex)); |
46 |
// already tell the engine which instrument to load |
// already tell the engine which instrument to load |
47 |
pEngineChannel->PrepareLoadInstrument(Filename.c_str(), uiInstrumentIndex); |
pEngineChannel->PrepareLoadInstrument(Filename.c_str(), uiInstrumentIndex); |
48 |
|
|
88 |
// Entry point for the task thread. |
// Entry point for the task thread. |
89 |
int InstrumentManagerThread::Main() { |
int InstrumentManagerThread::Main() { |
90 |
while (true) { |
while (true) { |
91 |
|
|
92 |
|
#if CONFIG_PTHREAD_TESTCANCEL |
93 |
|
TestCancel(); |
94 |
|
#endif |
95 |
|
|
96 |
while (!queue.empty()) { |
while (!queue.empty()) { |
97 |
command_t cmd; |
command_t cmd; |
98 |
|
|
112 |
default: |
default: |
113 |
std::cerr << "InstrumentManagerThread: unknown command - BUG!\n" << std::flush; |
std::cerr << "InstrumentManagerThread: unknown command - BUG!\n" << std::flush; |
114 |
} |
} |
115 |
} |
} catch (Exception e) { |
|
catch (Exception e) { |
|
116 |
e.PrintMessage(); |
e.PrintMessage(); |
117 |
|
} catch (...) { |
118 |
|
std::cerr << "InstrumentManagerThread: some exception occured, could not finish task\n" << std::flush; |
119 |
} |
} |
120 |
|
|
121 |
// remove processed command from queue |
// remove processed command from queue |