/[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 209 by schoenebeck, Sun Jul 18 00:29:39 2004 UTC revision 225 by schoenebeck, Sun Aug 22 14:46:47 2004 UTC
# Line 43  Line 43 
43   */   */
44  fd_set LSCPServer::fdSet;  fd_set LSCPServer::fdSet;
45  int LSCPServer::currentSocket = -1;  int LSCPServer::currentSocket = -1;
46  std::vector<int> LSCPServer::hSessions = std::vector<int>();  std::vector<yyparse_param_t> LSCPServer::Sessions = std::vector<yyparse_param_t>();
47  std::map<int,String> LSCPServer::bufferedNotifies = std::map<int,String>();  std::map<int,String> LSCPServer::bufferedNotifies = std::map<int,String>();
48  std::map<int,String> LSCPServer::bufferedCommands = std::map<int,String>();  std::map<int,String> LSCPServer::bufferedCommands = std::map<int,String>();
49  std::map< LSCPEvent::event_t, std::list<int> > LSCPServer::eventSubscriptions = std::map< LSCPEvent::event_t, std::list<int> >();  std::map< LSCPEvent::event_t, std::list<int> > LSCPServer::eventSubscriptions = std::map< LSCPEvent::event_t, std::list<int> >();
# Line 61  LSCPServer::LSCPServer(Sampler* pSampler Line 61  LSCPServer::LSCPServer(Sampler* pSampler
61      LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS");      LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS");
62  }  }
63    
64    /**
65     * Blocks the calling thread until the LSCP Server is initialized and
66     * accepting socket connections, if the server is already initialized then
67     * this method will return immediately.
68     * @param TimeoutSeconds     - optional: max. wait time in seconds
69     *                             (default: 0s)
70     * @param TimeoutNanoSeconds - optional: max wait time in nano seconds
71     *                             (default: 0ns)
72     * @returns  0 on success, a value less than 0 if timeout exceeded
73     */
74    int LSCPServer::WaitUntilInitialized(long TimeoutSeconds, long TimeoutNanoSeconds) {
75        return Initialized.WaitAndUnlockIf(false, TimeoutSeconds, TimeoutNanoSeconds);
76    }
77    
78  int LSCPServer::Main() {  int LSCPServer::Main() {
79      int hSocket = socket(AF_INET, SOCK_STREAM, 0);      int hSocket = socket(AF_INET, SOCK_STREAM, 0);
80      if (hSocket < 0) {      if (hSocket < 0) {
# Line 81  int LSCPServer::Main() { Line 95  int LSCPServer::Main() {
95      }      }
96    
97      listen(hSocket, 1);      listen(hSocket, 1);
98      dmsg(1,("LSCPServer: Server running.\n")); // server running      Initialized.Set(true);
99    
100      // now wait for client connections and handle their requests      // now wait for client connections and handle their requests
101      sockaddr_in client;      sockaddr_in client;
# Line 90  int LSCPServer::Main() { Line 104  int LSCPServer::Main() {
104      FD_SET(hSocket, &fdSet);      FD_SET(hSocket, &fdSet);
105      int maxSessions = hSocket;      int maxSessions = hSocket;
106    
     // Parser initialization  
     yyparse_param_t yyparse_param;  
     yyparse_param.pServer = this;  
   
107      while (true) {      while (true) {
108          fd_set selectSet = fdSet;          fd_set selectSet = fdSet;
109          int retval = select(maxSessions+1, &selectSet, NULL, NULL, NULL);          int retval = select(maxSessions+1, &selectSet, NULL, NULL, NULL);
# Line 118  int LSCPServer::Main() { Line 128  int LSCPServer::Main() {
128                          exit(EXIT_FAILURE);                          exit(EXIT_FAILURE);
129                  }                  }
130    
131                  hSessions.push_back(socket);                  // Parser initialization
132                    yyparse_param_t yyparse_param;
133                    yyparse_param.pServer  = this;
134                    yyparse_param.hSession = socket;
135    
136                    Sessions.push_back(yyparse_param);
137                  FD_SET(socket, &fdSet);                  FD_SET(socket, &fdSet);
138                  if (socket > maxSessions)                  if (socket > maxSessions)
139                          maxSessions = socket;                          maxSessions = socket;
# Line 128  int LSCPServer::Main() { Line 143  int LSCPServer::Main() {
143          }          }
144    
145          //Something was selected and it was not the hSocket, so it must be some command(s) coming.          //Something was selected and it was not the hSocket, so it must be some command(s) coming.
146          for (std::vector<int>::iterator iter = hSessions.begin(); iter !=  hSessions.end(); iter++) {          for (std::vector<yyparse_param_t>::iterator iter = Sessions.begin(); iter != Sessions.end(); iter++) {
147                  if (FD_ISSET(*iter, &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(&yyparse_param.pScanner);                                  int dummy; // just a temporary hack to fulfill the restart() function prototype
151                                  currentSocket = *iter;  //a hack                                  restart(NULL, dummy); // restart the 'scanner'
152                                  int result = yyparse(&yyparse_param);                                  currentSocket = (*iter).hSession;  //a hack
153                                    if ((*iter).bVerbose) { // if echo mode enabled
154                                        AnswerClient(bufferedCommands[currentSocket]);
155                                    }
156                                    int result = yyparse(&(*iter));
157                                  currentSocket = -1;     //continuation of a hack                                  currentSocket = -1;     //continuation of a hack
158                                  dmsg(3,("LSCPServer: Done parsing on socket %d.\n", currentSocket));                                  dmsg(3,("LSCPServer: Done parsing on socket %d.\n", currentSocket));
159                                  if (result == LSCP_QUIT) { //Was it a quit command by any chance?                                  if (result == LSCP_QUIT) { //Was it a quit command by any chance?
# Line 155  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<int>::iterator iter ) {  void LSCPServer::CloseConnection( std::vector<yyparse_param_t>::iterator iter ) {
180          int socket = *iter;          int socket = (*iter).hSession;
181          dmsg(1,("LSCPServer: Client connection terminated on socket:%d.\n",socket));          dmsg(1,("LSCPServer: Client connection terminated on socket:%d.\n",socket));
182          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Client connection terminated on socket", socket));          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Client connection terminated on socket", socket));
183          hSessions.erase(iter);          Sessions.erase(iter);
184          FD_CLR(socket,  &fdSet);          FD_CLR(socket,  &fdSet);
185          SubscriptionMutex.Lock(); //Must unsubscribe this socket from all events (if any)          SubscriptionMutex.Lock(); //Must unsubscribe this socket from all events (if any)
186          for (std::map< LSCPEvent::event_t, std::list<int> >::iterator iter = eventSubscriptions.begin(); iter != eventSubscriptions.end(); iter++) {          for (std::map< LSCPEvent::event_t, std::list<int> >::iterator iter = eventSubscriptions.begin(); iter != eventSubscriptions.end(); iter++) {
# Line 227  extern int GetLSCPCommand( void *buf, in Line 244  extern int GetLSCPCommand( void *buf, in
244   * If command is read, it will return true. Otherwise false is returned.   * If command is read, it will return true. Otherwise false is returned.
245   * In any case the received portion (complete or incomplete) is saved into bufferedCommand map.   * In any case the received portion (complete or incomplete) is saved into bufferedCommand map.
246   */   */
247  bool LSCPServer::GetLSCPCommand( std::vector<int>::iterator iter ) {  bool LSCPServer::GetLSCPCommand( std::vector<yyparse_param_t>::iterator iter ) {
248          int socket = *iter;          int socket = (*iter).hSession;
249          char c;          char c;
250          int i = 0;          int i = 0;
251          while (true) {          while (true) {
# Line 373  String LSCPServer::DestroyAudioOutputDev Line 390  String LSCPServer::DestroyAudioOutputDev
390      LSCPResultSet result;      LSCPResultSet result;
391      try {      try {
392          std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
393          if (!devices[DeviceIndex]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");
394          AudioOutputDevice* pDevice = devices[DeviceIndex];          AudioOutputDevice* pDevice = devices[DeviceIndex];
395          pSampler->DestroyAudioOutputDevice(pDevice);          pSampler->DestroyAudioOutputDevice(pDevice);
396      }      }
# Line 388  String LSCPServer::DestroyMidiInputDevic Line 405  String LSCPServer::DestroyMidiInputDevic
405      LSCPResultSet result;      LSCPResultSet result;
406      try {      try {
407          std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
408            if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");
409          MidiInputDevice* pDevice = devices[DeviceIndex];          MidiInputDevice* pDevice = devices[DeviceIndex];
         if (!pDevice) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");  
410          pSampler->DestroyMidiInputDevice(pDevice);          pSampler->DestroyMidiInputDevice(pDevice);
411      }      }
412      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
# Line 409  String LSCPServer::LoadInstrument(String Line 426  String LSCPServer::LoadInstrument(String
426          if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds");          if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds");
427          Engine* pEngine = pSamplerChannel->GetEngine();          Engine* pEngine = pSamplerChannel->GetEngine();
428          if (!pEngine) throw LinuxSamplerException("No engine loaded on channel");          if (!pEngine) throw LinuxSamplerException("No engine loaded on channel");
429          if (pSamplerChannel->GetAudioOutputDevice() == NULL)          if (!pSamplerChannel->GetAudioOutputDevice())
430              throw LinuxSamplerException("No audio output device on channel");              throw LinuxSamplerException("No audio output device on channel");
431          if (bBackground) {          if (bBackground) {
432              LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument);              LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument);
# Line 508  String LSCPServer::GetEngineInfo(String Line 525  String LSCPServer::GetEngineInfo(String
525      try {      try {
526          if ((EngineName == "GigEngine") || (EngineName == "gig")) {          if ((EngineName == "GigEngine") || (EngineName == "gig")) {
527              Engine* pEngine = new LinuxSampler::gig::Engine;              Engine* pEngine = new LinuxSampler::gig::Engine;
528              result.Add(pEngine->Description());              result.Add("DESCRIPTION", pEngine->Description());
529              result.Add(pEngine->Version());              result.Add("VERSION",     pEngine->Version());
530              delete pEngine;              delete pEngine;
531          }          }
532          else throw LinuxSamplerException("Unknown engine type");          else throw LinuxSamplerException("Unknown engine type");
# Line 534  String LSCPServer::GetChannelInfo(uint u Line 551  String LSCPServer::GetChannelInfo(uint u
551    
552          //Defaults values          //Defaults values
553          String EngineName = "NONE";          String EngineName = "NONE";
554          float Volume = 0;          float Volume = 0.0f;
555          String InstrumentFileName = "NONE";          String InstrumentFileName = "NONE";
556          int InstrumentIndex = -1;          int InstrumentIndex = -1;
557          int InstrumentStatus = -1;          int InstrumentStatus = -1;
558            int AudioOutputChannels = 0;
559            String AudioRouting;
560    
561          if (pEngine) {          if (pEngine) {
562              EngineName =  pEngine->EngineName();              EngineName =  pEngine->EngineName();
563                AudioOutputChannels = pEngine->Channels();
564              Volume = pEngine->Volume();              Volume = pEngine->Volume();
565              InstrumentStatus = pEngine->InstrumentStatus();              InstrumentStatus = pEngine->InstrumentStatus();
566              InstrumentIndex = pEngine->InstrumentIndex();              InstrumentIndex = pEngine->InstrumentIndex();
567              if (InstrumentIndex != -1)              if (InstrumentIndex != -1)
568                  InstrumentFileName = pEngine->InstrumentFileName();                  InstrumentFileName = pEngine->InstrumentFileName();
569                for (int chan = 0; chan < pEngine->Channels(); chan++) {
570                    if (AudioRouting != "") AudioRouting += ",";
571                    AudioRouting += ToString(pEngine->OutputChannel(chan));
572                }
573          }          }
574    
575          result.Add("ENGINE_NAME", EngineName);          result.Add("ENGINE_NAME", EngineName);
# Line 553  String LSCPServer::GetChannelInfo(uint u Line 577  String LSCPServer::GetChannelInfo(uint u
577    
578          //Some not-so-hardcoded stuff to make GUI look good          //Some not-so-hardcoded stuff to make GUI look good
579          result.Add("AUDIO_OUTPUT_DEVICE", GetAudioOutputDeviceIndex(pSamplerChannel->GetAudioOutputDevice()));          result.Add("AUDIO_OUTPUT_DEVICE", GetAudioOutputDeviceIndex(pSamplerChannel->GetAudioOutputDevice()));
580          result.Add("AUDIO_OUTPUT_CHANNELS", "2");          result.Add("AUDIO_OUTPUT_CHANNELS", AudioOutputChannels);
581          result.Add("AUDIO_OUTPUT_ROUTING", "0,1");          result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting);
582    
583          result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice()));          result.Add("MIDI_INPUT_DEVICE", GetMidiInputDeviceIndex(pSamplerChannel->GetMidiInputDevice()));
584          result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort());          result.Add("MIDI_INPUT_PORT", pSamplerChannel->GetMidiInputPort());
585          result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel());          if (pSamplerChannel->GetMidiInputChannel()) result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel());
586            else                                        result.Add("MIDI_INPUT_CHANNEL", "ALL");
587    
588          result.Add("INSTRUMENT_FILE", InstrumentFileName);          result.Add("INSTRUMENT_FILE", InstrumentFileName);
589          result.Add("INSTRUMENT_NR", InstrumentIndex);          result.Add("INSTRUMENT_NR", InstrumentIndex);
# Line 727  String LSCPServer::GetMidiInputDriverPar Line 752  String LSCPServer::GetMidiInputDriverPar
752          result.Add("MANDATORY",    pParameter->Mandatory());          result.Add("MANDATORY",    pParameter->Mandatory());
753          result.Add("FIX",          pParameter->Fix());          result.Add("FIX",          pParameter->Fix());
754          result.Add("MULTIPLICITY", pParameter->Multiplicity());          result.Add("MULTIPLICITY", pParameter->Multiplicity());
755          if (pParameter->Depends())       result.Add("DEPENDS",       pParameter->Depends());          if (pParameter->Depends())       result.Add("DEPENDS",       *pParameter->Depends());
756          if (pParameter->Default())       result.Add("DEFAULT",       pParameter->Default());          if (pParameter->Default())       result.Add("DEFAULT",       *pParameter->Default());
757          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     pParameter->RangeMin());          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     *pParameter->RangeMin());
758          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     pParameter->RangeMax());          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     *pParameter->RangeMax());
759          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities());          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities());
760      }      }
761      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
762          result.Error(e);          result.Error(e);
# Line 749  String LSCPServer::GetAudioOutputDriverP Line 774  String LSCPServer::GetAudioOutputDriverP
774          result.Add("MANDATORY",    pParameter->Mandatory());          result.Add("MANDATORY",    pParameter->Mandatory());
775          result.Add("FIX",          pParameter->Fix());          result.Add("FIX",          pParameter->Fix());
776          result.Add("MULTIPLICITY", pParameter->Multiplicity());          result.Add("MULTIPLICITY", pParameter->Multiplicity());
777          if (pParameter->Depends())       result.Add("DEPENDS",       pParameter->Depends());          if (pParameter->Depends())       result.Add("DEPENDS",       *pParameter->Depends());
778          if (pParameter->Default())       result.Add("DEFAULT",       pParameter->Default());          if (pParameter->Default())       result.Add("DEFAULT",       *pParameter->Default());
779          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     pParameter->RangeMin());          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     *pParameter->RangeMin());
780          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     pParameter->RangeMax());          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     *pParameter->RangeMax());
781          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities());          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities());
782      }      }
783      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
784          result.Error(e);          result.Error(e);
# Line 830  String LSCPServer::GetAudioOutputDeviceI Line 855  String LSCPServer::GetAudioOutputDeviceI
855      LSCPResultSet result;      LSCPResultSet result;
856      try {      try {
857          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
858          if (!devices[DeviceIndex]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");
859          AudioOutputDevice* pDevice = devices[DeviceIndex];          AudioOutputDevice* pDevice = devices[DeviceIndex];
860          result.Add("driver", pDevice->Driver());          result.Add("DRIVER", pDevice->Driver());
861          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();
862          std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin();          std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin();
863          for (; iter != parameters.end(); iter++) {          for (; iter != parameters.end(); iter++) {
# Line 850  String LSCPServer::GetMidiInputDeviceInf Line 875  String LSCPServer::GetMidiInputDeviceInf
875      LSCPResultSet result;      LSCPResultSet result;
876      try {      try {
877          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
878            if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");
879          MidiInputDevice* pDevice = devices[DeviceIndex];          MidiInputDevice* pDevice = devices[DeviceIndex];
880          if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");          result.Add("DRIVER", pDevice->Driver());
         result.Add("driver", pDevice->Driver());  
881          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();
882          std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin();          std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin();
883          for (; iter != parameters.end(); iter++) {          for (; iter != parameters.end(); iter++) {
# Line 868  String LSCPServer::GetMidiInputPortInfo( Line 893  String LSCPServer::GetMidiInputPortInfo(
893      dmsg(2,("LSCPServer: GetMidiInputPortInfo(DeviceIndex=%d, PortIndex=%d)\n",DeviceIndex, PortIndex));      dmsg(2,("LSCPServer: GetMidiInputPortInfo(DeviceIndex=%d, PortIndex=%d)\n",DeviceIndex, PortIndex));
894      LSCPResultSet result;      LSCPResultSet result;
895      try {      try {
896            // get MIDI input device
897          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
898            if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");
899          MidiInputDevice* pDevice = devices[DeviceIndex];          MidiInputDevice* pDevice = devices[DeviceIndex];
900          if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");  
901          MidiInputDevice::MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex);          // get MIDI port
902          if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + ".");          MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex);
903          std::map<String,DeviceCreationParameter*> parameters = pMidiInputPort->DeviceParameters();          if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + ".");
904          std::map<String,DeviceCreationParameter*>::iterator iter = parameters.begin();  
905            // return the values of all MIDI port parameters
906            std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters();
907            std::map<String,DeviceRuntimeParameter*>::iterator iter = parameters.begin();
908          for (; iter != parameters.end(); iter++) {          for (; iter != parameters.end(); iter++) {
909              result.Add(iter->first, iter->second->Value());              result.Add(iter->first, iter->second->Value());
910          }          }
# Line 891  String LSCPServer::GetAudioOutputChannel Line 921  String LSCPServer::GetAudioOutputChannel
921      try {      try {
922          // get audio output device          // get audio output device
923          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
924          if (!devices[DeviceId]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + ".");          if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + ".");
925          AudioOutputDevice* pDevice = devices[DeviceId];          AudioOutputDevice* pDevice = devices[DeviceId];
926    
927          // get audio channel          // get audio channel
# Line 915  String LSCPServer::GetMidiInputPortParam Line 945  String LSCPServer::GetMidiInputPortParam
945      dmsg(2,("LSCPServer: GetMidiInputPortParameterInfo(DeviceId=%d,PortId=%d,ParameterName=%s)\n",DeviceId,PortId,ParameterName.c_str()));      dmsg(2,("LSCPServer: GetMidiInputPortParameterInfo(DeviceId=%d,PortId=%d,ParameterName=%s)\n",DeviceId,PortId,ParameterName.c_str()));
946      LSCPResultSet result;      LSCPResultSet result;
947      try {      try {
948          // get audio output device          // get MIDI input device
949          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
950          if (!devices[DeviceId]) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceId) + ".");          if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceId) + ".");
951          MidiInputDevice* pDevice = devices[DeviceId];          MidiInputDevice* pDevice = devices[DeviceId];
952    
953          // get midi port          // get midi port
954          MidiInputDevice::MidiInputPort* pPort = pDevice->GetPort(PortId);          MidiInputPort* pPort = pDevice->GetPort(PortId);
955          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) + ".");
956    
957          // get desired port parameter          // get desired port parameter
958          std::map<String,DeviceCreationParameter*> parameters = pPort->DeviceParameters();          std::map<String,DeviceRuntimeParameter*> parameters = pPort->PortParameters();
959          if (!parameters[ParameterName]) throw LinuxSamplerException("Midi port does not provice a parameters '" + ParameterName + "'.");          if (!parameters.count(ParameterName)) throw LinuxSamplerException("Midi port does not provide a parameter '" + ParameterName + "'.");
960          DeviceCreationParameter* pParameter = parameters[ParameterName];          DeviceRuntimeParameter* pParameter = parameters[ParameterName];
961    
962          // return all fields of this audio channel parameter          // return all fields of this audio channel parameter
963          result.Add("TYPE",         pParameter->Type());          result.Add("TYPE",         pParameter->Type());
964          result.Add("DESCRIPTION",  pParameter->Description());          result.Add("DESCRIPTION",  pParameter->Description());
965          result.Add("FIX",          pParameter->Fix());          result.Add("FIX",          pParameter->Fix());
966          result.Add("MULTIPLICITY", pParameter->Multiplicity());          result.Add("MULTIPLICITY", pParameter->Multiplicity());
967          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     pParameter->RangeMin());          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     *pParameter->RangeMin());
968          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     pParameter->RangeMax());          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     *pParameter->RangeMax());
969          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities());          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities());
970      }      }
971      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
972          result.Error(e);          result.Error(e);
# Line 950  String LSCPServer::GetAudioOutputChannel Line 980  String LSCPServer::GetAudioOutputChannel
980      try {      try {
981          // get audio output device          // get audio output device
982          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
983          if (!devices[DeviceId]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + ".");          if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + ".");
984          AudioOutputDevice* pDevice = devices[DeviceId];          AudioOutputDevice* pDevice = devices[DeviceId];
985    
986          // get audio channel          // get audio channel
# Line 959  String LSCPServer::GetAudioOutputChannel Line 989  String LSCPServer::GetAudioOutputChannel
989    
990          // get desired audio channel parameter          // get desired audio channel parameter
991          std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters();          std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters();
992          if (!parameters[ParameterName]) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParameterName + "'.");          if (!parameters.count(ParameterName)) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParameterName + "'.");
993          DeviceRuntimeParameter* pParameter = parameters[ParameterName];          DeviceRuntimeParameter* pParameter = parameters[ParameterName];
994    
995          // return all fields of this audio channel parameter          // return all fields of this audio channel parameter
# Line 967  String LSCPServer::GetAudioOutputChannel Line 997  String LSCPServer::GetAudioOutputChannel
997          result.Add("DESCRIPTION",  pParameter->Description());          result.Add("DESCRIPTION",  pParameter->Description());
998          result.Add("FIX",          pParameter->Fix());          result.Add("FIX",          pParameter->Fix());
999          result.Add("MULTIPLICITY", pParameter->Multiplicity());          result.Add("MULTIPLICITY", pParameter->Multiplicity());
1000          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     pParameter->RangeMin());          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     *pParameter->RangeMin());
1001          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     pParameter->RangeMax());          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     *pParameter->RangeMax());
1002          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities());          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities());
1003      }      }
1004      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
1005          result.Error(e);          result.Error(e);
# Line 983  String LSCPServer::SetAudioOutputChannel Line 1013  String LSCPServer::SetAudioOutputChannel
1013      try {      try {
1014          // get audio output device          // get audio output device
1015          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
1016          if (!devices[DeviceId]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + ".");          if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + ".");
1017          AudioOutputDevice* pDevice = devices[DeviceId];          AudioOutputDevice* pDevice = devices[DeviceId];
1018    
1019          // get audio channel          // get audio channel
# Line 992  String LSCPServer::SetAudioOutputChannel Line 1022  String LSCPServer::SetAudioOutputChannel
1022    
1023          // get desired audio channel parameter          // get desired audio channel parameter
1024          std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters();          std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters();
1025          if (!parameters[ParamKey]) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParamKey + "'.");          if (!parameters.count(ParamKey)) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParamKey + "'.");
1026          DeviceRuntimeParameter* pParameter = parameters[ParamKey];          DeviceRuntimeParameter* pParameter = parameters[ParamKey];
1027    
1028          // set new channel parameter value          // set new channel parameter value
# Line 1009  String LSCPServer::SetAudioOutputDeviceP Line 1039  String LSCPServer::SetAudioOutputDeviceP
1039      LSCPResultSet result;      LSCPResultSet result;
1040      try {      try {
1041          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
1042          if (!devices[DeviceIndex]) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");
1043          AudioOutputDevice* pDevice = devices[DeviceIndex];          AudioOutputDevice* pDevice = devices[DeviceIndex];
1044          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();
1045          if (!parameters[ParamKey]) throw LinuxSamplerException("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'");          if (!parameters.count(ParamKey)) throw LinuxSamplerException("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'");
1046          parameters[ParamKey]->SetValue(ParamVal);          parameters[ParamKey]->SetValue(ParamVal);
1047      }      }
1048      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
# Line 1026  String LSCPServer::SetMidiInputDevicePar Line 1056  String LSCPServer::SetMidiInputDevicePar
1056      LSCPResultSet result;      LSCPResultSet result;
1057      try {      try {
1058          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
1059          if (!devices[DeviceIndex]) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");
1060          MidiInputDevice* pDevice = devices[DeviceIndex];          MidiInputDevice* pDevice = devices[DeviceIndex];
1061          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();
1062          if (!parameters[ParamKey]) throw LinuxSamplerException("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'");          if (!parameters.count(ParamKey)) throw LinuxSamplerException("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'");
1063          parameters[ParamKey]->SetValue(ParamVal);          parameters[ParamKey]->SetValue(ParamVal);
1064      }      }
1065      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
# Line 1042  String LSCPServer::SetMidiInputPortParam Line 1072  String LSCPServer::SetMidiInputPortParam
1072      dmsg(2,("LSCPServer: SetMidiOutputDeviceParameter(DeviceIndex=%d,ParamKey=%s,ParamVal=%s)\n",DeviceIndex,ParamKey.c_str(),ParamVal.c_str()));      dmsg(2,("LSCPServer: SetMidiOutputDeviceParameter(DeviceIndex=%d,ParamKey=%s,ParamVal=%s)\n",DeviceIndex,ParamKey.c_str(),ParamVal.c_str()));
1073      LSCPResultSet result;      LSCPResultSet result;
1074      try {      try {
1075            // get MIDI input device
1076          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
1077            if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");
1078          MidiInputDevice* pDevice = devices[DeviceIndex];          MidiInputDevice* pDevice = devices[DeviceIndex];
1079          if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");  
1080          MidiInputDevice::MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex);          // get MIDI port
1081          if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + ".");          MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex);
1082          std::map<String,DeviceCreationParameter*> parameters = pMidiInputPort->DeviceParameters();          if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + ".");
1083          if (!parameters[ParamKey]) throw LinuxSamplerException("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'");  
1084            // set port parameter value
1085            std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters();
1086            if (!parameters.count(ParamKey)) throw LinuxSamplerException("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'");
1087          parameters[ParamKey]->SetValue(ParamVal);          parameters[ParamKey]->SetValue(ParamVal);
1088      }      }
1089      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
# Line 1063  String LSCPServer::SetMidiInputPortParam Line 1098  String LSCPServer::SetMidiInputPortParam
1098   */   */
1099  String LSCPServer::SetAudioOutputChannel(uint ChannelAudioOutputChannel, uint AudioOutputDeviceInputChannel, uint uiSamplerChannel) {  String LSCPServer::SetAudioOutputChannel(uint ChannelAudioOutputChannel, uint AudioOutputDeviceInputChannel, uint uiSamplerChannel) {
1100      dmsg(2,("LSCPServer: SetAudioOutputChannel(ChannelAudioOutputChannel=%d, AudioOutputDeviceInputChannel=%d, SamplerChannel=%d)\n",ChannelAudioOutputChannel,AudioOutputDeviceInputChannel,uiSamplerChannel));      dmsg(2,("LSCPServer: SetAudioOutputChannel(ChannelAudioOutputChannel=%d, AudioOutputDeviceInputChannel=%d, SamplerChannel=%d)\n",ChannelAudioOutputChannel,AudioOutputDeviceInputChannel,uiSamplerChannel));
1101      return "ERR:0:Not implemented yet.\r\n"; //FIXME: Add support for this in resultset class?      LSCPResultSet result;
1102        try {
1103            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1104            if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel));
1105            Engine* pEngine = pSamplerChannel->GetEngine();
1106            if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel));
1107            pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel);
1108        }
1109        catch (LinuxSamplerException e) {
1110             result.Error(e);
1111        }
1112        return result.Produce();
1113  }  }
1114    
1115  String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint uiSamplerChannel) {  String LSCPServer::SetAudioOutputDevice(uint AudioDeviceId, uint uiSamplerChannel) {
# Line 1073  String LSCPServer::SetAudioOutputDevice( Line 1119  String LSCPServer::SetAudioOutputDevice(
1119          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1120          if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel));
1121          std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
1122            if (!devices.count(AudioDeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId));
1123          AudioOutputDevice* pDevice = devices[AudioDeviceId];          AudioOutputDevice* pDevice = devices[AudioDeviceId];
         if (!pDevice) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId));  
1124          pSamplerChannel->SetAudioOutputDevice(pDevice);          pSamplerChannel->SetAudioOutputDevice(pDevice);
1125      }      }
1126      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
# Line 1140  String LSCPServer::SetMIDIInputChannel(u Line 1186  String LSCPServer::SetMIDIInputChannel(u
1186      try {      try {
1187          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1188          if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel));
1189          pSamplerChannel->SetMidiInputChannel((MidiInputDevice::MidiInputPort::midi_chan_t) MIDIChannel);          pSamplerChannel->SetMidiInputChannel((MidiInputPort::midi_chan_t) MIDIChannel);
1190      }      }
1191      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
1192           result.Error(e);           result.Error(e);
# Line 1155  String LSCPServer::SetMIDIInputDevice(ui Line 1201  String LSCPServer::SetMIDIInputDevice(ui
1201          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1202          if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel));
1203          std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
1204            if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId));
1205          MidiInputDevice* pDevice = devices[MIDIDeviceId];          MidiInputDevice* pDevice = devices[MIDIDeviceId];
         if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId));  
1206          pSamplerChannel->SetMidiInputDevice(pDevice);          pSamplerChannel->SetMidiInputDevice(pDevice);
1207      }      }
1208      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
# Line 1190  String LSCPServer::SetMIDIInputType(Stri Line 1236  String LSCPServer::SetMIDIInputType(Stri
1236              pDevice = pSampler->CreateMidiInputDevice(MidiInputDriver, params);              pDevice = pSampler->CreateMidiInputDevice(MidiInputDriver, params);
1237              // Make it with at least one initial port.              // Make it with at least one initial port.
1238              std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();              std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();
1239              parameters["ports"]->SetValue("1");              parameters["PORTS"]->SetValue("1");
1240          }          }
1241          // Must have a device...          // Must have a device...
1242          if (pDevice == NULL)          if (pDevice == NULL)
# Line 1215  String LSCPServer::SetMIDIInput(uint MID Line 1261  String LSCPServer::SetMIDIInput(uint MID
1261          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1262          if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel));
1263          std::map<uint, MidiInputDevice*> devices =  pSampler->GetMidiInputDevices();          std::map<uint, MidiInputDevice*> devices =  pSampler->GetMidiInputDevices();
1264            if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId));
1265          MidiInputDevice* pDevice = devices[MIDIDeviceId];          MidiInputDevice* pDevice = devices[MIDIDeviceId];
1266          if (!pDevice) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId));          pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (MidiInputPort::midi_chan_t) MIDIChannel);
         pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (MidiInputDevice::MidiInputPort::midi_chan_t) MIDIChannel);  
1267      }      }
1268      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
1269           result.Error(e);           result.Error(e);
# Line 1229  String LSCPServer::SetMIDIInput(uint MID Line 1275  String LSCPServer::SetMIDIInput(uint MID
1275   * Will be called by the parser to change the global volume factor on a   * Will be called by the parser to change the global volume factor on a
1276   * particular sampler channel.   * particular sampler channel.
1277   */   */
1278  String LSCPServer::SetVolume(double Volume, uint uiSamplerChannel) {  String LSCPServer::SetVolume(double dVolume, uint uiSamplerChannel) {
1279      dmsg(2,("LSCPServer: SetVolume(Volume=%f, SamplerChannel=%d)\n", Volume, uiSamplerChannel));      dmsg(2,("LSCPServer: SetVolume(Volume=%f, SamplerChannel=%d)\n", dVolume, uiSamplerChannel));
1280      LSCPResultSet result;      LSCPResultSet result;
1281      try {      try {
1282          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1283          if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds");          if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds");
1284          Engine* pEngine = pSamplerChannel->GetEngine();          Engine* pEngine = pSamplerChannel->GetEngine();
1285          if (!pEngine) throw LinuxSamplerException("No engine loaded on channel");          if (!pEngine) throw LinuxSamplerException("No engine loaded on channel");
1286          pEngine->Volume(Volume);          pEngine->Volume(dVolume);
1287      }      }
1288      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
1289           result.Error(e);           result.Error(e);
# Line 1265  String LSCPServer::ResetChannel(uint uiS Line 1311  String LSCPServer::ResetChannel(uint uiS
1311  }  }
1312    
1313  /**  /**
1314     * Will be called by the parser to reset the whole sampler.
1315     */
1316    String LSCPServer::ResetSampler() {
1317        dmsg(2,("LSCPServer: ResetSampler()\n"));
1318        pSampler->Reset();
1319        LSCPResultSet result;
1320        return result.Produce();
1321    }
1322    
1323    /**
1324   * Will be called by the parser to subscribe a client (frontend) on the   * Will be called by the parser to subscribe a client (frontend) on the
1325   * server for receiving event messages.   * server for receiving event messages.
1326   */   */
# Line 1290  String LSCPServer::UnsubscribeNotificati Line 1346  String LSCPServer::UnsubscribeNotificati
1346      return result.Produce();      return result.Produce();
1347  }  }
1348    
1349    /**
1350     * Will be called by the parser to enable or disable echo mode; if echo
1351     * mode is enabled, all commands from the client will (immediately) be
1352     * echoed back to the client.
1353     */
1354    String LSCPServer::SetEcho(yyparse_param_t* pSession, double boolean_value) {
1355        dmsg(2,("LSCPServer: SetEcho(val=%f)\n", boolean_value));
1356        LSCPResultSet result;
1357        try {
1358            if      (boolean_value == 0) pSession->bVerbose = false;
1359            else if (boolean_value == 1) pSession->bVerbose = true;
1360            else throw LinuxSamplerException("Not a boolean value, must either be 0 or 1");
1361        }
1362        catch (LinuxSamplerException e) {
1363             result.Error(e);
1364        }
1365        return result.Produce();
1366    }
1367    
1368  // Instrument loader constructor.  // Instrument loader constructor.
1369  LSCPLoadInstrument::LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument)  LSCPLoadInstrument::LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument)

Legend:
Removed from v.209  
changed lines
  Added in v.225

  ViewVC Help
Powered by ViewVC