[Android] LibVlcUtil: attempt to get maximum CPU frequency

Felix Abecassis git at videolan.org
Thu Jul 24 16:08:06 CEST 2014


vlc-ports/android | branch: master | Felix Abecassis <felix.abecassis at gmail.com> | Thu Jul 24 15:50:21 2014 +0200| [bba50cce7ad18b7aeae649f90d8a20bb73c5f83e] | committer: Felix Abecassis

LibVlcUtil: attempt to get maximum CPU frequency

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=bba50cce7ad18b7aeae649f90d8a20bb73c5f83e
---

 vlc-android/src/org/videolan/libvlc/LibVlcUtil.java |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/vlc-android/src/org/videolan/libvlc/LibVlcUtil.java b/vlc-android/src/org/videolan/libvlc/LibVlcUtil.java
index bf1024e..014aaf3 100644
--- a/vlc-android/src/org/videolan/libvlc/LibVlcUtil.java
+++ b/vlc-android/src/org/videolan/libvlc/LibVlcUtil.java
@@ -218,6 +218,20 @@ public class LibVlcUtil {
             }
         }
 
+        float frequency = 0.f;
+        try {
+            FileReader fileReader = new FileReader("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq");
+            BufferedReader br = new BufferedReader(fileReader);
+            try {
+                frequency = Float.parseFloat(br.readLine()) / 1000.f; /* Convert to MHz */
+            } catch(NumberFormatException e) {
+                /* keep default value of 0.f */
+            }
+            fileReader.close();
+        } catch(IOException ex) {
+            Log.w(TAG, "Could not find maximum CPU frequency.");
+        }
+
         errorMsg = null;
         isCompatible = true;
         // Store into MachineSpecs
@@ -230,6 +244,7 @@ public class LibVlcUtil {
         machineSpecs.hasX86 = hasX86;
         machineSpecs.bogoMIPS = bogoMIPS;
         machineSpecs.processors = processors;
+        machineSpecs.frequency = frequency;
         return true;
     }
 
@@ -246,6 +261,7 @@ public class LibVlcUtil {
         public boolean hasX86;
         public float bogoMIPS;
         public int processors;
+        public float frequency; /* in MHz */
     }
 
     private static final int EM_386 = 3;



More information about the Android mailing list