/[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 2837 by persson, Sun Aug 23 06:14:00 2015 UTC revision 3055 by schoenebeck, Thu Dec 15 13:01:58 2016 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 - 2015 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2016 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This library is free software; you can redistribute it and/or modify  *   *   This library is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 31  Line 31 
31    
32  #if defined(WIN32)  #if defined(WIN32)
33  #include <windows.h>  #include <windows.h>
34    typedef unsigned short in_port_t;
35    typedef unsigned long in_addr_t;
36  #else  #else
37  #include <fcntl.h>  #include <fcntl.h>
38  #endif  #endif
# Line 111  Mutex LSCPServer::RTNotifyMutex; Line 113  Mutex LSCPServer::RTNotifyMutex;
113    
114  LSCPServer::LSCPServer(Sampler* pSampler, long int addr, short int port) : Thread(true, false, 0, -4), eventHandler(this) {  LSCPServer::LSCPServer(Sampler* pSampler, long int addr, short int port) : Thread(true, false, 0, -4), eventHandler(this) {
115      SocketAddress.sin_family      = AF_INET;      SocketAddress.sin_family      = AF_INET;
116      SocketAddress.sin_addr.s_addr = addr;      SocketAddress.sin_addr.s_addr = (in_addr_t)addr;
117      SocketAddress.sin_port        = port;      SocketAddress.sin_port        = (in_port_t)port;
118      this->pSampler = pSampler;      this->pSampler = pSampler;
119      LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_count, "AUDIO_OUTPUT_DEVICE_COUNT");      LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_count, "AUDIO_OUTPUT_DEVICE_COUNT");
120      LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_info, "AUDIO_OUTPUT_DEVICE_INFO");      LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_info, "AUDIO_OUTPUT_DEVICE_INFO");
# Line 708  extern int GetLSCPCommand( void *buf, in Line 710  extern int GetLSCPCommand( void *buf, in
710    
711          strcpy((char*) buf, command.c_str());          strcpy((char*) buf, command.c_str());
712          LSCPServer::bufferedCommands.erase(LSCPServer::currentSocket);          LSCPServer::bufferedCommands.erase(LSCPServer::currentSocket);
713          return command.size();          return (int) command.size();
714  }  }
715    
716  extern yyparse_param_t* GetCurrentYaccSession() {  extern yyparse_param_t* GetCurrentYaccSession() {
# Line 762  bool LSCPServer::GetLSCPCommand( std::ve Line 764  bool LSCPServer::GetLSCPCommand( std::ve
764          // first get as many character as possible and add it to the 'input' buffer          // first get as many character as possible and add it to the 'input' buffer
765          while (true) {          while (true) {
766                  #if defined(WIN32)                  #if defined(WIN32)
767                  result = recv(socket, (char *)&c, 1, 0); //Read one character at a time for now                  result = (int)recv(socket, (char*)&c, 1, 0); //Read one character at a time for now
768                  #else                  #else
769                  result = recv(socket, (void *)&c, 1, 0); //Read one character at a time for now                  result = (int)recv(socket, (void*)&c, 1, 0); //Read one character at a time for now
770                  #endif                  #endif
771                  if (result == 1) input.push_back(c);                  if (result == 1) input.push_back(c);
772                  else break; // end of input or some error                  else break; // end of input or some error
# Line 798  bool LSCPServer::GetLSCPCommand( std::ve Line 800  bool LSCPServer::GetLSCPCommand( std::ve
800                  } else if (c == 3) { // custom ASCII code usage for moving cursor right (LSCP shell)                  } else if (c == 3) { // custom ASCII code usage for moving cursor right (LSCP shell)
801                          if (iter->iCursorOffset < 0) iter->iCursorOffset++;                          if (iter->iCursorOffset < 0) iter->iCursorOffset++;
802                  } else {                  } else {
803                          size_t cursorPos = bufferedCommands[socket].size() + iter->iCursorOffset;                          ssize_t cursorPos = bufferedCommands[socket].size() + iter->iCursorOffset;
804                          // backspace character - should only happen with shell                          // backspace character - should only happen with shell
805                          if (c == '\b') {                          if (c == '\b') {
806                                  if (!bufferedCommands[socket].empty() && cursorPos > 0)                                  if (!bufferedCommands[socket].empty() && cursorPos > 0)
# Line 1146  String LSCPServer::GetAvailableEngines() Line 1148  String LSCPServer::GetAvailableEngines()
1148      dmsg(2,("LSCPServer: GetAvailableEngines()\n"));      dmsg(2,("LSCPServer: GetAvailableEngines()\n"));
1149      LSCPResultSet result;      LSCPResultSet result;
1150      try {      try {
1151          int n = EngineFactory::AvailableEngineTypes().size();          int n = (int)EngineFactory::AvailableEngineTypes().size();
1152          result.Add(n);          result.Add(n);
1153      }      }
1154      catch (Exception e) {      catch (Exception e) {
# Line 1350  String LSCPServer::GetAvailableAudioOutp Line 1352  String LSCPServer::GetAvailableAudioOutp
1352      dmsg(2,("LSCPServer: GetAvailableAudioOutputDrivers()\n"));      dmsg(2,("LSCPServer: GetAvailableAudioOutputDrivers()\n"));
1353      LSCPResultSet result;      LSCPResultSet result;
1354      try {      try {
1355          int n = AudioOutputDeviceFactory::AvailableDrivers().size();          int n = (int) AudioOutputDeviceFactory::AvailableDrivers().size();
1356          result.Add(n);          result.Add(n);
1357      }      }
1358      catch (Exception e) {      catch (Exception e) {
# Line 1376  String LSCPServer::GetAvailableMidiInput Line 1378  String LSCPServer::GetAvailableMidiInput
1378      dmsg(2,("LSCPServer: GetAvailableMidiInputDrivers()\n"));      dmsg(2,("LSCPServer: GetAvailableMidiInputDrivers()\n"));
1379      LSCPResultSet result;      LSCPResultSet result;
1380      try {      try {
1381          int n = MidiInputDeviceFactory::AvailableDrivers().size();          int n = (int)MidiInputDeviceFactory::AvailableDrivers().size();
1382          result.Add(n);          result.Add(n);
1383      }      }
1384      catch (Exception e) {      catch (Exception e) {
# Line 2434  String LSCPServer::GetMidiInstrumentMaps Line 2436  String LSCPServer::GetMidiInstrumentMaps
2436      dmsg(2,("LSCPServer: GetMidiInstrumentMaps()\n"));      dmsg(2,("LSCPServer: GetMidiInstrumentMaps()\n"));
2437      LSCPResultSet result;      LSCPResultSet result;
2438      try {      try {
2439          result.Add(MidiInstrumentMapper::Maps().size());          result.Add(int(MidiInstrumentMapper::Maps().size()));
2440      } catch (Exception e) {      } catch (Exception e) {
2441          result.Error(e);          result.Error(e);
2442      }      }
# Line 3275  String LSCPServer::GetTotalVoiceCount() Line 3277  String LSCPServer::GetTotalVoiceCount()
3277  String LSCPServer::GetTotalVoiceCountMax() {  String LSCPServer::GetTotalVoiceCountMax() {
3278      dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n"));      dmsg(2,("LSCPServer: GetTotalVoiceCountMax()\n"));
3279      LSCPResultSet result;      LSCPResultSet result;
3280      result.Add(EngineFactory::EngineInstances().size() * pSampler->GetGlobalMaxVoices());      result.Add(int(EngineFactory::EngineInstances().size() * pSampler->GetGlobalMaxVoices()));
3281      return result.Produce();      return result.Produce();
3282  }  }
3283    
# Line 3377  String LSCPServer::GetFileInstruments(St Line 3379  String LSCPServer::GetFileInstruments(St
3379                  std::vector<InstrumentManager::instrument_id_t> IDs =                  std::vector<InstrumentManager::instrument_id_t> IDs =
3380                      pManager->GetInstrumentFileContent(Filename);                      pManager->GetInstrumentFileContent(Filename);
3381                  // return the amount of instruments in the file                  // return the amount of instruments in the file
3382                  result.Add(IDs.size());                  result.Add((int)IDs.size());
3383                  // no more need to ask other engine types                  // no more need to ask other engine types
3384                  bFound = true;                  bFound = true;
3385              } else dmsg(1,("Warning: engine '%s' does not provide an instrument manager\n", engineTypes[i].c_str()));              } else dmsg(1,("Warning: engine '%s' does not provide an instrument manager\n", engineTypes[i].c_str()));

Legend:
Removed from v.2837  
changed lines
  Added in v.3055

  ViewVC Help
Powered by ViewVC