The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. // (This file gets included by juce_android_NativeCode.cpp, rather than being
  19. // compiled on its own).
  20. #if JUCE_INCLUDED_FILE
  21. //==============================================================================
  22. SystemStats::OperatingSystemType SystemStats::getOperatingSystemType()
  23. {
  24. return Android;
  25. }
  26. const String SystemStats::getOperatingSystemName()
  27. {
  28. return "Android";
  29. }
  30. bool SystemStats::isOperatingSystem64Bit()
  31. {
  32. #if JUCE_64BIT
  33. return true;
  34. #else
  35. return false;
  36. #endif
  37. }
  38. //==============================================================================
  39. namespace AndroidStatsHelpers
  40. {
  41. // TODO
  42. const String getCpuInfo (const char* const key)
  43. {
  44. StringArray lines;
  45. lines.addLines (File ("/proc/cpuinfo").loadFileAsString());
  46. for (int i = lines.size(); --i >= 0;) // (NB - it's important that this runs in reverse order)
  47. if (lines[i].startsWithIgnoreCase (key))
  48. return lines[i].fromFirstOccurrenceOf (":", false, false).trim();
  49. return String::empty;
  50. }
  51. }
  52. const String SystemStats::getCpuVendor()
  53. {
  54. return AndroidStatsHelpers::getCpuInfo ("vendor_id");
  55. }
  56. int SystemStats::getCpuSpeedInMegaherz()
  57. {
  58. return roundToInt (AndroidStatsHelpers::getCpuInfo ("cpu MHz").getFloatValue());
  59. }
  60. int SystemStats::getMemorySizeInMegabytes()
  61. {
  62. // TODO
  63. struct sysinfo sysi;
  64. if (sysinfo (&sysi) == 0)
  65. return (sysi.totalram * sysi.mem_unit / (1024 * 1024));
  66. return 0;
  67. }
  68. int SystemStats::getPageSize()
  69. {
  70. // TODO
  71. return sysconf (_SC_PAGESIZE);
  72. }
  73. //==============================================================================
  74. const String SystemStats::getLogonName()
  75. {
  76. // TODO
  77. const char* user = getenv ("USER");
  78. if (user == 0)
  79. {
  80. struct passwd* const pw = getpwuid (getuid());
  81. if (pw != 0)
  82. user = pw->pw_name;
  83. }
  84. return String::fromUTF8 (user);
  85. }
  86. const String SystemStats::getFullUserName()
  87. {
  88. return getLogonName();
  89. }
  90. //==============================================================================
  91. void SystemStats::initialiseStats()
  92. {
  93. // TODO
  94. const String flags (AndroidStatsHelpers::getCpuInfo ("flags"));
  95. cpuFlags.hasMMX = flags.contains ("mmx");
  96. cpuFlags.hasSSE = flags.contains ("sse");
  97. cpuFlags.hasSSE2 = flags.contains ("sse2");
  98. cpuFlags.has3DNow = flags.contains ("3dnow");
  99. // TODO
  100. cpuFlags.numCpus = AndroidStatsHelpers::getCpuInfo ("processor").getIntValue() + 1;
  101. }
  102. void PlatformUtilities::fpuReset() {}
  103. //==============================================================================
  104. uint32 juce_millisecondsSinceStartup() throw()
  105. {
  106. // TODO
  107. timespec t;
  108. clock_gettime (CLOCK_MONOTONIC, &t);
  109. return t.tv_sec * 1000 + t.tv_nsec / 1000000;
  110. }
  111. int64 Time::getHighResolutionTicks() throw()
  112. {
  113. // TODO
  114. timespec t;
  115. clock_gettime (CLOCK_MONOTONIC, &t);
  116. return (t.tv_sec * (int64) 1000000) + (t.tv_nsec / (int64) 1000);
  117. }
  118. int64 Time::getHighResolutionTicksPerSecond() throw()
  119. {
  120. // TODO
  121. return 1000000; // (microseconds)
  122. }
  123. double Time::getMillisecondCounterHiRes() throw()
  124. {
  125. return getHighResolutionTicks() * 0.001;
  126. }
  127. bool Time::setSystemTimeToThisTime() const
  128. {
  129. jassertfalse;
  130. return false;
  131. }
  132. #endif