/[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 411 by schoenebeck, Sat Feb 26 02:01:14 2005 UTC revision 579 by schoenebeck, Tue May 24 19:20:20 2005 UTC
# Line 62  Mutex LSCPServer::RTNotifyMutex = Mutex( Line 62  Mutex LSCPServer::RTNotifyMutex = Mutex(
62    
63  LSCPServer::LSCPServer(Sampler* pSampler) : Thread(true, false, 0, -4) {  LSCPServer::LSCPServer(Sampler* pSampler) : Thread(true, false, 0, -4) {
64      this->pSampler = pSampler;      this->pSampler = pSampler;
65      LSCPEvent::RegisterEvent(LSCPEvent::event_channels, "CHANNELS");      LSCPEvent::RegisterEvent(LSCPEvent::event_channel_count, "CHANNEL_COUNT");
66      LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT");      LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT");
67      LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT");      LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT");
68      LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL");      LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL");
69      LSCPEvent::RegisterEvent(LSCPEvent::event_info, "INFO");      LSCPEvent::RegisterEvent(LSCPEvent::event_channel_info, "CHANNEL_INFO");
70      LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS");      LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS");
71        hSocket = -1;
72    }
73    
74    LSCPServer::~LSCPServer() {
75        if (hSocket >= 0) close(hSocket);
76  }  }
77    
78  /**  /**
# Line 85  int LSCPServer::WaitUntilInitialized(lon Line 90  int LSCPServer::WaitUntilInitialized(lon
90  }  }
91    
92  int LSCPServer::Main() {  int LSCPServer::Main() {
93      int hSocket = socket(AF_INET, SOCK_STREAM, 0);      hSocket = socket(AF_INET, SOCK_STREAM, 0);
94      if (hSocket < 0) {      if (hSocket < 0) {
95          std::cerr << "LSCPServer: Could not create server socket." << std::endl;          std::cerr << "LSCPServer: Could not create server socket." << std::endl;
96          //return -1;          //return -1;
# Line 168  int LSCPServer::Main() { Line 173  int LSCPServer::Main() {
173                                  int dummy; // just a temporary hack to fulfill the restart() function prototype                                  int dummy; // just a temporary hack to fulfill the restart() function prototype
174                                  restart(NULL, dummy); // restart the 'scanner'                                  restart(NULL, dummy); // restart the 'scanner'
175                                  currentSocket = (*iter).hSession;  //a hack                                  currentSocket = (*iter).hSession;  //a hack
176                                    dmsg(2,("LSCPServer: [%s]\n",bufferedCommands[currentSocket].c_str()));
177                                  if ((*iter).bVerbose) { // if echo mode enabled                                  if ((*iter).bVerbose) { // if echo mode enabled
178                                      AnswerClient(bufferedCommands[currentSocket]);                                      AnswerClient(bufferedCommands[currentSocket]);
179                                  }                                  }
# Line 481  String LSCPServer::LoadInstrument(String Line 487  String LSCPServer::LoadInstrument(String
487  String LSCPServer::SetEngineType(String EngineName, uint uiSamplerChannel) {  String LSCPServer::SetEngineType(String EngineName, uint uiSamplerChannel) {
488      dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel));      dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel));
489      LSCPResultSet result;      LSCPResultSet result;
490      try {              try {
491          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
492          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));
493          LockRTNotify();          LockRTNotify();
# Line 544  String LSCPServer::RemoveChannel(uint ui Line 550  String LSCPServer::RemoveChannel(uint ui
550  }  }
551    
552  /**  /**
553   * Will be called by the parser to get all available engines.   * Will be called by the parser to get the amount of all available engines.
554   */   */
555  String LSCPServer::GetAvailableEngines() {  String LSCPServer::GetAvailableEngines() {
556      dmsg(2,("LSCPServer: GetAvailableEngines()\n"));      dmsg(2,("LSCPServer: GetAvailableEngines()\n"));
557      LSCPResultSet result("GigEngine");      LSCPResultSet result("1");
558        return result.Produce();
559    }
560    
561    /**
562     * Will be called by the parser to get a list of all available engines.
563     */
564    String LSCPServer::ListAvailableEngines() {
565        dmsg(2,("LSCPServer: ListAvailableEngines()\n"));
566        LSCPResultSet result("\'GIG\'");
567      return result.Produce();      return result.Produce();
568  }  }
569    
# Line 593  String LSCPServer::GetChannelInfo(uint u Line 608  String LSCPServer::GetChannelInfo(uint u
608          int AudioOutputChannels = 0;          int AudioOutputChannels = 0;
609          String AudioRouting;          String AudioRouting;
610    
611          if (pEngineChannel) {                                        if (pEngineChannel) {
612              EngineName          = pEngineChannel->GetEngine()->EngineName();              EngineName          = pEngineChannel->EngineName();
613              AudioOutputChannels = pEngineChannel->Channels();              AudioOutputChannels = pEngineChannel->Channels();
614              Volume              = pEngineChannel->Volume();              Volume              = pEngineChannel->Volume();
615              InstrumentStatus    = pEngineChannel->InstrumentStatus();              InstrumentStatus    = pEngineChannel->InstrumentStatus();
# Line 709  String LSCPServer::GetAvailableAudioOutp Line 724  String LSCPServer::GetAvailableAudioOutp
724      dmsg(2,("LSCPServer: GetAvailableAudioOutputDrivers()\n"));      dmsg(2,("LSCPServer: GetAvailableAudioOutputDrivers()\n"));
725      LSCPResultSet result;      LSCPResultSet result;
726      try {      try {
727            int n = AudioOutputDeviceFactory::AvailableDrivers().size();
728            result.Add(n);
729        }
730        catch (LinuxSamplerException e) {
731            result.Error(e);
732        }
733        return result.Produce();
734    }
735    
736    String LSCPServer::ListAvailableAudioOutputDrivers() {
737        dmsg(2,("LSCPServer: ListAvailableAudioOutputDrivers()\n"));
738        LSCPResultSet result;
739        try {
740          String s = AudioOutputDeviceFactory::AvailableDriversAsString();          String s = AudioOutputDeviceFactory::AvailableDriversAsString();
741          result.Add(s);          result.Add(s);
742      }      }
# Line 722  String LSCPServer::GetAvailableMidiInput Line 750  String LSCPServer::GetAvailableMidiInput
750      dmsg(2,("LSCPServer: GetAvailableMidiInputDrivers()\n"));      dmsg(2,("LSCPServer: GetAvailableMidiInputDrivers()\n"));
751      LSCPResultSet result;      LSCPResultSet result;
752      try {      try {
753            int n = MidiInputDeviceFactory::AvailableDrivers().size();
754            result.Add(n);
755        }
756        catch (LinuxSamplerException e) {
757            result.Error(e);
758        }
759        return result.Produce();
760    }
761    
762    String LSCPServer::ListAvailableMidiInputDrivers() {
763        dmsg(2,("LSCPServer: ListAvailableMidiInputDrivers()\n"));
764        LSCPResultSet result;
765        try {
766          String s = MidiInputDeviceFactory::AvailableDriversAsString();          String s = MidiInputDeviceFactory::AvailableDriversAsString();
767          result.Add(s);          result.Add(s);
768      }      }
# Line 1350  String LSCPServer::ResetChannel(uint uiS Line 1391  String LSCPServer::ResetChannel(uint uiS
1391          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));
1392          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1393          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");
1394            if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel");
1395          pEngineChannel->GetEngine()->Reset();          pEngineChannel->GetEngine()->Reset();
1396      }      }
1397      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
# Line 1368  String LSCPServer::ResetSampler() { Line 1410  String LSCPServer::ResetSampler() {
1410      return result.Produce();      return result.Produce();
1411  }  }
1412    
1413    /**
1414     * Will be called by the parser to return general informations about this
1415     * sampler.
1416     */
1417    String LSCPServer::GetServerInfo() {
1418        dmsg(2,("LSCPServer: GetServerInfo()\n"));
1419        LSCPResultSet result;
1420        result.Add("DESCRIPTION", "LinuxSampler - modular, streaming capable sampler");
1421        result.Add("VERSION", VERSION);
1422        result.Add("PROTOCOL_VERSION", "1.0");
1423        return result.Produce();
1424    }
1425    
1426  /**  /**
1427   * 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
1428   * server for receiving event messages.   * server for receiving event messages.

Legend:
Removed from v.411  
changed lines
  Added in v.579

  ViewVC Help
Powered by ViewVC