/[svn]/linuxsampler/trunk/src/network/lscpserver.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/network/lscpserver.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 212 by schoenebeck, Wed Jul 28 14:17:29 2004 UTC revision 221 by schoenebeck, Fri Aug 20 17:25:19 2004 UTC
# Line 147  int LSCPServer::Main() { Line 147  int LSCPServer::Main() {
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]);
# Line 173  int LSCPServer::Main() { Line 174  int LSCPServer::Main() {
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 ) {
# Line 193  void LSCPServer::CloseConnection( std::v Line 192  void LSCPServer::CloseConnection( std::v
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 ) {
# Line 851  String LSCPServer::GetAudioOutputDeviceI Line 849  String LSCPServer::GetAudioOutputDeviceI
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++) {
# Line 871  String LSCPServer::GetMidiInputDeviceInf Line 869  String LSCPServer::GetMidiInputDeviceInf
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++) {
# Line 890  String LSCPServer::GetMidiInputPortInfo( Line 888  String LSCPServer::GetMidiInputPortInfo(
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          }          }
# Line 939  String LSCPServer::GetMidiInputPortParam Line 937  String LSCPServer::GetMidiInputPortParam
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());
# Line 1064  String LSCPServer::SetMidiInputPortParam Line 1062  String LSCPServer::SetMidiInputPortParam
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      }      }
# Line 1159  String LSCPServer::SetMIDIInputChannel(u Line 1157  String LSCPServer::SetMIDIInputChannel(u
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);
# Line 1209  String LSCPServer::SetMIDIInputType(Stri Line 1207  String LSCPServer::SetMIDIInputType(Stri
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)
# Line 1236  String LSCPServer::SetMIDIInput(uint MID Line 1234  String LSCPServer::SetMIDIInput(uint MID
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);

Legend:
Removed from v.212  
changed lines
  Added in v.221

  ViewVC Help
Powered by ViewVC