25 |
#include "lscpevent.h" |
#include "lscpevent.h" |
26 |
|
|
27 |
#include "../engines/gig/Engine.h" |
#include "../engines/gig/Engine.h" |
28 |
#include "../audiodriver/AudioOutputDeviceFactory.h" |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
29 |
#include "../mididriver/MidiInputDeviceFactory.h" |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
30 |
|
|
31 |
/** |
/** |
32 |
* Below are a few static members of the LSCPServer class. |
* Below are a few static members of the LSCPServer class. |
89 |
FD_ZERO(&fdSet); |
FD_ZERO(&fdSet); |
90 |
FD_SET(hSocket, &fdSet); |
FD_SET(hSocket, &fdSet); |
91 |
int maxSessions = hSocket; |
int maxSessions = hSocket; |
92 |
|
|
93 |
// Parser initialization |
// Parser initialization |
94 |
yyparse_param_t yyparse_param; |
yyparse_param_t yyparse_param; |
95 |
yyparse_param.pServer = this; |
yyparse_param.pServer = this; |
104 |
close(hSocket); |
close(hSocket); |
105 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
106 |
} |
} |
107 |
|
|
108 |
//Accept new connections now (if any) |
//Accept new connections now (if any) |
109 |
if (FD_ISSET(hSocket, &selectSet)) { |
if (FD_ISSET(hSocket, &selectSet)) { |
110 |
int socket = accept(hSocket, (sockaddr*) &client, (socklen_t*) &length); |
int socket = accept(hSocket, (sockaddr*) &client, (socklen_t*) &length); |
143 |
} |
} |
144 |
//socket may have been closed, iter may be invalid, get out of the loop for now. |
//socket may have been closed, iter may be invalid, get out of the loop for now. |
145 |
//we'll be back if there is data. |
//we'll be back if there is data. |
146 |
break; |
break; |
147 |
} |
} |
148 |
} |
} |
149 |
|
|
238 |
break; |
break; |
239 |
} |
} |
240 |
if (result == 1) { |
if (result == 1) { |
241 |
if (c == '\r') |
if (c == '\r') |
242 |
continue; //Ignore CR |
continue; //Ignore CR |
243 |
if (c == '\n') { |
if (c == '\n') { |
244 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket)); |
265 |
break; |
break; |
266 |
case EAGAIN: |
case EAGAIN: |
267 |
dmsg(2,("LSCPScanner: The socket is marked non-blocking and the receive operation would block, or a receive timeout had been set and the timeout expired before data was received.\n")); |
dmsg(2,("LSCPScanner: The socket is marked non-blocking and the receive operation would block, or a receive timeout had been set and the timeout expired before data was received.\n")); |
268 |
break; |
break; |
269 |
case EINTR: |
case EINTR: |
270 |
dmsg(2,("LSCPScanner: The receive was interrupted by delivery of a signal before any data were available.\n")); |
dmsg(2,("LSCPScanner: The receive was interrupted by delivery of a signal before any data were available.\n")); |
271 |
break; |
break; |
272 |
case EFAULT: |
case EFAULT: |
273 |
dmsg(2,("LSCPScanner: The receive buffer pointer(s) point outside the process's address space.\n")); |
dmsg(2,("LSCPScanner: The receive buffer pointer(s) point outside the process's address space.\n")); |
274 |
break; |
break; |
275 |
case EINVAL: |
case EINVAL: |
276 |
dmsg(2,("LSCPScanner: Invalid argument passed.\n")); |
dmsg(2,("LSCPScanner: Invalid argument passed.\n")); |
277 |
break; |
break; |
278 |
case ENOMEM: |
case ENOMEM: |
279 |
dmsg(2,("LSCPScanner: Could not allocate memory for recvmsg.\n")); |
dmsg(2,("LSCPScanner: Could not allocate memory for recvmsg.\n")); |
280 |
break; |
break; |
281 |
default: |
default: |
282 |
dmsg(2,("LSCPScanner: Unknown recv() error.\n")); |
dmsg(2,("LSCPScanner: Unknown recv() error.\n")); |
283 |
break; |
break; |
284 |
} |
} |
285 |
CloseConnection(iter); |
CloseConnection(iter); |
286 |
break; |
break; |
287 |
} |
} |
454 |
} |
} |
455 |
|
|
456 |
/** |
/** |
457 |
|
* Will be called by the parser to get the list of sampler channels. |
458 |
|
*/ |
459 |
|
String LSCPServer::ListChannels() { |
460 |
|
dmsg(2,("LSCPServer: ListChannels()\n")); |
461 |
|
String list; |
462 |
|
std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels(); |
463 |
|
std::map<uint,SamplerChannel*>::iterator iter = channels.begin(); |
464 |
|
for (; iter != channels.end(); iter++) { |
465 |
|
if (list != "") list += ","; |
466 |
|
list += ToString(iter->first); |
467 |
|
} |
468 |
|
LSCPResultSet result; |
469 |
|
result.Add(list); |
470 |
|
return result.Produce(); |
471 |
|
} |
472 |
|
|
473 |
|
/** |
474 |
* Will be called by the parser to add a sampler channel. |
* Will be called by the parser to add a sampler channel. |
475 |
*/ |
*/ |
476 |
String LSCPServer::AddChannel() { |
String LSCPServer::AddChannel() { |
928 |
std::map<String,DeviceCreationParameter*> parameters = pPort->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pPort->DeviceParameters(); |
929 |
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 + "'."); |
930 |
DeviceCreationParameter* pParameter = parameters[ParameterName]; |
DeviceCreationParameter* pParameter = parameters[ParameterName]; |
931 |
|
|
932 |
// return all fields of this audio channel parameter |
// return all fields of this audio channel parameter |
933 |
result.Add("TYPE", pParameter->Type()); |
result.Add("TYPE", pParameter->Type()); |
934 |
result.Add("DESCRIPTION", pParameter->Description()); |
result.Add("DESCRIPTION", pParameter->Description()); |
1091 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
1092 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1093 |
if (AudioOutputDriver == "ALSA") AudioOutputDriver = "Alsa"; |
if (AudioOutputDriver == "ALSA") AudioOutputDriver = "Alsa"; |
1094 |
if (AudioOutputDriver == "JACK") AudioOutputDriver = "Jack"; |
if (AudioOutputDriver == "JACK") AudioOutputDriver = "Jack"; |
1095 |
// Check if there's one audio output device already created |
// Check if there's one audio output device already created |
1096 |
// for the intended audio driver type (AudioOutputDriver)... |
// for the intended audio driver type (AudioOutputDriver)... |
1097 |
AudioOutputDevice *pDevice = NULL; |
AudioOutputDevice *pDevice = NULL; |