147 |
if (FD_ISSET((*iter).hSession, &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(&((*iter).pScanner)); //FIXME: should me moved out of this loop and initialized only when a new session is created |
int dummy; // just a temporary hack to fulfill the restart() function prototype |
151 |
|
restart(NULL, dummy); // restart the 'scanner' |
152 |
currentSocket = (*iter).hSession; //a hack |
currentSocket = (*iter).hSession; //a hack |
153 |
if ((*iter).bVerbose) { // if echo mode enabled |
if ((*iter).bVerbose) { // if echo mode enabled |
154 |
AnswerClient(bufferedCommands[currentSocket]); |
AnswerClient(bufferedCommands[currentSocket]); |
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<yyparse_param_t>::iterator iter ) { |
void LSCPServer::CloseConnection( std::vector<yyparse_param_t>::iterator iter ) { |
192 |
bufferedNotifies.erase(socket); |
bufferedNotifies.erase(socket); |
193 |
close(socket); |
close(socket); |
194 |
NotifyMutex.Unlock(); |
NotifyMutex.Unlock(); |
|
//yylex_destroy((*iter).pScanner); |
|
195 |
} |
} |
196 |
|
|
197 |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
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); |