--- linuxsampler/trunk/src/linuxsampler.cpp 2009/05/03 12:15:40 1895 +++ linuxsampler/trunk/src/linuxsampler.cpp 2016/01/06 10:02:40 2856 @@ -3,7 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003-2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005-2009 Christian Schoenebeck * + * Copyright (C) 2005-2016 Christian Schoenebeck * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -23,6 +23,7 @@ #include #include +#include #if defined(WIN32) // require at least Windows 2000 for the GlobalMemoryStatusEx() call @@ -40,6 +41,7 @@ #include "plugins/InstrumentEditorFactory.h" #include "drivers/midi/MidiInputDeviceFactory.h" #include "drivers/audio/AudioOutputDeviceFactory.h" +#include "effects/EffectFactory.h" #include "engines/gig/Profiler.h" #include "network/lscpserver.h" #include "common/stacktrace.h" @@ -71,6 +73,7 @@ static bool bShowStackTrace = false; unsigned long int lscp_addr; unsigned short int lscp_port; +String ExecAfterInit; void parse_options(int argc, char **argv); void signal_handler(int signal); @@ -116,7 +119,7 @@ dmsg(1,("LinuxSampler %s\n", VERSION)); dmsg(1,("Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck\n")); - dmsg(1,("Copyright (C) 2005-2009 Christian Schoenebeck\n")); + dmsg(1,("Copyright (C) 2005-2016 Christian Schoenebeck\n")); #if defined(WIN32) #if 0 @@ -187,6 +190,8 @@ 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())); + dmsg(1,("Registered internal effect systems: %s\n", EffectFactory::AvailableEffectSystemsAsString().c_str())); + dmsg(1,("Registered internal effects: %d\n", EffectFactory::AvailableEffectsCount())); // start LSCP network server struct in_addr addr; @@ -207,6 +212,18 @@ } printf("LinuxSampler initialization completed. :-)\n\n"); + + if (ExecAfterInit != "") { + printf("Executing command: %s\n\n", ExecAfterInit.c_str()); + if (system(ExecAfterInit.c_str()) == -1) { + std::cerr << "Failed to execute the command" << std::endl; + } + } + +//TODO: (hopefully) just a temporary nasty hack for launching gigedit on the main thread on Mac (see comments in gigedit.cpp for details) +#if defined(__APPLE__) + g_mainThreadCallbackSupported = true; +#endif while (atomic_read(&running)) { if (bPrintStatistics) { @@ -235,7 +252,22 @@ } pSampler->fireStatistics(); + + //TODO: (hopefully) just a temporary nasty hack for launching gigedit on the main thread on Mac (see comments in gigedit.cpp for details) + #if defined(__APPLE__) + if (g_fireMainThreadCallback && g_mainThreadCallback) { + void (*fn)(void* info) = g_mainThreadCallback; + void* info = g_mainThreadCallbackInfo; + g_mainThreadCallbackInfo = NULL; + g_mainThreadCallback = NULL; + g_fireMainThreadCallback = false; + printf("Received main thread callback, calling now ...\n"); fflush(stdout); + (*fn)(info); + printf("Main thread callback executed.\n"); fflush(stdout); + } + #endif } +//#endif if (pLSCPServer) pLSCPServer->StopThread(); // the delete order here is important: the Sampler // destructor sends notifications to the lscpserver @@ -311,6 +343,7 @@ {"lscp-addr",1,0,0}, {"lscp-port",1,0,0}, {"stacktrace",0,0,0}, + {"exec-after-init",1,0,0}, {0,0,0,0} }; @@ -336,6 +369,7 @@ printf("--instruments-db-location specifies the instruments DB file\n"); printf("--stacktrace automatically shows stacktrace if crashes\n"); printf(" (broken on most systems at the moment)\n"); + printf("--exec-after-init executes a command after initialization\n"); exit(EXIT_SUCCESS); break; case 1: // --version @@ -344,6 +378,9 @@ break; case 2: // --profile profile = true; + //FIXME: profiling code is currently broken! + std::cerr << "Option '--profile' is currently not supported, since the profiling code is currently broken!" << std::endl; + exit(EXIT_FAILURE); break; case 3: // --no-tune tune = false; @@ -416,7 +453,7 @@ } case 8: {// --lscp-port long unsigned int port = 0; - if ((sscanf(optarg, "%u", &port) != 1) || (port == 0) || (port > 65535)) + if ((sscanf(optarg, "%lu", &port) != 1) || (port == 0) || (port > 65535)) printf("WARNING: Failed to parse lscp-port argument, ignoring!\n"); else lscp_port = htons(port); @@ -425,6 +462,9 @@ case 9: // --stacktrace bShowStackTrace = true; break; + case 10: // --exec-after-init + ExecAfterInit = optarg; + break; } } }