43 |
*/ |
*/ |
44 |
fd_set LSCPServer::fdSet; |
fd_set LSCPServer::fdSet; |
45 |
int LSCPServer::currentSocket = -1; |
int LSCPServer::currentSocket = -1; |
46 |
std::vector<int> LSCPServer::hSessions = std::vector<int>(); |
std::vector<yyparse_param_t> LSCPServer::Sessions = std::vector<yyparse_param_t>(); |
47 |
std::map<int,String> LSCPServer::bufferedNotifies = std::map<int,String>(); |
std::map<int,String> LSCPServer::bufferedNotifies = std::map<int,String>(); |
48 |
std::map<int,String> LSCPServer::bufferedCommands = std::map<int,String>(); |
std::map<int,String> LSCPServer::bufferedCommands = std::map<int,String>(); |
49 |
std::map< LSCPEvent::event_t, std::list<int> > LSCPServer::eventSubscriptions = std::map< LSCPEvent::event_t, std::list<int> >(); |
std::map< LSCPEvent::event_t, std::list<int> > LSCPServer::eventSubscriptions = std::map< LSCPEvent::event_t, std::list<int> >(); |
61 |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
62 |
} |
} |
63 |
|
|
64 |
|
/** |
65 |
|
* Blocks the calling thread until the LSCP Server is initialized and |
66 |
|
* accepting socket connections, if the server is already initialized then |
67 |
|
* this method will return immediately. |
68 |
|
* @param TimeoutSeconds - optional: max. wait time in seconds |
69 |
|
* (default: 0s) |
70 |
|
* @param TimeoutNanoSeconds - optional: max wait time in nano seconds |
71 |
|
* (default: 0ns) |
72 |
|
* @returns 0 on success, a value less than 0 if timeout exceeded |
73 |
|
*/ |
74 |
|
int LSCPServer::WaitUntilInitialized(long TimeoutSeconds, long TimeoutNanoSeconds) { |
75 |
|
return Initialized.WaitAndUnlockIf(false, TimeoutSeconds, TimeoutNanoSeconds); |
76 |
|
} |
77 |
|
|
78 |
int LSCPServer::Main() { |
int LSCPServer::Main() { |
79 |
int hSocket = socket(AF_INET, SOCK_STREAM, 0); |
int hSocket = socket(AF_INET, SOCK_STREAM, 0); |
80 |
if (hSocket < 0) { |
if (hSocket < 0) { |
95 |
} |
} |
96 |
|
|
97 |
listen(hSocket, 1); |
listen(hSocket, 1); |
98 |
dmsg(1,("LSCPServer: Server running.\n")); // server running |
Initialized.Set(true); |
99 |
|
|
100 |
// now wait for client connections and handle their requests |
// now wait for client connections and handle their requests |
101 |
sockaddr_in client; |
sockaddr_in client; |
104 |
FD_SET(hSocket, &fdSet); |
FD_SET(hSocket, &fdSet); |
105 |
int maxSessions = hSocket; |
int maxSessions = hSocket; |
106 |
|
|
|
// Parser initialization |
|
|
yyparse_param_t yyparse_param; |
|
|
yyparse_param.pServer = this; |
|
|
|
|
107 |
while (true) { |
while (true) { |
108 |
fd_set selectSet = fdSet; |
fd_set selectSet = fdSet; |
109 |
int retval = select(maxSessions+1, &selectSet, NULL, NULL, NULL); |
int retval = select(maxSessions+1, &selectSet, NULL, NULL, NULL); |
128 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
129 |
} |
} |
130 |
|
|
131 |
hSessions.push_back(socket); |
// Parser initialization |
132 |
|
yyparse_param_t yyparse_param; |
133 |
|
yyparse_param.pServer = this; |
134 |
|
yyparse_param.hSession = socket; |
135 |
|
|
136 |
|
Sessions.push_back(yyparse_param); |
137 |
FD_SET(socket, &fdSet); |
FD_SET(socket, &fdSet); |
138 |
if (socket > maxSessions) |
if (socket > maxSessions) |
139 |
maxSessions = socket; |
maxSessions = socket; |
143 |
} |
} |
144 |
|
|
145 |
//Something was selected and it was not the hSocket, so it must be some command(s) coming. |
//Something was selected and it was not the hSocket, so it must be some command(s) coming. |
146 |
for (std::vector<int>::iterator iter = hSessions.begin(); iter != hSessions.end(); iter++) { |
for (std::vector<yyparse_param_t>::iterator iter = Sessions.begin(); iter != Sessions.end(); iter++) { |
147 |
if (FD_ISSET(*iter, &selectSet)) { //Was it this socket? |
if (FD_ISSET((*iter).hSession, &selectSet)) { //Was it this socket? |
148 |
if (GetLSCPCommand(iter)) { //Have we read the entire command? |
if (GetLSCPCommand(iter)) { //Have we read the entire command? |
149 |
dmsg(3,("LSCPServer: Got command on socket %d, calling parser.\n", currentSocket)); |
dmsg(3,("LSCPServer: Got command on socket %d, calling parser.\n", currentSocket)); |
150 |
yylex_init(&yyparse_param.pScanner); |
int dummy; // just a temporary hack to fulfill the restart() function prototype |
151 |
currentSocket = *iter; //a hack |
restart(NULL, dummy); // restart the 'scanner' |
152 |
int result = yyparse(&yyparse_param); |
currentSocket = (*iter).hSession; //a hack |
153 |
|
if ((*iter).bVerbose) { // if echo mode enabled |
154 |
|
AnswerClient(bufferedCommands[currentSocket]); |
155 |
|
} |
156 |
|
int result = yyparse(&(*iter)); |
157 |
currentSocket = -1; //continuation of a hack |
currentSocket = -1; //continuation of a hack |
158 |
dmsg(3,("LSCPServer: Done parsing on socket %d.\n", currentSocket)); |
dmsg(3,("LSCPServer: Done parsing on socket %d.\n", currentSocket)); |
159 |
if (result == LSCP_QUIT) { //Was it a quit command by any chance? |
if (result == LSCP_QUIT) { //Was it a quit command by any chance? |
174 |
} |
} |
175 |
NotifyBufferMutex.Unlock(); |
NotifyBufferMutex.Unlock(); |
176 |
} |
} |
|
//It will never get here anyway |
|
|
//yylex_destroy(yyparse_param.pScanner); |
|
177 |
} |
} |
178 |
|
|
179 |
void LSCPServer::CloseConnection( std::vector<int>::iterator iter ) { |
void LSCPServer::CloseConnection( std::vector<yyparse_param_t>::iterator iter ) { |
180 |
int socket = *iter; |
int socket = (*iter).hSession; |
181 |
dmsg(1,("LSCPServer: Client connection terminated on socket:%d.\n",socket)); |
dmsg(1,("LSCPServer: Client connection terminated on socket:%d.\n",socket)); |
182 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Client connection terminated on socket", socket)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Client connection terminated on socket", socket)); |
183 |
hSessions.erase(iter); |
Sessions.erase(iter); |
184 |
FD_CLR(socket, &fdSet); |
FD_CLR(socket, &fdSet); |
185 |
SubscriptionMutex.Lock(); //Must unsubscribe this socket from all events (if any) |
SubscriptionMutex.Lock(); //Must unsubscribe this socket from all events (if any) |
186 |
for (std::map< LSCPEvent::event_t, std::list<int> >::iterator iter = eventSubscriptions.begin(); iter != eventSubscriptions.end(); iter++) { |
for (std::map< LSCPEvent::event_t, std::list<int> >::iterator iter = eventSubscriptions.begin(); iter != eventSubscriptions.end(); iter++) { |
244 |
* If command is read, it will return true. Otherwise false is returned. |
* If command is read, it will return true. Otherwise false is returned. |
245 |
* In any case the received portion (complete or incomplete) is saved into bufferedCommand map. |
* In any case the received portion (complete or incomplete) is saved into bufferedCommand map. |
246 |
*/ |
*/ |
247 |
bool LSCPServer::GetLSCPCommand( std::vector<int>::iterator iter ) { |
bool LSCPServer::GetLSCPCommand( std::vector<yyparse_param_t>::iterator iter ) { |
248 |
int socket = *iter; |
int socket = (*iter).hSession; |
249 |
char c; |
char c; |
250 |
int i = 0; |
int i = 0; |
251 |
while (true) { |
while (true) { |
471 |
} |
} |
472 |
|
|
473 |
/** |
/** |
474 |
|
* Will be called by the parser to get the list of sampler channels. |
475 |
|
*/ |
476 |
|
String LSCPServer::ListChannels() { |
477 |
|
dmsg(2,("LSCPServer: ListChannels()\n")); |
478 |
|
String list; |
479 |
|
std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels(); |
480 |
|
std::map<uint,SamplerChannel*>::iterator iter = channels.begin(); |
481 |
|
for (; iter != channels.end(); iter++) { |
482 |
|
if (list != "") list += ","; |
483 |
|
list += ToString(iter->first); |
484 |
|
} |
485 |
|
LSCPResultSet result; |
486 |
|
result.Add(list); |
487 |
|
return result.Produce(); |
488 |
|
} |
489 |
|
|
490 |
|
/** |
491 |
* Will be called by the parser to add a sampler channel. |
* Will be called by the parser to add a sampler channel. |
492 |
*/ |
*/ |
493 |
String LSCPServer::AddChannel() { |
String LSCPServer::AddChannel() { |
741 |
DeviceCreationParameter* pParameter = MidiInputDeviceFactory::GetDriverParameter(Driver, Parameter); |
DeviceCreationParameter* pParameter = MidiInputDeviceFactory::GetDriverParameter(Driver, Parameter); |
742 |
result.Add("TYPE", pParameter->Type()); |
result.Add("TYPE", pParameter->Type()); |
743 |
result.Add("DESCRIPTION", pParameter->Description()); |
result.Add("DESCRIPTION", pParameter->Description()); |
744 |
result.Add("MANDATORY", pParameter->Mandatory()); |
result.Add("MANDATORY", (pParameter->Mandatory()) ? "true" : "false"); |
745 |
result.Add("FIX", pParameter->Fix()); |
result.Add("FIX", (pParameter->Fix()) ? "true" : "false"); |
746 |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
result.Add("MULTIPLICITY", (pParameter->Multiplicity()) ? "true" : "false"); |
747 |
if (pParameter->Depends()) result.Add("DEPENDS", pParameter->Depends()); |
if (pParameter->Depends()) result.Add("DEPENDS", *pParameter->Depends()); |
748 |
if (pParameter->Default()) result.Add("DEFAULT", pParameter->Default()); |
if (pParameter->Default()) result.Add("DEFAULT", *pParameter->Default()); |
749 |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", pParameter->RangeMin()); |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", *pParameter->RangeMin()); |
750 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", pParameter->RangeMax()); |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
751 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities()); |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
752 |
} |
} |
753 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
754 |
result.Error(e); |
result.Error(e); |
763 |
DeviceCreationParameter* pParameter = AudioOutputDeviceFactory::GetDriverParameter(Driver, Parameter); |
DeviceCreationParameter* pParameter = AudioOutputDeviceFactory::GetDriverParameter(Driver, Parameter); |
764 |
result.Add("TYPE", pParameter->Type()); |
result.Add("TYPE", pParameter->Type()); |
765 |
result.Add("DESCRIPTION", pParameter->Description()); |
result.Add("DESCRIPTION", pParameter->Description()); |
766 |
result.Add("MANDATORY", pParameter->Mandatory()); |
result.Add("MANDATORY", (pParameter->Mandatory()) ? "true" : "false"); |
767 |
result.Add("FIX", pParameter->Fix()); |
result.Add("FIX", (pParameter->Fix()) ? "true" : "false"); |
768 |
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
result.Add("MULTIPLICITY", (pParameter->Multiplicity()) ? "true" : "false"); |
769 |
if (pParameter->Depends()) result.Add("DEPENDS", pParameter->Depends()); |
if (pParameter->Depends()) result.Add("DEPENDS", *pParameter->Depends()); |
770 |
if (pParameter->Default()) result.Add("DEFAULT", pParameter->Default()); |
if (pParameter->Default()) result.Add("DEFAULT", *pParameter->Default()); |
771 |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", pParameter->RangeMin()); |
if (pParameter->RangeMin()) result.Add("RANGE_MIN", *pParameter->RangeMin()); |
772 |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", pParameter->RangeMax()); |
if (pParameter->RangeMax()) result.Add("RANGE_MAX", *pParameter->RangeMax()); |
773 |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities()); |
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities()); |
774 |
} |
} |
775 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
776 |
result.Error(e); |
result.Error(e); |
849 |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
850 |
if (!devices[DeviceIndex]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
if (!devices[DeviceIndex]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + "."); |
851 |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
AudioOutputDevice* pDevice = devices[DeviceIndex]; |
852 |
result.Add("driver", pDevice->Driver()); |
result.Add("DRIVER", pDevice->Driver()); |
853 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
854 |
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
855 |
for (; iter != parameters.end(); iter++) { |
for (; iter != parameters.end(); iter++) { |
869 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
870 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
871 |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
872 |
result.Add("driver", pDevice->Driver()); |
result.Add("DRIVER", pDevice->Driver()); |
873 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
874 |
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
875 |
for (; iter != parameters.end(); iter++) { |
for (; iter != parameters.end(); iter++) { |
888 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
889 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
890 |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
891 |
MidiInputDevice::MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
892 |
if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
893 |
std::map<String,DeviceCreationParameter*> parameters = pMidiInputPort->DeviceParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
894 |
std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin(); |
std::map<String,DeviceRuntimeParameter*>::iterator iter = parameters.begin(); |
895 |
for (; iter != parameters.end(); iter++) { |
for (; iter != parameters.end(); iter++) { |
896 |
result.Add(iter->first, iter->second->Value()); |
result.Add(iter->first, iter->second->Value()); |
897 |
} |
} |
937 |
if (!devices[DeviceId]) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceId) + "."); |
if (!devices[DeviceId]) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceId) + "."); |
938 |
MidiInputDevice* pDevice = devices[DeviceId]; |
MidiInputDevice* pDevice = devices[DeviceId]; |
939 |
|
|
940 |
// get midi port |
// get midi port |
941 |
MidiInputDevice::MidiInputPort* pPort = pDevice->GetPort(PortId); |
MidiInputPort* pPort = pDevice->GetPort(PortId); |
942 |
if (!pPort) throw LinuxSamplerException("Midi input device does not have port " + ToString(PortId) + "."); |
if (!pPort) throw LinuxSamplerException("Midi input device does not have port " + ToString(PortId) + "."); |
943 |
|
|
944 |
// get desired port parameter |
// get desired port parameter |
945 |
std::map<String,DeviceCreationParameter*> parameters = pPort->DeviceParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pPort->PortParameters(); |
946 |
if (!parameters[ParameterName]) throw LinuxSamplerException("Midi port does not provice a parameters '" + ParameterName + "'."); |
if (!parameters[ParameterName]) throw LinuxSamplerException("Midi port does not provice a parameters '" + ParameterName + "'."); |
947 |
DeviceCreationParameter* pParameter = parameters[ParameterName]; |
DeviceRuntimeParameter* pParameter = parameters[ParameterName]; |
948 |
|
|
949 |
// return all fields of this audio channel parameter |
// return all fields of this audio channel parameter |
950 |
result.Add("TYPE", pParameter->Type()); |
result.Add("TYPE", pParameter->Type()); |
1062 |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1063 |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
MidiInputDevice* pDevice = devices[DeviceIndex]; |
1064 |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + "."); |
1065 |
MidiInputDevice::MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex); |
1066 |
if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + "."); |
1067 |
std::map<String,DeviceCreationParameter*> parameters = pMidiInputPort->DeviceParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
1068 |
if (!parameters[ParamKey]) throw LinuxSamplerException("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'"); |
if (!parameters[ParamKey]) throw LinuxSamplerException("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'"); |
1069 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1070 |
} |
} |
1157 |
try { |
try { |
1158 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1159 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1160 |
pSamplerChannel->SetMidiInputChannel((MidiInputDevice::MidiInputPort::midi_chan_t) MIDIChannel); |
pSamplerChannel->SetMidiInputChannel((MidiInputPort::midi_chan_t) MIDIChannel); |
1161 |
} |
} |
1162 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1163 |
result.Error(e); |
result.Error(e); |
1207 |
pDevice = pSampler->CreateMidiInputDevice(MidiInputDriver, params); |
pDevice = pSampler->CreateMidiInputDevice(MidiInputDriver, params); |
1208 |
// Make it with at least one initial port. |
// Make it with at least one initial port. |
1209 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1210 |
parameters["ports"]->SetValue("1"); |
parameters["PORTS"]->SetValue("1"); |
1211 |
} |
} |
1212 |
// Must have a device... |
// Must have a device... |
1213 |
if (pDevice == NULL) |
if (pDevice == NULL) |
1234 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1235 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1236 |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1237 |
pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (MidiInputDevice::MidiInputPort::midi_chan_t) MIDIChannel); |
pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (MidiInputPort::midi_chan_t) MIDIChannel); |
1238 |
} |
} |
1239 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1240 |
result.Error(e); |
result.Error(e); |
1282 |
} |
} |
1283 |
|
|
1284 |
/** |
/** |
1285 |
|
* Will be called by the parser to reset the whole sampler. |
1286 |
|
*/ |
1287 |
|
String LSCPServer::ResetSampler() { |
1288 |
|
dmsg(2,("LSCPServer: ResetSampler()\n")); |
1289 |
|
pSampler->Reset(); |
1290 |
|
LSCPResultSet result; |
1291 |
|
return result.Produce(); |
1292 |
|
} |
1293 |
|
|
1294 |
|
/** |
1295 |
* Will be called by the parser to subscribe a client (frontend) on the |
* Will be called by the parser to subscribe a client (frontend) on the |
1296 |
* server for receiving event messages. |
* server for receiving event messages. |
1297 |
*/ |
*/ |
1317 |
return result.Produce(); |
return result.Produce(); |
1318 |
} |
} |
1319 |
|
|
1320 |
|
/** |
1321 |
|
* Will be called by the parser to enable or disable echo mode; if echo |
1322 |
|
* mode is enabled, all commands from the client will (immediately) be |
1323 |
|
* echoed back to the client. |
1324 |
|
*/ |
1325 |
|
String LSCPServer::SetEcho(yyparse_param_t* pSession, double boolean_value) { |
1326 |
|
dmsg(2,("LSCPServer: SetEcho(val=%f)\n", boolean_value)); |
1327 |
|
LSCPResultSet result; |
1328 |
|
try { |
1329 |
|
if (boolean_value == 0) pSession->bVerbose = false; |
1330 |
|
else if (boolean_value == 1) pSession->bVerbose = true; |
1331 |
|
else throw LinuxSamplerException("Not a boolean value, must either be 0 or 1"); |
1332 |
|
} |
1333 |
|
catch (LinuxSamplerException e) { |
1334 |
|
result.Error(e); |
1335 |
|
} |
1336 |
|
return result.Produce(); |
1337 |
|
} |
1338 |
|
|
1339 |
// Instrument loader constructor. |
// Instrument loader constructor. |
1340 |
LSCPLoadInstrument::LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument) |
LSCPLoadInstrument::LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument) |