--- linuxsampler/trunk/src/network/lscpserver.cpp 2004/07/07 02:00:37 184 +++ linuxsampler/trunk/src/network/lscpserver.cpp 2004/07/13 22:44:13 203 @@ -25,8 +25,8 @@ #include "lscpevent.h" #include "../engines/gig/Engine.h" -#include "../audiodriver/AudioOutputDeviceFactory.h" -#include "../mididriver/MidiInputDeviceFactory.h" +#include "../drivers/audio/AudioOutputDeviceFactory.h" +#include "../drivers/midi/MidiInputDeviceFactory.h" /** * Below are a few static members of the LSCPServer class. @@ -86,28 +86,25 @@ // now wait for client connections and handle their requests sockaddr_in client; int length = sizeof(client); - struct timeval tv; - tv.tv_sec = 30; - tv.tv_usec = 0; FD_ZERO(&fdSet); FD_SET(hSocket, &fdSet); int maxSessions = hSocket; - + // Parser initialization yyparse_param_t yyparse_param; yyparse_param.pServer = this; while (true) { fd_set selectSet = fdSet; - int retval = select(maxSessions+1, &selectSet, NULL, NULL, &tv); + int retval = select(maxSessions+1, &selectSet, NULL, NULL, NULL); if (retval == 0) - continue; //Nothing in 30 seconds, try again + continue; //Nothing try again if (retval == -1) { std::cerr << "LSCPServer: Socket select error." << std::endl; close(hSocket); exit(EXIT_FAILURE); } - + //Accept new connections now (if any) if (FD_ISSET(hSocket, &selectSet)) { int socket = accept(hSocket, (sockaddr*) &client, (socklen_t*) &length); @@ -146,7 +143,7 @@ } //socket may have been closed, iter may be invalid, get out of the loop for now. //we'll be back if there is data. - break; + break; } } @@ -241,7 +238,7 @@ break; } if (result == 1) { - if (c == '\r') + if (c == '\r') continue; //Ignore CR if (c == '\n') { LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket)); @@ -268,23 +265,23 @@ break; case EAGAIN: 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")); - break; - case EINTR: + break; + case EINTR: dmsg(2,("LSCPScanner: The receive was interrupted by delivery of a signal before any data were available.\n")); - break; - case EFAULT: - dmsg(2,("LSCPScanner: The receive buffer pointer(s) point outside the process's address space.\n")); - break; - case EINVAL: - dmsg(2,("LSCPScanner: Invalid argument passed.\n")); - break; - case ENOMEM: - dmsg(2,("LSCPScanner: Could not allocate memory for recvmsg.\n")); - break; - default: - dmsg(2,("LSCPScanner: Unknown recv() error.\n")); - break; - } + break; + case EFAULT: + dmsg(2,("LSCPScanner: The receive buffer pointer(s) point outside the process's address space.\n")); + break; + case EINVAL: + dmsg(2,("LSCPScanner: Invalid argument passed.\n")); + break; + case ENOMEM: + dmsg(2,("LSCPScanner: Could not allocate memory for recvmsg.\n")); + break; + default: + dmsg(2,("LSCPScanner: Unknown recv() error.\n")); + break; + } CloseConnection(iter); break; } @@ -897,6 +894,39 @@ return result.Produce(); } +String LSCPServer::GetMidiInputPortParameterInfo(uint DeviceId, uint PortId, String ParameterName) { + dmsg(2,("LSCPServer: GetMidiInputPortParameterInfo(DeviceId=%d,PortId=%d,ParameterName=%s)\n",DeviceId,PortId,ParameterName.c_str())); + LSCPResultSet result; + try { + // get audio output device + std::map devices = pSampler->GetMidiInputDevices(); + if (!devices[DeviceId]) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceId) + "."); + MidiInputDevice* pDevice = devices[DeviceId]; + + // get midi port + MidiInputDevice::MidiInputPort* pPort = pDevice->GetPort(PortId); + if (!pPort) throw LinuxSamplerException("Midi input device does not have port " + ToString(PortId) + "."); + + // get desired port parameter + std::map parameters = pPort->DeviceParameters(); + if (!parameters[ParameterName]) throw LinuxSamplerException("Midi port does not provice a parameters '" + ParameterName + "'."); + DeviceCreationParameter* pParameter = parameters[ParameterName]; + + // return all fields of this audio channel parameter + result.Add("TYPE", pParameter->Type()); + result.Add("DESCRIPTION", pParameter->Description()); + result.Add("FIX", pParameter->Fix()); + result.Add("MULTIPLICITY", pParameter->Multiplicity()); + if (pParameter->RangeMin()) result.Add("RANGE_MIN", pParameter->RangeMin()); + if (pParameter->RangeMax()) result.Add("RANGE_MAX", pParameter->RangeMax()); + if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities()); + } + catch (LinuxSamplerException e) { + result.Error(e); + } + return result.Produce(); +} + String LSCPServer::GetAudioOutputChannelParameterInfo(uint DeviceId, uint ChannelId, String ParameterName) { dmsg(2,("LSCPServer: GetAudioOutputChannelParameterInfo(DeviceId=%d,ChannelId=%d,ParameterName=%s)\n",DeviceId,ChannelId,ParameterName.c_str())); LSCPResultSet result; @@ -1044,7 +1074,7 @@ if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); // Driver type name aliasing... if (AudioOutputDriver == "ALSA") AudioOutputDriver = "Alsa"; - if (AudioOutputDriver == "JACK") AudioOutputDriver = "Jack"; + if (AudioOutputDriver == "JACK") AudioOutputDriver = "Jack"; // Check if there's one audio output device already created // for the intended audio driver type (AudioOutputDriver)... AudioOutputDevice *pDevice = NULL;