86 |
// now wait for client connections and handle their requests |
// now wait for client connections and handle their requests |
87 |
sockaddr_in client; |
sockaddr_in client; |
88 |
int length = sizeof(client); |
int length = sizeof(client); |
|
struct timeval tv; |
|
|
tv.tv_sec = 30; |
|
|
tv.tv_usec = 0; |
|
89 |
FD_ZERO(&fdSet); |
FD_ZERO(&fdSet); |
90 |
FD_SET(hSocket, &fdSet); |
FD_SET(hSocket, &fdSet); |
91 |
int maxSessions = hSocket; |
int maxSessions = hSocket; |
96 |
|
|
97 |
while (true) { |
while (true) { |
98 |
fd_set selectSet = fdSet; |
fd_set selectSet = fdSet; |
99 |
int retval = select(maxSessions+1, &selectSet, NULL, NULL, &tv); |
int retval = select(maxSessions+1, &selectSet, NULL, NULL, NULL); |
100 |
if (retval == 0) |
if (retval == 0) |
101 |
continue; //Nothing in 30 seconds, try again |
continue; //Nothing try again |
102 |
if (retval == -1) { |
if (retval == -1) { |
103 |
std::cerr << "LSCPServer: Socket select error." << std::endl; |
std::cerr << "LSCPServer: Socket select error." << std::endl; |
104 |
close(hSocket); |
close(hSocket); |
890 |
} |
} |
891 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
892 |
result.Error(e); |
result.Error(e); |
893 |
|
} |
894 |
|
return result.Produce(); |
895 |
|
} |
896 |
|
|
897 |
|
String LSCPServer::GetMidiInputPortParameterInfo(uint DeviceId, uint PortId, String ParameterName) { |
898 |
|
dmsg(2,("LSCPServer: GetMidiInputPortParameterInfo(DeviceId=%d,PortId=%d,ParameterName=%s)\n",DeviceId,PortId,ParameterName.c_str())); |
899 |
|
LSCPResultSet result; |
900 |
|
try { |
901 |
|
// get audio output device |
902 |
|
std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
903 |
|
if (!devices[DeviceId]) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceId) + "."); |
904 |
|
MidiInputDevice* pDevice = devices[DeviceId]; |
905 |
|
|
906 |
|
// get midi port |
907 |
|
MidiInputDevice::MidiInputPort* pPort = pDevice->GetPort(PortId); |
908 |
|
if (!pPort) throw LinuxSamplerException("Midi input device does not have port " + ToString(PortId) + "."); |
909 |
|
|
910 |
|
// get desired port parameter |
911 |
|
std::map<String,DeviceCreationParameter*> parameters = pPort->DeviceParameters(); |
912 |
|
if (!parameters[ParameterName]) throw LinuxSamplerException("Midi port does not provice a parameters '" + ParameterName + "'."); |
913 |
|
DeviceCreationParameter* pParameter = parameters[ParameterName]; |
914 |
|
|
915 |
|
// return all fields of this audio channel parameter |
916 |
|
result.Add("TYPE", pParameter->Type()); |
917 |
|
result.Add("DESCRIPTION", pParameter->Description()); |
918 |
|
result.Add("FIX", pParameter->Fix()); |
919 |
|
result.Add("MULTIPLICITY", pParameter->Multiplicity()); |
920 |
|
if (pParameter->RangeMin()) result.Add("RANGE_MIN", pParameter->RangeMin()); |
921 |
|
if (pParameter->RangeMax()) result.Add("RANGE_MAX", pParameter->RangeMax()); |
922 |
|
if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities()); |
923 |
|
} |
924 |
|
catch (LinuxSamplerException e) { |
925 |
|
result.Error(e); |
926 |
} |
} |
927 |
return result.Produce(); |
return result.Produce(); |
928 |
} |
} |