summaryrefslogtreecommitdiffstats
path: root/media/java
diff options
context:
space:
mode:
authorAnurag Singh <anursing@codeaurora.org>2012-03-04 00:02:36 +0100
committerGiulio Cervera <giulio.cervera@gmail.com>2012-03-04 00:02:44 +0100
commitc6dd471df320fbacf336760cb094b7d751c2fe61 (patch)
tree18e0f754902a8ae17bcda408fdf43ec7fc439b3c /media/java
parent377a18a6dcb37422815aa69b4776ff934e3a936d (diff)
downloadframeworks_base-c6dd471df320fbacf336760cb094b7d751c2fe61.zip
frameworks_base-c6dd471df320fbacf336760cb094b7d751c2fe61.tar.gz
frameworks_base-c6dd471df320fbacf336760cb094b7d751c2fe61.tar.bz2
frameworks/base: Vote to turn off io_is_busy during recording.
When recording starts, vote to turn off io_is_busy. After recording stops, take out that vote so that io_is_busy can go to its original value. Doing this saves power by reducing the amount of time for which the CPU runs at high frequencies when encoded data is being written to the SD card - a process that causes io_wait times to shoot up. With io_is_busy turned off, these wait times will not be considered as CPU busy time and so the ondemand governor will not unnecessarily bump up the clock rate. The votes are handled by the CpuGovernorService. Also move the dynamic sampling rate and vote processor classes out of the CpuGovernorService to improve modularity.
Diffstat (limited to 'media/java')
-rw-r--r--media/java/android/media/MediaRecorder.java40
1 files changed, 37 insertions, 3 deletions
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index 08e6032..2afaea5 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -22,6 +22,10 @@ import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.Surface;
+import android.app.Application;
+import android.app.ActivityThread;
+import android.content.Context;
+import android.content.Intent;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
@@ -76,8 +80,10 @@ public class MediaRecorder
System.loadLibrary("media_jni");
native_init();
}
- private final static String TAG = "MediaRecorder";
+ private final static String TAG = "MediaRecorder";
+ private final static String IOBUSY_VOTE = "com.android.server.CpuGovernorService.action.IOBUSY_VOTE";
+ private final static String IOBUSY_UNVOTE = "com.android.server.CpuGovernorService.action.IOBUSY_UNVOTE";
// The two fields below are accessed by native methods
@SuppressWarnings("unused")
private int mNativeContext;
@@ -654,7 +660,7 @@ public class MediaRecorder
* @throws IllegalStateException if it is called before
* prepare().
*/
- public native void start() throws IllegalStateException;
+ public native void native_start() throws IllegalStateException;
/**
* Stops recording. Call this after start(). Once recording is stopped,
@@ -668,7 +674,35 @@ public class MediaRecorder
*
* @throws IllegalStateException if it is called before start()
*/
- public native void stop() throws IllegalStateException;
+ public native void native_stop() throws IllegalStateException;
+
+ public void start() throws IllegalStateException {
+ try {
+ Application application = ActivityThread.systemMain().getApplication();
+ Intent ioBusyVoteIntent = new Intent(IOBUSY_VOTE);
+ // Vote for io_is_busy to be turned off.
+ ioBusyVoteIntent.putExtra("com.android.server.CpuGovernorService.voteType", 0);
+ application.sendBroadcast(ioBusyVoteIntent);
+ } catch (Exception exception) {
+ Log.e(TAG, "Unable to vote to turn io_is_busy off.");
+ }
+
+ native_start();
+ }
+
+ public void stop() throws IllegalStateException {
+ try {
+ Application application = ActivityThread.systemMain().getApplication();
+ Intent ioBusyUnVoteIntent = new Intent(IOBUSY_UNVOTE);
+ // Remove vote for io_is_busy to be turned off.
+ ioBusyUnVoteIntent.putExtra("com.android.server.CpuGovernorService.voteType", 0);
+ application.sendBroadcast(ioBusyUnVoteIntent);
+ } catch (Exception exception) {
+ Log.e(TAG, "Unable to withdraw io_is_busy off vote.");
+ }
+
+ native_stop();
+ }
/**
* Restarts the MediaRecorder to its idle state. After calling