FIX: [droid] cpu load info with vanilla ndk
authorChris "Koying" Browet <cbro@semperpax.com>
Sat, 28 Dec 2013 19:40:03 +0000 (20:40 +0100)
committerChris "Koying" Browet <cbro@semperpax.com>
Sat, 28 Dec 2013 19:48:33 +0000 (20:48 +0100)
xbmc/utils/CPUInfo.cpp

index f47ab62..f3f275f 100644 (file)
@@ -685,8 +685,16 @@ bool CCPUInfo::readProcStat(unsigned long long& user, unsigned long long& nice,
   if (m_fProcStat == NULL)
     return false;
 
+#ifdef TARGET_ANDROID
+  // Just another (vanilla) NDK quirk:
+  // rewind + fflush do not actually flush the buffers,
+  // the same initial content is returned rather than re-read
+  fclose(m_fProcStat);
+  m_fProcStat = fopen("/proc/stat", "r");
+#else
   rewind(m_fProcStat);
   fflush(m_fProcStat);
+#endif
 
   char buf[256];
   if (!fgets(buf, sizeof(buf), m_fProcStat))