--- linuxsampler/trunk/src/linuxsampler.cpp 2007/05/16 14:22:26 1187 +++ linuxsampler/trunk/src/linuxsampler.cpp 2007/10/03 18:41:09 1375 @@ -26,6 +26,7 @@ #include "Sampler.h" #include "engines/EngineFactory.h" +#include "plugins/InstrumentEditorFactory.h" #include "drivers/midi/MidiInputDeviceFactory.h" #include "drivers/audio/AudioOutputDeviceFactory.h" #include "engines/gig/Profiler.h" @@ -99,6 +100,7 @@ dmsg(1,("Registered sampler engines: %s\n", EngineFactory::AvailableEngineTypesAsString().c_str())); dmsg(1,("Registered MIDI input drivers: %s\n", MidiInputDeviceFactory::AvailableDriversAsString().c_str())); dmsg(1,("Registered audio output drivers: %s\n", AudioOutputDeviceFactory::AvailableDriversAsString().c_str())); + dmsg(1,("Registered instrument editors: %s\n", InstrumentEditorFactory::AvailableEditorsAsString().c_str())); // start LSCP network server struct in_addr addr; @@ -163,8 +165,8 @@ if (!pEngineChannel) continue; Engine* pEngine = pEngineChannel->GetEngine(); if (!pEngine) continue; - pSampler->fireVoiceCountChanged(iter->first, pEngine->VoiceCount()); - pSampler->fireStreamCountChanged(iter->first, pEngine->DiskStreamCount()); + pSampler->fireVoiceCountChanged(iter->first, pEngineChannel->GetVoiceCount()); + pSampler->fireStreamCountChanged(iter->first, pEngineChannel->GetDiskStreamCount()); pSampler->fireBufferFillChanged(iter->first, pEngine->DiskStreamBufferFillPercentage()); pSampler->fireTotalVoiceCountChanged(pSampler->GetVoiceCount()); } @@ -180,11 +182,11 @@ switch (iSignal) { case SIGINT: { if (pthread_equal(pthread_self(), main_thread)) { - if (pLSCPServer) { - pLSCPServer->StopThread(); - delete pLSCPServer; - } + if (pLSCPServer) pLSCPServer->StopThread(); + // the delete order here is important: the Sampler + // destructor sends notifications to the lscpserver if (pSampler) delete pSampler; + if (pLSCPServer) delete pLSCPServer; #if HAVE_SQLITE3 InstrumentsDb::Destroy(); #endif @@ -238,6 +240,7 @@ {"profile",0,0,0}, {"no-tune",0,0,0}, {"statistics",0,0,0}, + {"instruments-db-location",1,0,0}, {"create-instruments-db",1,0,0}, {"lscp-addr",1,0,0}, {"lscp-port",1,0,0}, @@ -255,14 +258,15 @@ switch(option_index) { case 0: // --help printf("usage: linuxsampler [OPTIONS]\n\n"); - printf("--help prints this message\n"); - printf("--version prints version information\n"); - printf("--profile profile synthesis algorithms\n"); - printf("--no-tune disable assembly optimization\n"); - printf("--statistics periodically prints statistics\n"); - printf("--lscp-addr set LSCP address (default: any)\n"); - printf("--lscp-port set LSCP port (default: 8888)\n"); - printf("--create-instruments-db creates an instruments DB\n"); + printf("--help prints this message\n"); + printf("--version prints version information\n"); + printf("--profile profile synthesis algorithms\n"); + printf("--no-tune disable assembly optimization\n"); + printf("--statistics periodically prints statistics\n"); + printf("--lscp-addr set LSCP address (default: any)\n"); + printf("--lscp-port set LSCP port (default: 8888)\n"); + printf("--create-instruments-db creates an instruments DB\n"); + printf("--instruments-db-location specifies the instruments DB file\n"); exit(EXIT_SUCCESS); break; case 1: // --version @@ -278,7 +282,40 @@ case 4: // --statistics bPrintStatistics = true; break; - case 5: // --create-instruments-db + case 5: // --instruments-db-location +#if HAVE_SQLITE3 + try { + if (optarg) { + struct stat statBuf; + int res = stat(optarg, &statBuf); + + if (res) { + std::stringstream ss; + ss << "Failed to stat `" << optarg << "`: " << strerror(errno); + throw Exception(ss.str()); + } + + if (!S_ISREG(statBuf.st_mode)) { + std::stringstream ss; + ss << "`" << optarg << "` is not a regular file"; + throw Exception(ss.str()); + } + + InstrumentsDb::GetInstrumentsDb()->SetDbFile(String(optarg)); + } + } catch(Exception e) { + std::cerr << "Could not open instruments DB file: " + << e.Message() << std::endl; + exit(EXIT_FAILURE); + } + break; +#else + std::cerr << "LinuxSampler was not build with "; + std::cerr << "instruments database support!\n"; + exit(EXIT_FAILURE); + break; +#endif + case 6: // --create-instruments-db #if HAVE_SQLITE3 try { if (optarg) { @@ -297,18 +334,18 @@ return; #else std::cerr << "Failed to create the database. LinuxSampler was "; - std::cerr << "not build with instruments database support." < 65535)) printf("WARNING: Failed to parse lscp-port argument, ignoring!\n");