/[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 1535 by iliev, Mon Dec 3 13:59:03 2007 UTC revision 1536 by schoenebeck, Mon Dec 3 16:41:17 2007 UTC
# Line 367  int LSCPServer::Main() { Line 367  int LSCPServer::Main() {
367                    std::cerr << "LSCPServer: ioctlsocket: set FIONBIO failed. Error " << WSAGetLastError() << std::endl;                    std::cerr << "LSCPServer: ioctlsocket: set FIONBIO failed. Error " << WSAGetLastError() << std::endl;
368                    exit(EXIT_FAILURE);                    exit(EXIT_FAILURE);
369                  }                  }
370          #else                    #else
371                  if (fcntl(socket, F_SETFL, O_NONBLOCK)) {                  if (fcntl(socket, F_SETFL, O_NONBLOCK)) {
372                          std::cerr << "LSCPServer: F_SETFL O_NONBLOCK failed." << std::endl;                          std::cerr << "LSCPServer: F_SETFL O_NONBLOCK failed." << std::endl;
373                          exit(EXIT_FAILURE);                          exit(EXIT_FAILURE);
# Line 538  bool LSCPServer::GetLSCPCommand( std::ve Line 538  bool LSCPServer::GetLSCPCommand( std::ve
538                      int wsa_lasterror = WSAGetLastError();                      int wsa_lasterror = WSAGetLastError();
539                          if (wsa_lasterror == WSAEWOULDBLOCK) //Would block, try again later.                          if (wsa_lasterror == WSAEWOULDBLOCK) //Would block, try again later.
540                                  return false;                                  return false;
541                          dmsg(2,("LSCPScanner: Socket error after recv() Error %d.\n", wsa_lasterror));                            dmsg(2,("LSCPScanner: Socket error after recv() Error %d.\n", wsa_lasterror));
542                          CloseConnection(iter);                          CloseConnection(iter);
543                          break;                          break;
544                  }                  }
# Line 2474  String LSCPServer::GetFileInstrumentInfo Line 2474  String LSCPServer::GetFileInstrumentInfo
2474      id.Index    = InstrumentID;      id.Index    = InstrumentID;
2475      // try to find a sampler engine that can handle the file      // try to find a sampler engine that can handle the file
2476      bool bFound = false;      bool bFound = false;
2477        bool bFatalErr = false;
2478      std::vector<String> engineTypes = EngineFactory::AvailableEngineTypes();      std::vector<String> engineTypes = EngineFactory::AvailableEngineTypes();
2479      for (int i = 0; !bFound && i < engineTypes.size(); i++) {      for (int i = 0; !bFound && !bFatalErr && i < engineTypes.size(); i++) {
2480          Engine* pEngine = NULL;          Engine* pEngine = NULL;
2481          try {          try {
2482              pEngine = EngineFactory::Create(engineTypes[i]);              pEngine = EngineFactory::Create(engineTypes[i]);
2483              if (!pEngine) throw Exception("Internal error: could not create '" + engineTypes[i] + "' engine");              if (!pEngine) throw Exception("Internal error: could not create '" + engineTypes[i] + "' engine");
2484              InstrumentManager* pManager = pEngine->GetInstrumentManager();              InstrumentManager* pManager = pEngine->GetInstrumentManager();
2485              if (pManager) {              if (pManager) {
2486                    // check if the instrument index is valid
2487                    // FIXME: this won't work if an engine only supports parts of the instrument file
2488                    std::vector<InstrumentManager::instrument_id_t> IDs =
2489                        pManager->GetInstrumentFileContent(Filename);
2490                    if (std::find(IDs.begin(), IDs.end(), id) == IDs.end()) {
2491                        std::stringstream ss;
2492                        ss << "Invalid instrument index " << InstrumentID << " for instrument file '" << Filename << "'";
2493                        bFatalErr = true;
2494                        throw Exception(ss.str());
2495                    }
2496                    // get the info of the requested instrument
2497                  InstrumentManager::instrument_info_t info =                  InstrumentManager::instrument_info_t info =
2498                      pManager->GetInstrumentInfo(id);                      pManager->GetInstrumentInfo(id);
2499                  // return detailed informations about the file                  // return detailed informations about the file
# Line 2494  String LSCPServer::GetFileInstrumentInfo Line 2506  String LSCPServer::GetFileInstrumentInfo
2506                  bFound = true;                  bFound = true;
2507              } 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()));
2508          } catch (Exception e) {          } catch (Exception e) {
2509              // NOOP, as exception is thrown if engine doesn't support file              // usually NOOP, as exception is thrown if engine doesn't support file
2510                if (bFatalErr) result.Error(e);
2511          }          }
2512          if (pEngine) EngineFactory::Destroy(pEngine);          if (pEngine) EngineFactory::Destroy(pEngine);
2513      }      }
2514    
2515      if (!bFound) result.Error("Unknown file format");      if (!bFound && !bFatalErr) result.Error("Unknown file format");
2516      return result.Produce();      return result.Produce();
2517  }  }
2518    

Legend:
Removed from v.1535  
changed lines
  Added in v.1536

  ViewVC Help
Powered by ViewVC