Chris@150: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@150: Chris@150: /* Chris@150: Sonic Visualiser Chris@150: An audio file viewer and annotation editor. Chris@150: Centre for Digital Music, Queen Mary, University of London. Chris@202: This file copyright 2006 Chris Cannam and QMUL. Chris@150: Chris@150: This program is free software; you can redistribute it and/or Chris@150: modify it under the terms of the GNU General Public License as Chris@150: published by the Free Software Foundation; either version 2 of the Chris@150: License, or (at your option) any later version. See the file Chris@150: COPYING included with this distribution for more information. Chris@150: */ Chris@150: Chris@150: #ifndef _SYSTEM_H_ Chris@150: #define _SYSTEM_H_ Chris@150: Chris@150: #ifdef _WIN32 Chris@150: Chris@150: #include Chris@150: #include Chris@150: #include Chris@150: Chris@150: #define MLOCK(a,b) 1 Chris@150: #define MUNLOCK(a,b) 1 Chris@150: #define MUNLOCK_SAMPLEBLOCK(a) 1 Chris@368: #define MUNLOCKALL() 1 Chris@150: Chris@150: #define DLOPEN(a,b) LoadLibrary((a).toStdWString().c_str()) Chris@150: #define DLSYM(a,b) GetProcAddress((HINSTANCE)(a),(b)) Chris@223: #define DLCLOSE(a) (!FreeLibrary((HINSTANCE)(a))) Chris@150: #define DLERROR() "" Chris@150: Chris@150: #define PLUGIN_GLOB "*.dll" Chris@223: #define PATH_SEPARATOR ';' Chris@186: Chris@219: // The default Vamp plugin path is obtained from a function in the Chris@219: // Vamp SDK (Vamp::PluginHostAdapter::getPluginPath). Chris@186: Chris@219: // At the time of writing, at least, the vast majority of LADSPA Chris@219: // plugins on Windows hosts will have been put there for use in Chris@219: // Audacity. It's a bit of a shame that Audacity uses its own Program Chris@219: // Files directory for plugins that any host may want to use... maybe Chris@219: // they were just following the example of VSTs, which are usually Chris@219: // found in Steinberg's Program Files directory. Anyway, we can Chris@219: // greatly increase our chances of picking up some LADSPA plugins by Chris@219: // default if we include the Audacity plugin location as well as an Chris@219: // (imho) more sensible place. Chris@219: Chris@223: #define DEFAULT_LADSPA_PATH "%ProgramFiles%\\LADSPA Plugins;%ProgramFiles%\\Audacity\\Plug-Ins" Chris@186: #define DEFAULT_DSSI_PATH "%ProgramFiles%\\DSSI Plugins" Chris@150: Chris@150: #define getpid _getpid Chris@150: Chris@150: extern "C" { Chris@150: void usleep(unsigned long usec); Chris@501: int gettimeofday(struct timeval *p, void *tz); Chris@150: } Chris@150: Chris@150: #else Chris@150: Chris@150: #include Chris@150: #include Chris@150: Chris@150: #define MLOCK(a,b) ::mlock((a),(b)) Chris@150: #define MUNLOCK(a,b) (::munlock((a),(b)) ? (::perror("munlock failed"), 0) : 0) Chris@150: #define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0); Chris@232: //#define MLOCK(a,b) 1 Chris@232: //#define MUNLOCK(a,b) 1 Chris@232: //#define MUNLOCK_SAMPLEBLOCK(a) 1 Chris@150: Chris@150: #define DLOPEN(a,b) dlopen((a).toStdString().c_str(),(b)) Chris@150: #define DLSYM(a,b) dlsym((a),(b)) Chris@150: #define DLCLOSE(a) dlclose((a)) Chris@150: #define DLERROR() dlerror() Chris@150: Chris@150: #ifdef __APPLE__ Chris@150: Chris@255: #define PLUGIN_GLOB "*.dylib *.so" Chris@223: #define PATH_SEPARATOR ':' Chris@186: Chris@186: #define DEFAULT_LADSPA_PATH "$HOME/Library/Audio/Plug-Ins/LADSPA:/Library/Audio/Plug-Ins/LADSPA" Chris@186: #define DEFAULT_DSSI_PATH "$HOME/Library/Audio/Plug-Ins/DSSI:/Library/Audio/Plug-Ins/DSSI" Chris@150: Chris@368: #define MUNLOCKALL() 1 Chris@368: Chris@150: #else Chris@150: Chris@150: #define PLUGIN_GLOB "*.so" Chris@223: #define PATH_SEPARATOR ':' Chris@186: Chris@186: #define DEFAULT_LADSPA_PATH "$HOME/ladspa:$HOME/.ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa" Chris@186: #define DEFAULT_DSSI_PATH "$HOME/dssi:$HOME/.dssi:/usr/local/lib/dssi:/usr/lib/dssi" Chris@150: Chris@368: #define MUNLOCKALL() ::munlockall() Chris@368: Chris@150: #endif /* __APPLE__ */ Chris@150: Chris@150: #endif /* ! _WIN32 */ Chris@150: Chris@150: enum ProcessStatus { ProcessRunning, ProcessNotRunning, UnknownProcessStatus }; Chris@150: extern ProcessStatus GetProcessStatus(int pid); Chris@150: Chris@168: // Return a vague approximation to the number of free megabytes of real memory. Chris@168: // Return -1 if unknown. Chris@170: extern void GetRealMemoryMBAvailable(int &available, int &total); Chris@168: Chris@168: // Return a vague approximation to the number of free megabytes of disc space Chris@168: // on the partition containing the given path. Return -1 if unknown. Chris@168: extern int GetDiscSpaceMBAvailable(const char *path); Chris@168: Chris@303: extern void StoreStartupLocale(); Chris@303: extern void RestoreStartupLocale(); Chris@303: Chris@150: #include Chris@150: Chris@150: extern double mod(double x, double y); Chris@150: extern float modf(float x, float y); Chris@150: Chris@150: extern double princarg(double a); Chris@150: extern float princargf(float a); Chris@150: Chris@573: #ifdef USE_POW_NO_F Chris@573: #define powf pow Chris@573: #endif Chris@573: Chris@150: #endif /* ! _SYSTEM_H_ */ Chris@150: Chris@150: