42 |
#include "../Sampler.h" |
#include "../Sampler.h" |
43 |
#include "../common/Thread.h" |
#include "../common/Thread.h" |
44 |
#include "../common/Mutex.h" |
#include "../common/Mutex.h" |
45 |
|
#include "../common/Condition.h" |
46 |
|
|
47 |
/// TCP Port on which the server should listen for connection requests. |
/// TCP Port on which the server should listen for connection requests. |
48 |
#define LSCP_PORT 8888 |
#define LSCP_PORT 8888 |
60 |
class LSCPServer : public Thread { |
class LSCPServer : public Thread { |
61 |
public: |
public: |
62 |
LSCPServer(Sampler* pSampler); |
LSCPServer(Sampler* pSampler); |
63 |
|
int WaitUntilInitialized(long TimeoutSeconds = 0L, long TimeoutNanoSeconds = 0L); |
64 |
|
|
65 |
// Methods called by the parser |
// Methods called by the parser |
66 |
String DestroyAudioOutputDevice(uint DeviceIndex); |
String DestroyAudioOutputDevice(uint DeviceIndex); |
68 |
String LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground = false); |
String LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground = false); |
69 |
String LoadEngine(String EngineName, uint uiSamplerChannel); |
String LoadEngine(String EngineName, uint uiSamplerChannel); |
70 |
String GetChannels(); |
String GetChannels(); |
71 |
|
String ListChannels(); |
72 |
String AddChannel(); |
String AddChannel(); |
73 |
String RemoveChannel(uint uiSamplerChannel); |
String RemoveChannel(uint uiSamplerChannel); |
74 |
String GetAvailableEngines(); |
String GetAvailableEngines(); |
100 |
String GetAudioOutputDeviceInfo(uint DeviceIndex); |
String GetAudioOutputDeviceInfo(uint DeviceIndex); |
101 |
String GetMidiInputDeviceInfo(uint DeviceIndex); |
String GetMidiInputDeviceInfo(uint DeviceIndex); |
102 |
String GetMidiInputPortInfo(uint DeviceIndex, uint PortIndex); |
String GetMidiInputPortInfo(uint DeviceIndex, uint PortIndex); |
103 |
|
String GetMidiInputPortParameterInfo(uint DeviceId, uint PortId, String ParameterName); |
104 |
String GetAudioOutputChannelInfo(uint DeviceId, uint ChannelId); |
String GetAudioOutputChannelInfo(uint DeviceId, uint ChannelId); |
105 |
String GetAudioOutputChannelParameterInfo(uint DeviceId, uint ChannelId, String ParameterName); |
String GetAudioOutputChannelParameterInfo(uint DeviceId, uint ChannelId, String ParameterName); |
106 |
String SetAudioOutputChannelParameter(uint DeviceId, uint ChannelId, String ParamKey, String ParamVal); |
String SetAudioOutputChannelParameter(uint DeviceId, uint ChannelId, String ParamKey, String ParamVal); |
119 |
String ResetChannel(uint uiSamplerChannel); |
String ResetChannel(uint uiSamplerChannel); |
120 |
String SubscribeNotification(LSCPEvent::event_t); |
String SubscribeNotification(LSCPEvent::event_t); |
121 |
String UnsubscribeNotification(LSCPEvent::event_t); |
String UnsubscribeNotification(LSCPEvent::event_t); |
122 |
|
String SetEcho(yyparse_param_t* pSession, double boolean_value); |
123 |
void AnswerClient(String ReturnMessage); |
void AnswerClient(String ReturnMessage); |
124 |
|
|
125 |
static int currentSocket; |
static int currentSocket; |
126 |
static std::map<int,String> bufferedCommands; |
static std::map<int,String> bufferedCommands; |
127 |
|
|
128 |
|
static void SendLSCPNotify( LSCPEvent Event ); |
129 |
|
|
130 |
protected: |
protected: |
131 |
int hSocket; |
int hSocket; |
132 |
sockaddr_in SocketAddress; |
sockaddr_in SocketAddress; |
133 |
Sampler* pSampler; |
Sampler* pSampler; |
134 |
|
Condition Initialized; |
135 |
|
|
136 |
int Main(); ///< Implementation of virtual method from class Thread |
int Main(); ///< Implementation of virtual method from class Thread |
137 |
|
|
|
static void SendLSCPNotify( LSCPEvent Event ); |
|
|
|
|
138 |
private: |
private: |
139 |
|
|
140 |
/** |
/** |
141 |
* Find a created audio output device index. |
* Find a created audio output device index. |
142 |
*/ |
*/ |
143 |
int GetAudioOutputDeviceIndex (AudioOutputDevice *pDevice); |
int GetAudioOutputDeviceIndex (AudioOutputDevice *pDevice); |
144 |
|
|
145 |
/** |
/** |
146 |
* Find a created midi input device index. |
* Find a created midi input device index. |
147 |
*/ |
*/ |
150 |
static std::map<int,String> bufferedNotifies; |
static std::map<int,String> bufferedNotifies; |
151 |
static Mutex NotifyMutex; |
static Mutex NotifyMutex; |
152 |
static Mutex NotifyBufferMutex; |
static Mutex NotifyBufferMutex; |
153 |
static bool GetLSCPCommand( std::vector<int>::iterator iter ); |
static bool GetLSCPCommand( std::vector<yyparse_param_t>::iterator iter ); |
154 |
static void CloseConnection( std::vector<int>::iterator iter ); |
static void CloseConnection( std::vector<yyparse_param_t>::iterator iter ); |
155 |
static std::vector<int> hSessions; |
static std::vector<yyparse_param_t> Sessions; |
156 |
static Mutex SubscriptionMutex; |
static Mutex SubscriptionMutex; |
157 |
static std::map< LSCPEvent::event_t, std::list<int> > eventSubscriptions; |
static std::map< LSCPEvent::event_t, std::list<int> > eventSubscriptions; |
158 |
static fd_set fdSet; |
static fd_set fdSet; |