summaryrefslogtreecommitdiff
path: root/src/memchecker.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-05-21 18:00:42 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-05-21 18:00:42 +0200
commit6a12513e42e7fbd5883bf2c9f55defe24f802ed1 (patch)
tree67e8848f695492b2aeea8cd213ba00dacd83c2e5 /src/memchecker.cc
parentfc041fd9566acb756b2d3b7b36ba963ccb00c388 (diff)
Experimental new platform detection code used in memchecker.
Diffstat (limited to 'src/memchecker.cc')
-rw-r--r--src/memchecker.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/memchecker.cc b/src/memchecker.cc
index 1110e69..81c9da7 100644
--- a/src/memchecker.cc
+++ b/src/memchecker.cc
@@ -26,12 +26,12 @@
*/
#include "memchecker.h"
-#ifdef WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#else
+#include "platform.h"
+
+#if DG_PLATFORM == DG_PLATFORM_LINUX
#include <sys/sysinfo.h>
#endif
+
#include <sndfile.h>
#include <hugin.hpp>
@@ -48,15 +48,19 @@ uint64_t MemChecker::calcFreeMemory() const
uint64_t free_memory = 0;
// Platform specific calculation of the amount of free memory.
-#ifdef WIN32
+#if DG_PLATFORM == DG_PLATFORM_LINUX
+ struct sysinfo sys_info;
+ sysinfo(&sys_info);
+ free_memory = sys_info.freeram * sys_info.mem_unit;
+#elif DG_PLATFORM == DG_PLATFORM_WINDOWS
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
GlobalMemoryStatusEx(&status);
free_memory = status.ullAvailPhys;
-#else
- struct sysinfo sys_info;
- sysinfo(&sys_info);
- free_memory = sys_info.freeram * sys_info.mem_unit;
+#elif DG_PLATFORM == DG_PLATFORM_OSX
+ // TODO
+#elif DG_PLATFORM == DG_PLATFORM_UNIX
+ // TODO
#endif
DEBUG(memchecker, "Calculated %" PRIu64 " free memory.\n", free_memory);
@@ -92,7 +96,8 @@ uint64_t MemChecker::calcBytesPerChannel(const std::string& filename) const
SNDFILE* f = sf_open(filename.c_str(), SFM_READ, &sf_info);
if(!f)
{
- ERR(memchecker, "SNDFILE Error (%s): %s\n", filename.c_str(), sf_strerror(f));
+ ERR(memchecker, "SNDFILE Error (%s): %s\n",
+ filename.c_str(), sf_strerror(f));
return 0;
}