1 |
/*************************************************************************** |
2 |
* * |
3 |
* Copyright (C) 2005 Christian Schoenebeck * |
4 |
* * |
5 |
* 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 * |
7 |
* the Free Software Foundation; either version 2 of the License, or * |
8 |
* (at your option) any later version. * |
9 |
* * |
10 |
* This library is distributed in the hope that it will be useful, * |
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 |
* GNU General Public License for more details. * |
14 |
* * |
15 |
* You should have received a copy of the GNU General Public License * |
16 |
* along with this library; if not, write to the Free Software * |
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
18 |
* MA 02111-1307 USA * |
19 |
***************************************************************************/ |
20 |
|
21 |
#ifndef __LSCPINSTRUMENTLOADER_H__ |
22 |
#define __LSCPINSTRUMENTLOADER_H__ |
23 |
|
24 |
#include "../common/global.h" |
25 |
#include "../common/Thread.h" |
26 |
#include "../common/Condition.h" |
27 |
#include "../common/RingBuffer.h" |
28 |
#include "../Sampler.h" |
29 |
|
30 |
/// Maximum numbers of instruments waiting to be loaded by the LSCPInstrumentLoader. |
31 |
#define INSTRUMENT_LOADER_QUEUE_SIZE 200 |
32 |
|
33 |
using namespace LinuxSampler; |
34 |
|
35 |
/** |
36 |
* Instrument loader thread for the LinuxSampler Control Protocol (LSCP) |
37 |
* Server for loading instruments in the background. This loader will only |
38 |
* load one instrument by one. The thread will actually only be created once |
39 |
* StartnewLoad() method was called the first time. After that the thread |
40 |
* will exist for the whole life time of the LSCPInstrumentLoader instance |
41 |
* and just block until new loading jobs arrive. |
42 |
*/ |
43 |
class LSCPInstrumentLoader : public Thread { |
44 |
public: |
45 |
LSCPInstrumentLoader(); |
46 |
void StartNewLoad(String Filename, uint uiInstrumentIndex, EngineChannel* pEngineChannel); |
47 |
virtual ~LSCPInstrumentLoader(); |
48 |
protected: |
49 |
struct command_t { |
50 |
EngineChannel* pEngineChannel; |
51 |
}; |
52 |
|
53 |
// Instance variables. |
54 |
RingBuffer<command_t>* pQueue; ///< queue with commands for loading new instruments. |
55 |
Condition conditionJobsLeft; ///< synchronizer to block this thread until a new job arrives |
56 |
|
57 |
int Main(); ///< Implementation of virtual method from class Thread. |
58 |
}; |
59 |
|
60 |
#endif // __LSCPINSTRUMENTLOADER_H__ |