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-2009 Christian Schoenebeck * |
* Copyright (C) 2005-2016 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program 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 * |
23 |
|
|
24 |
#include <getopt.h> |
#include <getopt.h> |
25 |
#include <signal.h> |
#include <signal.h> |
26 |
|
#include <sys/stat.h> |
27 |
|
|
28 |
#if defined(WIN32) |
#if defined(WIN32) |
29 |
// require at least Windows 2000 for the GlobalMemoryStatusEx() call |
// require at least Windows 2000 for the GlobalMemoryStatusEx() call |
41 |
#include "plugins/InstrumentEditorFactory.h" |
#include "plugins/InstrumentEditorFactory.h" |
42 |
#include "drivers/midi/MidiInputDeviceFactory.h" |
#include "drivers/midi/MidiInputDeviceFactory.h" |
43 |
#include "drivers/audio/AudioOutputDeviceFactory.h" |
#include "drivers/audio/AudioOutputDeviceFactory.h" |
44 |
|
#include "effects/EffectFactory.h" |
45 |
#include "engines/gig/Profiler.h" |
#include "engines/gig/Profiler.h" |
46 |
#include "network/lscpserver.h" |
#include "network/lscpserver.h" |
47 |
#include "common/stacktrace.h" |
#include "common/stacktrace.h" |
73 |
static bool bShowStackTrace = false; |
static bool bShowStackTrace = false; |
74 |
unsigned long int lscp_addr; |
unsigned long int lscp_addr; |
75 |
unsigned short int lscp_port; |
unsigned short int lscp_port; |
76 |
|
String ExecAfterInit; |
77 |
|
|
78 |
void parse_options(int argc, char **argv); |
void parse_options(int argc, char **argv); |
79 |
void signal_handler(int signal); |
void signal_handler(int signal); |
119 |
|
|
120 |
dmsg(1,("LinuxSampler %s\n", VERSION)); |
dmsg(1,("LinuxSampler %s\n", VERSION)); |
121 |
dmsg(1,("Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck\n")); |
dmsg(1,("Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck\n")); |
122 |
dmsg(1,("Copyright (C) 2005-2009 Christian Schoenebeck\n")); |
dmsg(1,("Copyright (C) 2005-2016 Christian Schoenebeck\n")); |
123 |
|
dmsg(1,("Binary built: " __DATE__ "\n")) |
124 |
|
|
125 |
#if defined(WIN32) |
#if defined(WIN32) |
126 |
#if 0 |
#if 0 |
191 |
dmsg(1,("Registered MIDI input drivers: %s\n", MidiInputDeviceFactory::AvailableDriversAsString().c_str())); |
dmsg(1,("Registered MIDI input drivers: %s\n", MidiInputDeviceFactory::AvailableDriversAsString().c_str())); |
192 |
dmsg(1,("Registered audio output drivers: %s\n", AudioOutputDeviceFactory::AvailableDriversAsString().c_str())); |
dmsg(1,("Registered audio output drivers: %s\n", AudioOutputDeviceFactory::AvailableDriversAsString().c_str())); |
193 |
dmsg(1,("Registered instrument editors: %s\n", InstrumentEditorFactory::AvailableEditorsAsString().c_str())); |
dmsg(1,("Registered instrument editors: %s\n", InstrumentEditorFactory::AvailableEditorsAsString().c_str())); |
194 |
|
dmsg(1,("Registered internal effect systems: %s\n", EffectFactory::AvailableEffectSystemsAsString().c_str())); |
195 |
|
dmsg(1,("Registered internal effects: %d\n", EffectFactory::AvailableEffectsCount())); |
196 |
|
|
197 |
// start LSCP network server |
// start LSCP network server |
198 |
struct in_addr addr; |
struct in_addr addr; |
213 |
} |
} |
214 |
|
|
215 |
printf("LinuxSampler initialization completed. :-)\n\n"); |
printf("LinuxSampler initialization completed. :-)\n\n"); |
216 |
|
|
217 |
|
if (ExecAfterInit != "") { |
218 |
|
printf("Executing command: %s\n\n", ExecAfterInit.c_str()); |
219 |
|
if (system(ExecAfterInit.c_str()) == -1) { |
220 |
|
std::cerr << "Failed to execute the command" << std::endl; |
221 |
|
} |
222 |
|
} |
223 |
|
|
224 |
|
//TODO: (hopefully) just a temporary nasty hack for launching gigedit on the main thread on Mac (see comments in gigedit.cpp for details) |
225 |
|
#if defined(__APPLE__) |
226 |
|
g_mainThreadCallbackSupported = true; |
227 |
|
#endif |
228 |
|
|
229 |
while (atomic_read(&running)) { |
while (atomic_read(&running)) { |
230 |
if (bPrintStatistics) { |
if (bPrintStatistics) { |
253 |
} |
} |
254 |
|
|
255 |
pSampler->fireStatistics(); |
pSampler->fireStatistics(); |
256 |
|
|
257 |
|
//TODO: (hopefully) just a temporary nasty hack for launching gigedit on the main thread on Mac (see comments in gigedit.cpp for details) |
258 |
|
#if defined(__APPLE__) |
259 |
|
if (g_fireMainThreadCallback && g_mainThreadCallback) { |
260 |
|
void (*fn)(void* info) = g_mainThreadCallback; |
261 |
|
void* info = g_mainThreadCallbackInfo; |
262 |
|
g_mainThreadCallbackInfo = NULL; |
263 |
|
g_mainThreadCallback = NULL; |
264 |
|
g_fireMainThreadCallback = false; |
265 |
|
printf("Received main thread callback, calling now ...\n"); fflush(stdout); |
266 |
|
(*fn)(info); |
267 |
|
printf("Main thread callback executed.\n"); fflush(stdout); |
268 |
|
} |
269 |
|
#endif |
270 |
} |
} |
271 |
|
//#endif |
272 |
if (pLSCPServer) pLSCPServer->StopThread(); |
if (pLSCPServer) pLSCPServer->StopThread(); |
273 |
// the delete order here is important: the Sampler |
// the delete order here is important: the Sampler |
274 |
// destructor sends notifications to the lscpserver |
// destructor sends notifications to the lscpserver |
344 |
{"lscp-addr",1,0,0}, |
{"lscp-addr",1,0,0}, |
345 |
{"lscp-port",1,0,0}, |
{"lscp-port",1,0,0}, |
346 |
{"stacktrace",0,0,0}, |
{"stacktrace",0,0,0}, |
347 |
|
{"exec-after-init",1,0,0}, |
348 |
{0,0,0,0} |
{0,0,0,0} |
349 |
}; |
}; |
350 |
|
|
370 |
printf("--instruments-db-location specifies the instruments DB file\n"); |
printf("--instruments-db-location specifies the instruments DB file\n"); |
371 |
printf("--stacktrace automatically shows stacktrace if crashes\n"); |
printf("--stacktrace automatically shows stacktrace if crashes\n"); |
372 |
printf(" (broken on most systems at the moment)\n"); |
printf(" (broken on most systems at the moment)\n"); |
373 |
|
printf("--exec-after-init executes a command after initialization\n"); |
374 |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
375 |
break; |
break; |
376 |
case 1: // --version |
case 1: // --version |
379 |
break; |
break; |
380 |
case 2: // --profile |
case 2: // --profile |
381 |
profile = true; |
profile = true; |
382 |
|
//FIXME: profiling code is currently broken! |
383 |
|
std::cerr << "Option '--profile' is currently not supported, since the profiling code is currently broken!" << std::endl; |
384 |
|
exit(EXIT_FAILURE); |
385 |
break; |
break; |
386 |
case 3: // --no-tune |
case 3: // --no-tune |
387 |
tune = false; |
tune = false; |
454 |
} |
} |
455 |
case 8: {// --lscp-port |
case 8: {// --lscp-port |
456 |
long unsigned int port = 0; |
long unsigned int port = 0; |
457 |
if ((sscanf(optarg, "%u", &port) != 1) || (port == 0) || (port > 65535)) |
if ((sscanf(optarg, "%lu", &port) != 1) || (port == 0) || (port > 65535)) |
458 |
printf("WARNING: Failed to parse lscp-port argument, ignoring!\n"); |
printf("WARNING: Failed to parse lscp-port argument, ignoring!\n"); |
459 |
else |
else |
460 |
lscp_port = htons(port); |
lscp_port = htons(port); |
463 |
case 9: // --stacktrace |
case 9: // --stacktrace |
464 |
bShowStackTrace = true; |
bShowStackTrace = true; |
465 |
break; |
break; |
466 |
|
case 10: // --exec-after-init |
467 |
|
ExecAfterInit = optarg; |
468 |
|
break; |
469 |
} |
} |
470 |
} |
} |
471 |
} |
} |