System.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam and QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _SYSTEM_H_
00017 #define _SYSTEM_H_
00018 
00019 #ifdef _WIN32
00020 
00021 #include <windows.h>
00022 #include <malloc.h>
00023 #include <process.h>
00024 
00025 #define MLOCK(a,b)   1
00026 #define MUNLOCK(a,b) 1
00027 #define MUNLOCK_SAMPLEBLOCK(a) 1
00028 #define MUNLOCKALL() 1
00029 
00030 #define DLOPEN(a,b)  LoadLibrary((a).toStdWString().c_str())
00031 #define DLSYM(a,b)   GetProcAddress((HINSTANCE)(a),(b))
00032 #define DLCLOSE(a)   (!FreeLibrary((HINSTANCE)(a)))
00033 #define DLERROR()    ""
00034 
00035 #define PLUGIN_GLOB  "*.dll"
00036 #define PATH_SEPARATOR ';'
00037 
00038 // The default Vamp plugin path is obtained from a function in the
00039 // Vamp SDK (Vamp::PluginHostAdapter::getPluginPath).
00040 
00041 // At the time of writing, at least, the vast majority of LADSPA
00042 // plugins on Windows hosts will have been put there for use in
00043 // Audacity.  It's a bit of a shame that Audacity uses its own Program
00044 // Files directory for plugins that any host may want to use... maybe
00045 // they were just following the example of VSTs, which are usually
00046 // found in Steinberg's Program Files directory.  Anyway, we can
00047 // greatly increase our chances of picking up some LADSPA plugins by
00048 // default if we include the Audacity plugin location as well as an
00049 // (imho) more sensible place.
00050 
00051 #define DEFAULT_LADSPA_PATH "%ProgramFiles%\\LADSPA Plugins;%ProgramFiles%\\Audacity\\Plug-Ins"
00052 #define DEFAULT_DSSI_PATH   "%ProgramFiles%\\DSSI Plugins"
00053 
00054 #define getpid _getpid
00055 
00056 extern "C" {
00057 void usleep(unsigned long usec);
00058 void gettimeofday(struct timeval *p, void *tz);
00059 }
00060 
00061 #else
00062 
00063 #include <sys/mman.h>
00064 #include <dlfcn.h>
00065 
00066 #define MLOCK(a,b)   ::mlock((a),(b))
00067 #define MUNLOCK(a,b) (::munlock((a),(b)) ? (::perror("munlock failed"), 0) : 0)
00068 #define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0);
00069 //#define MLOCK(a,b)   1
00070 //#define MUNLOCK(a,b) 1
00071 //#define MUNLOCK_SAMPLEBLOCK(a) 1
00072 
00073 #define DLOPEN(a,b)  dlopen((a).toStdString().c_str(),(b))
00074 #define DLSYM(a,b)   dlsym((a),(b))
00075 #define DLCLOSE(a)   dlclose((a))
00076 #define DLERROR()    dlerror()
00077 
00078 #ifdef __APPLE__
00079 
00080 #define PLUGIN_GLOB  "*.dylib *.so"
00081 #define PATH_SEPARATOR ':'
00082 
00083 #define DEFAULT_LADSPA_PATH "$HOME/Library/Audio/Plug-Ins/LADSPA:/Library/Audio/Plug-Ins/LADSPA"
00084 #define DEFAULT_DSSI_PATH   "$HOME/Library/Audio/Plug-Ins/DSSI:/Library/Audio/Plug-Ins/DSSI"
00085 
00086 #define MUNLOCKALL() 1
00087 
00088 #else 
00089 
00090 #define PLUGIN_GLOB  "*.so"
00091 #define PATH_SEPARATOR ':'
00092 
00093 #define DEFAULT_LADSPA_PATH "$HOME/ladspa:$HOME/.ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa"
00094 #define DEFAULT_DSSI_PATH "$HOME/dssi:$HOME/.dssi:/usr/local/lib/dssi:/usr/lib/dssi"
00095 
00096 #define MUNLOCKALL() ::munlockall()
00097 
00098 #endif /* __APPLE__ */
00099 
00100 #endif /* ! _WIN32 */
00101 
00102 enum ProcessStatus { ProcessRunning, ProcessNotRunning, UnknownProcessStatus };
00103 extern ProcessStatus GetProcessStatus(int pid);
00104 
00105 // Return a vague approximation to the number of free megabytes of real memory.
00106 // Return -1 if unknown.
00107 extern void GetRealMemoryMBAvailable(int &available, int &total);
00108 
00109 // Return a vague approximation to the number of free megabytes of disc space
00110 // on the partition containing the given path.  Return -1 if unknown.
00111 extern int GetDiscSpaceMBAvailable(const char *path);
00112 
00113 extern void StoreStartupLocale();
00114 extern void RestoreStartupLocale();
00115 
00116 #include <cmath>
00117 
00118 extern double mod(double x, double y);
00119 extern float modf(float x, float y);
00120 
00121 extern double princarg(double a);
00122 extern float princargf(float a);
00123 
00124 #endif /* ! _SYSTEM_H_ */
00125 
00126 

Generated on Wed Feb 20 15:45:28 2008 for SonicVisualiser by  doxygen 1.5.1