/[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 778 by iliev, Fri Sep 23 06:58:26 2005 UTC revision 814 by wylder, Thu Dec 22 19:26:35 2005 UTC
# Line 128  int LSCPServer::Main() { Line 128  int LSCPServer::Main() {
128      FD_SET(hSocket, &fdSet);      FD_SET(hSocket, &fdSet);
129      int maxSessions = hSocket;      int maxSessions = hSocket;
130    
131        timeval timeout;
132    
133      while (true) {      while (true) {
134          fd_set selectSet = fdSet;          // check if some engine channel's parameter / status changed, if so notify the respective LSCP event subscribers
135          int retval = select(maxSessions+1, &selectSet, NULL, NULL, NULL);          {
136                std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances();
137                std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin();
138                std::set<EngineChannel*>::iterator itEnd           = engineChannels.end();
139                for (; itEngineChannel != itEnd; ++itEngineChannel) {
140                    if ((*itEngineChannel)->StatusChanged()) {
141                        SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->iSamplerChannelIndex));
142                    }
143                }
144            }
145    
146            //Now let's deliver late notifies (if any)
147            NotifyBufferMutex.Lock();
148            for (std::map<int,String>::iterator iterNotify = bufferedNotifies.begin(); iterNotify != bufferedNotifies.end(); iterNotify++) {
149    #ifdef MSG_NOSIGNAL
150                    send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), MSG_NOSIGNAL);
151    #else
152                    send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), 0);
153    #endif
154                    bufferedNotifies.erase(iterNotify);
155            }
156            NotifyBufferMutex.Unlock();
157    
158            fd_set selectSet = fdSet;
159            timeout.tv_sec  = 0;
160            timeout.tv_usec = 100000;
161    
162            int retval = select(maxSessions+1, &selectSet, NULL, NULL, &timeout);
163    
164          if (retval == 0)          if (retval == 0)
165                  continue; //Nothing try again                  continue; //Nothing try again
166          if (retval == -1) {          if (retval == -1) {
# Line 190  int LSCPServer::Main() { Line 220  int LSCPServer::Main() {
220                          break;                          break;
221                  }                  }
222          }          }
   
         // check if some engine channel's parameter / status changed, if so notify the respective LSCP event subscribers  
         {  
             std::set<EngineChannel*> engineChannels = EngineChannelFactory::EngineChannelInstances();  
             std::set<EngineChannel*>::iterator itEngineChannel = engineChannels.begin();  
             std::set<EngineChannel*>::iterator itEnd           = engineChannels.end();  
             for (; itEngineChannel != itEnd; ++itEngineChannel) {  
                 if ((*itEngineChannel)->StatusChanged()) {  
                     SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->iSamplerChannelIndex));  
                 }  
             }  
         }  
   
         //Now let's deliver late notifies (if any)  
         NotifyBufferMutex.Lock();  
         for (std::map<int,String>::iterator iterNotify = bufferedNotifies.begin(); iterNotify != bufferedNotifies.end(); iterNotify++) {  
                 send(iterNotify->first, iterNotify->second.c_str(), iterNotify->second.size(), MSG_NOSIGNAL);  
                 bufferedNotifies.erase(iterNotify);  
         }  
         NotifyBufferMutex.Unlock();  
223      }      }
224  }  }
225    
# Line 256  void LSCPServer::SendLSCPNotify( LSCPEve Line 266  void LSCPServer::SendLSCPNotify( LSCPEve
266          while (true) {          while (true) {
267                  if (NotifyMutex.Trylock()) {                  if (NotifyMutex.Trylock()) {
268                          for(;iter != end; iter++)                          for(;iter != end; iter++)
269    #ifdef MSG_NOSIGNAL
270                                  send(*iter, notify.c_str(), notify.size(), MSG_NOSIGNAL);                                  send(*iter, notify.c_str(), notify.size(), MSG_NOSIGNAL);
271    #else
272                                    send(*iter, notify.c_str(), notify.size(), 0);
273    #endif
274                          NotifyMutex.Unlock();                          NotifyMutex.Unlock();
275                          break;                          break;
276                  } else {                  } else {
# Line 365  void LSCPServer::AnswerClient(String Ret Line 379  void LSCPServer::AnswerClient(String Ret
379      dmsg(2,("LSCPServer::AnswerClient(ReturnMessage=%s)", ReturnMessage.c_str()));      dmsg(2,("LSCPServer::AnswerClient(ReturnMessage=%s)", ReturnMessage.c_str()));
380      if (currentSocket != -1) {      if (currentSocket != -1) {
381              NotifyMutex.Lock();              NotifyMutex.Lock();
382    #ifdef MSG_NOSIGNAL
383              send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), MSG_NOSIGNAL);              send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), MSG_NOSIGNAL);
384    #else
385                send(currentSocket, ReturnMessage.c_str(), ReturnMessage.size(), 0);
386    #endif
387              NotifyMutex.Unlock();              NotifyMutex.Unlock();
388      }      }
389  }  }

Legend:
Removed from v.778  
changed lines
  Added in v.814

  ViewVC Help
Powered by ViewVC