24 |
#include "../common/global.h" |
#include "../common/global.h" |
25 |
#include "../common/Thread.h" |
#include "../common/Thread.h" |
26 |
#include "../common/Condition.h" |
#include "../common/Condition.h" |
27 |
#include "../common/RingBuffer.h" |
#include "../common/Mutex.h" |
28 |
#include "../Sampler.h" |
#include "../Sampler.h" |
29 |
|
#include "../EventListeners.h" |
30 |
#include "InstrumentManager.h" |
#include "InstrumentManager.h" |
31 |
|
|
32 |
/// Maximum numbers of instruments waiting to be loaded by the InstrumentLoader. |
#include <list> |
|
#define INSTRUMENT_LOADER_QUEUE_SIZE 200 |
|
33 |
|
|
34 |
namespace LinuxSampler { |
namespace LinuxSampler { |
35 |
|
|
41 |
* to the API. |
* to the API. |
42 |
*/ |
*/ |
43 |
class InstrumentManagerThread : public Thread { |
class InstrumentManagerThread : public Thread { |
44 |
|
friend class EventHandler; |
45 |
|
|
46 |
public: |
public: |
47 |
InstrumentManagerThread(); |
InstrumentManagerThread(); |
48 |
void StartNewLoad(String Filename, uint uiInstrumentIndex, EngineChannel* pEngineChannel); |
void StartNewLoad(String Filename, uint uiInstrumentIndex, EngineChannel* pEngineChannel); |
61 |
}; |
}; |
62 |
|
|
63 |
// Instance variables. |
// Instance variables. |
64 |
RingBuffer<command_t,true>* pQueue; ///< queue with commands for loading new instruments. |
std::list<command_t> queue; ///< queue with commands for loading new instruments. |
65 |
Condition conditionJobsLeft; ///< synchronizer to block this thread until a new job arrives |
Mutex mutex; ///< for making the queue thread safe |
66 |
|
Condition conditionJobsLeft; ///< synchronizer to block this thread until a new job arrives |
67 |
|
|
68 |
int Main(); ///< Implementation of virtual method from class Thread. |
int Main(); ///< Implementation of virtual method from class Thread. |
69 |
|
private: |
70 |
|
class EventHandler : public ChannelCountAdapter { |
71 |
|
public: |
72 |
|
InstrumentManagerThread* pThread; |
73 |
|
virtual void ChannelToBeRemoved(SamplerChannel* pChannel); |
74 |
|
}; |
75 |
|
|
76 |
|
EventHandler eventHandler; |
77 |
}; |
}; |
78 |
|
|
79 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |