/[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 1781 by iliev, Mon Sep 29 18:21:21 2008 UTC revision 1835 by iliev, Mon Feb 16 17:56:50 2009 UTC
# Line 24  Line 24 
24  #include <algorithm>  #include <algorithm>
25  #include <string>  #include <string>
26    
27    #include "../common/File.h"
28  #include "lscpserver.h"  #include "lscpserver.h"
29  #include "lscpresultset.h"  #include "lscpresultset.h"
30  #include "lscpevent.h"  #include "lscpevent.h"
# Line 334  void LSCPServer::DbInstrumentsEventHandl Line 335  void LSCPServer::DbInstrumentsEventHandl
335  }  }
336  #endif // HAVE_SQLITE3  #endif // HAVE_SQLITE3
337    
338    void LSCPServer::RemoveListeners() {
339        pSampler->RemoveChannelCountListener(&eventHandler);
340        pSampler->RemoveAudioDeviceCountListener(&eventHandler);
341        pSampler->RemoveMidiDeviceCountListener(&eventHandler);
342        pSampler->RemoveVoiceCountListener(&eventHandler);
343        pSampler->RemoveStreamCountListener(&eventHandler);
344        pSampler->RemoveBufferFillListener(&eventHandler);
345        pSampler->RemoveTotalStreamCountListener(&eventHandler);
346        pSampler->RemoveTotalVoiceCountListener(&eventHandler);
347        pSampler->RemoveFxSendCountListener(&eventHandler);
348        MidiInstrumentMapper::RemoveMidiInstrumentCountListener(&eventHandler);
349        MidiInstrumentMapper::RemoveMidiInstrumentInfoListener(&eventHandler);
350        MidiInstrumentMapper::RemoveMidiInstrumentMapCountListener(&eventHandler);
351        MidiInstrumentMapper::RemoveMidiInstrumentMapInfoListener(&eventHandler);
352    #if HAVE_SQLITE3
353        InstrumentsDb::GetInstrumentsDb()->RemoveInstrumentsDbListener(&dbInstrumentsEventHandler);
354    #endif
355    }
356    
357  /**  /**
358   * Blocks the calling thread until the LSCP Server is initialized and   * Blocks the calling thread until the LSCP Server is initialized and
# Line 507  int LSCPServer::Main() { Line 526  int LSCPServer::Main() {
526    
527          int retval = select(maxSessions+1, &selectSet, NULL, NULL, &timeout);          int retval = select(maxSessions+1, &selectSet, NULL, NULL, &timeout);
528    
529          if (retval == 0)          if (retval == 0 || (retval == -1 && errno == EINTR))
530                  continue; //Nothing try again                  continue; //Nothing try again
531          if (retval == -1) {          if (retval == -1) {
532                  std::cerr << "LSCPServer: Socket select error." << std::endl;                  std::cerr << "LSCPServer: Socket select error." << std::endl;
# Line 1259  String LSCPServer::GetMidiInputDriverInf Line 1278  String LSCPServer::GetMidiInputDriverInf
1278              for (;iter != parameters.end(); iter++) {              for (;iter != parameters.end(); iter++) {
1279                  if (s != "") s += ",";                  if (s != "") s += ",";
1280                  s += iter->first;                  s += iter->first;
1281                    delete iter->second;
1282              }              }
1283              result.Add("PARAMETERS", s);              result.Add("PARAMETERS", s);
1284          }          }
# Line 1283  String LSCPServer::GetAudioOutputDriverI Line 1303  String LSCPServer::GetAudioOutputDriverI
1303              for (;iter != parameters.end(); iter++) {              for (;iter != parameters.end(); iter++) {
1304                  if (s != "") s += ",";                  if (s != "") s += ",";
1305                  s += iter->first;                  s += iter->first;
1306                    delete iter->second;
1307              }              }
1308              result.Add("PARAMETERS", s);              result.Add("PARAMETERS", s);
1309          }          }
# Line 1313  String LSCPServer::GetMidiInputDriverPar Line 1334  String LSCPServer::GetMidiInputDriverPar
1334          if (oRangeMin)      result.Add("RANGE_MIN",     *oRangeMin);          if (oRangeMin)      result.Add("RANGE_MIN",     *oRangeMin);
1335          if (oRangeMax)      result.Add("RANGE_MAX",     *oRangeMax);          if (oRangeMax)      result.Add("RANGE_MAX",     *oRangeMax);
1336          if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities);          if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities);
1337            delete pParameter;
1338      }      }
1339      catch (Exception e) {      catch (Exception e) {
1340          result.Error(e);          result.Error(e);
# Line 1340  String LSCPServer::GetAudioOutputDriverP Line 1362  String LSCPServer::GetAudioOutputDriverP
1362          if (oRangeMin)      result.Add("RANGE_MIN",     *oRangeMin);          if (oRangeMin)      result.Add("RANGE_MIN",     *oRangeMin);
1363          if (oRangeMax)      result.Add("RANGE_MAX",     *oRangeMax);          if (oRangeMax)      result.Add("RANGE_MAX",     *oRangeMax);
1364          if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities);          if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities);
1365            delete pParameter;
1366      }      }
1367      catch (Exception e) {      catch (Exception e) {
1368          result.Error(e);          result.Error(e);
# Line 2540  String LSCPServer::GetTotalVoiceCount() Line 2563  String LSCPServer::GetTotalVoiceCount()
2563  String LSCPServer::GetTotalVoiceCountMax() {  String LSCPServer::GetTotalVoiceCountMax() {
2564      dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n"));      dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n"));
2565      LSCPResultSet result;      LSCPResultSet result;
2566      result.Add(EngineFactory::EngineInstances().size() * CONFIG_MAX_VOICES);      result.Add(EngineFactory::EngineInstances().size() * GLOBAL_MAX_VOICES);
2567        return result.Produce();
2568    }
2569    
2570    /**
2571     * Will be called by the parser to return the sampler global maximum
2572     * allowed number of voices.
2573     */
2574    String LSCPServer::GetGlobalMaxVoices() {
2575        dmsg(2,("LSCPServer: GetGlobalMaxVoices()\n"));
2576        LSCPResultSet result;
2577        result.Add(GLOBAL_MAX_VOICES);
2578        return result.Produce();
2579    }
2580    
2581    /**
2582     * Will be called by the parser to set the sampler global maximum number of
2583     * voices.
2584     */
2585    String LSCPServer::SetGlobalMaxVoices(int iVoices) {
2586        dmsg(2,("LSCPServer: SetGlobalMaxVoices(%d)\n", iVoices));
2587        LSCPResultSet result;
2588        try {
2589            if (iVoices < 1) throw Exception("Maximum voices may not be less than 1");
2590            GLOBAL_MAX_VOICES = iVoices; // see common/global_private.cpp
2591            const std::set<Engine*>& engines = EngineFactory::EngineInstances();
2592            if (engines.size() > 0) {
2593                std::set<Engine*>::iterator iter = engines.begin();
2594                std::set<Engine*>::iterator end  = engines.end();
2595                for (; iter != end; ++iter) {
2596                    (*iter)->SetMaxVoices(iVoices);
2597                }
2598            }
2599            LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_global_info, "VOICES", GLOBAL_MAX_VOICES));
2600        } catch (Exception e) {
2601            result.Error(e);
2602        }
2603        return result.Produce();
2604    }
2605    
2606    /**
2607     * Will be called by the parser to return the sampler global maximum
2608     * allowed number of disk streams.
2609     */
2610    String LSCPServer::GetGlobalMaxStreams() {
2611        dmsg(2,("LSCPServer: GetGlobalMaxStreams()\n"));
2612        LSCPResultSet result;
2613        result.Add(GLOBAL_MAX_STREAMS);
2614        return result.Produce();
2615    }
2616    
2617    /**
2618     * Will be called by the parser to set the sampler global maximum number of
2619     * disk streams.
2620     */
2621    String LSCPServer::SetGlobalMaxStreams(int iStreams) {
2622        dmsg(2,("LSCPServer: SetGlobalMaxStreams(%d)\n", iStreams));
2623        LSCPResultSet result;
2624        try {
2625            if (iStreams < 0) throw Exception("Maximum disk streams may not be negative");
2626            GLOBAL_MAX_STREAMS = iStreams; // see common/global_private.cpp
2627            const std::set<Engine*>& engines = EngineFactory::EngineInstances();
2628            if (engines.size() > 0) {
2629                std::set<Engine*>::iterator iter = engines.begin();
2630                std::set<Engine*>::iterator end  = engines.end();
2631                for (; iter != end; ++iter) {
2632                    (*iter)->SetMaxDiskStreams(iStreams);
2633                }
2634            }
2635            LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_global_info, "STREAMS", GLOBAL_MAX_STREAMS));
2636        } catch (Exception e) {
2637            result.Error(e);
2638        }
2639      return result.Produce();      return result.Produce();
2640  }  }
2641    
# Line 2728  void LSCPServer::VerifyFile(String Filen Line 2823  void LSCPServer::VerifyFile(String Filen
2823          throw Exception("Directory is specified");          throw Exception("Directory is specified");
2824      }      }
2825      #else      #else
2826      struct stat statBuf;      File f(Filename);
2827      int res = stat(Filename.c_str(), &statBuf);      if(!f.Exist()) throw Exception(f.GetErrorMsg());
2828      if (res) {      if (f.IsDirectory()) throw Exception("Directory is specified");
         std::stringstream ss;  
         ss << "Fail to stat `" << Filename << "`: " << strerror(errno);  
         throw Exception(ss.str());  
     }  
   
     if (S_ISDIR(statBuf.st_mode)) {  
         throw Exception("Directory is specified");  
     }  
2829      #endif      #endif
2830  }  }
2831    

Legend:
Removed from v.1781  
changed lines
  Added in v.1835

  ViewVC Help
Powered by ViewVC