/[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 210 by schoenebeck, Sat Jul 24 12:33:49 2004 UTC revision 219 by schoenebeck, Tue Aug 17 20:35:04 2004 UTC
# 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 133  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 159  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 179  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 729  String LSCPServer::GetMidiInputDriverPar Line 741  String LSCPServer::GetMidiInputDriverPar
741          DeviceCreationParameter* pParameter = MidiInputDeviceFactory::GetDriverParameter(Driver, Parameter);          DeviceCreationParameter* pParameter = MidiInputDeviceFactory::GetDriverParameter(Driver, Parameter);
742          result.Add("TYPE",         pParameter->Type());          result.Add("TYPE",         pParameter->Type());
743          result.Add("DESCRIPTION",  pParameter->Description());          result.Add("DESCRIPTION",  pParameter->Description());
744          result.Add("MANDATORY",    pParameter->Mandatory());          result.Add("MANDATORY",    (pParameter->Mandatory())    ? "true" : "false");
745          result.Add("FIX",          pParameter->Fix());          result.Add("FIX",          (pParameter->Fix())          ? "true" : "false");
746          result.Add("MULTIPLICITY", pParameter->Multiplicity());          result.Add("MULTIPLICITY", (pParameter->Multiplicity()) ? "true" : "false");
747          if (pParameter->Depends())       result.Add("DEPENDS",       pParameter->Depends());          if (pParameter->Depends())       result.Add("DEPENDS",       *pParameter->Depends());
748          if (pParameter->Default())       result.Add("DEFAULT",       pParameter->Default());          if (pParameter->Default())       result.Add("DEFAULT",       *pParameter->Default());
749          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     pParameter->RangeMin());          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     *pParameter->RangeMin());
750          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     pParameter->RangeMax());          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     *pParameter->RangeMax());
751          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities());          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities());
752      }      }
753      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
754          result.Error(e);          result.Error(e);
# Line 751  String LSCPServer::GetAudioOutputDriverP Line 763  String LSCPServer::GetAudioOutputDriverP
763          DeviceCreationParameter* pParameter = AudioOutputDeviceFactory::GetDriverParameter(Driver, Parameter);          DeviceCreationParameter* pParameter = AudioOutputDeviceFactory::GetDriverParameter(Driver, Parameter);
764          result.Add("TYPE",         pParameter->Type());          result.Add("TYPE",         pParameter->Type());
765          result.Add("DESCRIPTION",  pParameter->Description());          result.Add("DESCRIPTION",  pParameter->Description());
766          result.Add("MANDATORY",    pParameter->Mandatory());          result.Add("MANDATORY",    (pParameter->Mandatory())    ? "true" : "false");
767          result.Add("FIX",          pParameter->Fix());          result.Add("FIX",          (pParameter->Fix())          ? "true" : "false");
768          result.Add("MULTIPLICITY", pParameter->Multiplicity());          result.Add("MULTIPLICITY", (pParameter->Multiplicity()) ? "true" : "false");
769          if (pParameter->Depends())       result.Add("DEPENDS",       pParameter->Depends());          if (pParameter->Depends())       result.Add("DEPENDS",       *pParameter->Depends());
770          if (pParameter->Default())       result.Add("DEFAULT",       pParameter->Default());          if (pParameter->Default())       result.Add("DEFAULT",       *pParameter->Default());
771          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     pParameter->RangeMin());          if (pParameter->RangeMin())      result.Add("RANGE_MIN",     *pParameter->RangeMin());
772          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     pParameter->RangeMax());          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     *pParameter->RangeMax());
773          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", pParameter->Possibilities());          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities());
774      }      }
775      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
776          result.Error(e);          result.Error(e);
# Line 1269  String LSCPServer::ResetChannel(uint uiS Line 1281  String LSCPServer::ResetChannel(uint uiS
1281      return result.Produce();      return result.Produce();
1282  }  }
1283    
1284    /**
1285     * Will be called by the parser to reset the whole sampler.
1286     */
1287    String LSCPServer::ResetSampler() {
1288        dmsg(2,("LSCPServer: ResetSampler()\n"));
1289        pSampler->Reset();
1290        LSCPResultSet result;
1291        return result.Produce();
1292    }
1293    
1294  /**  /**
1295   * 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
1296   * server for receiving event messages.   * server for receiving event messages.

Legend:
Removed from v.210  
changed lines
  Added in v.219

  ViewVC Help
Powered by ViewVC