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-2012 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 * |
58 |
#define INADDR_NONE 0xffffffff |
#define INADDR_NONE 0xffffffff |
59 |
#endif |
#endif |
60 |
|
|
61 |
|
typedef unsigned long in_addr_t; |
62 |
|
|
63 |
int inet_aton(const char *cp, struct in_addr *addr) |
int inet_aton(const char *cp, struct in_addr *addr) |
64 |
{ |
{ |
65 |
addr->s_addr = inet_addr(cp); |
addr->s_addr = inet_addr(cp); |
102 |
if (bShowStackTrace) { |
if (bShowStackTrace) { |
103 |
#if defined(WIN32) |
#if defined(WIN32) |
104 |
// FIXME: sigaction() not supported on WIN32, we ignore it for now |
// FIXME: sigaction() not supported on WIN32, we ignore it for now |
105 |
|
#elif AC_APPLE_UNIVERSAL_BUILD |
106 |
|
// not used for Xcode |
107 |
#else |
#else |
108 |
StackTraceInit(argv[0], -1); |
StackTraceInit(argv[0], -1); |
109 |
// register signal handler for all unusual signals |
// register signal handler for all unusual signals |
123 |
|
|
124 |
dmsg(1,("LinuxSampler %s\n", VERSION)); |
dmsg(1,("LinuxSampler %s\n", VERSION)); |
125 |
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")); |
126 |
dmsg(1,("Copyright (C) 2005-2012 Christian Schoenebeck\n")); |
dmsg(1,("Copyright (C) 2005-2016 Christian Schoenebeck\n")); |
127 |
|
dmsg(1,("Binary built: " __DATE__ "\n")) |
128 |
|
|
129 |
#if defined(WIN32) |
#if defined(WIN32) |
130 |
#if 0 |
#if 0 |
200 |
|
|
201 |
// start LSCP network server |
// start LSCP network server |
202 |
struct in_addr addr; |
struct in_addr addr; |
203 |
addr.s_addr = lscp_addr; |
addr.s_addr = (in_addr_t)lscp_addr; |
204 |
dmsg(1,("Starting LSCP network server (%s:%d)...", inet_ntoa(addr), ntohs(lscp_port))); |
dmsg(1,("Starting LSCP network server (%s:%d)...", inet_ntoa(addr), ntohs(lscp_port))); |
205 |
pLSCPServer = new LSCPServer(pSampler, lscp_addr, lscp_port); |
pLSCPServer = new LSCPServer(pSampler, lscp_addr, lscp_port); |
206 |
pLSCPServer->StartThread(); |
pLSCPServer->StartThread(); |
225 |
} |
} |
226 |
} |
} |
227 |
|
|
228 |
|
//TODO: (hopefully) just a temporary nasty hack for launching gigedit on the main thread on Mac (see comments in gigedit.cpp for details) |
229 |
|
#if defined(__APPLE__) |
230 |
|
g_mainThreadCallbackSupported = true; |
231 |
|
#endif |
232 |
|
|
233 |
while (atomic_read(&running)) { |
while (atomic_read(&running)) { |
234 |
if (bPrintStatistics) { |
if (bPrintStatistics) { |
235 |
const std::set<Engine*>& engines = EngineFactory::EngineInstances(); |
const std::set<Engine*>& engines = EngineFactory::EngineInstances(); |
257 |
} |
} |
258 |
|
|
259 |
pSampler->fireStatistics(); |
pSampler->fireStatistics(); |
260 |
|
|
261 |
|
//TODO: (hopefully) just a temporary nasty hack for launching gigedit on the main thread on Mac (see comments in gigedit.cpp for details) |
262 |
|
#if defined(__APPLE__) |
263 |
|
if (g_fireMainThreadCallback && g_mainThreadCallback) { |
264 |
|
void (*fn)(void* info) = g_mainThreadCallback; |
265 |
|
void* info = g_mainThreadCallbackInfo; |
266 |
|
g_mainThreadCallbackInfo = NULL; |
267 |
|
g_mainThreadCallback = NULL; |
268 |
|
g_fireMainThreadCallback = false; |
269 |
|
printf("Received main thread callback, calling now ...\n"); fflush(stdout); |
270 |
|
(*fn)(info); |
271 |
|
printf("Main thread callback executed.\n"); fflush(stdout); |
272 |
|
} |
273 |
|
#endif |
274 |
} |
} |
275 |
|
//#endif |
276 |
if (pLSCPServer) pLSCPServer->StopThread(); |
if (pLSCPServer) pLSCPServer->StopThread(); |
277 |
// the delete order here is important: the Sampler |
// the delete order here is important: the Sampler |
278 |
// destructor sends notifications to the lscpserver |
// destructor sends notifications to the lscpserver |
317 |
signal(iSignal, SIG_DFL); // Reinstall default handler to prevent race conditions |
signal(iSignal, SIG_DFL); // Reinstall default handler to prevent race conditions |
318 |
if (bShowStackTrace) { |
if (bShowStackTrace) { |
319 |
std::cerr << "Showing stack trace...\n" << std::flush; |
std::cerr << "Showing stack trace...\n" << std::flush; |
320 |
|
#if !AC_APPLE_UNIVERSAL_BUILD |
321 |
StackTrace(); |
StackTrace(); |
322 |
|
#endif |
323 |
sleep(2); |
sleep(2); |
324 |
} |
} |
325 |
std::cerr << "Killing LinuxSampler...\n" << std::flush; |
std::cerr << "Killing LinuxSampler...\n" << std::flush; |
460 |
} |
} |
461 |
case 8: {// --lscp-port |
case 8: {// --lscp-port |
462 |
long unsigned int port = 0; |
long unsigned int port = 0; |
463 |
if ((sscanf(optarg, "%u", &port) != 1) || (port == 0) || (port > 65535)) |
if ((sscanf(optarg, "%lu", &port) != 1) || (port == 0) || (port > 65535)) |
464 |
printf("WARNING: Failed to parse lscp-port argument, ignoring!\n"); |
printf("WARNING: Failed to parse lscp-port argument, ignoring!\n"); |
465 |
else |
else |
466 |
lscp_port = htons(port); |
lscp_port = htons(port); |