From 8b16b13ad2d14368b332c7ba5ad2cb6a7031581d Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Fri, 16 Jan 2015 18:47:57 +0100 Subject: [PATCH] added menu items to increase / decrease update rate default update rate is 2 updates per second --- app/src/main/java/xdsopl/robot36/Decoder.java | 6 +++++- app/src/main/java/xdsopl/robot36/MainActivity.java | 6 ++++++ app/src/main/res/menu/menu_main.xml | 4 ++++ app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/xdsopl/robot36/Decoder.java b/app/src/main/java/xdsopl/robot36/Decoder.java index 05e93f9..a8b4dcc 100644 --- a/app/src/main/java/xdsopl/robot36/Decoder.java +++ b/app/src/main/java/xdsopl/robot36/Decoder.java @@ -46,6 +46,7 @@ public class Decoder { private final int[] savedWidth; private final int[] savedHeight; private final float[] volume; + private int updateRate = 1; private final RenderScript rs; private final Allocation rsDecoderAudioBuffer; @@ -165,6 +166,9 @@ public class Decoder { void scottieDX_mode() { rsDecoder.invoke_scottieDX_mode(); } void wrasseSC2_180_mode() { rsDecoder.invoke_wrasseSC2_180_mode(); } + + void increaseUpdateRate() { updateRate = Math.min(4, updateRate + 1); } + void decreaseUpdateRate() { updateRate = Math.max(0, updateRate - 1); } void updateTitle(int id) { activity.updateTitle(activity.getString(id)); } void switch_mode(int mode) @@ -245,7 +249,7 @@ public class Decoder { } void decode() { - int samples = audio.read(audioBuffer, 0, audioBuffer.length); + int samples = audio.read(audioBuffer, 0, audioBuffer.length >> updateRate); if (samples <= 0) return; diff --git a/app/src/main/java/xdsopl/robot36/MainActivity.java b/app/src/main/java/xdsopl/robot36/MainActivity.java index 5d87867..8c4ee58 100644 --- a/app/src/main/java/xdsopl/robot36/MainActivity.java +++ b/app/src/main/java/xdsopl/robot36/MainActivity.java @@ -199,6 +199,12 @@ public class MainActivity extends Activity { decoder.enable_analyzer(enableAnalyzer ^= true); changeLayoutOrientation(getResources().getConfiguration()); return true; + case R.id.action_increase_update_rate: + decoder.increaseUpdateRate(); + return true; + case R.id.action_decrease_update_rate: + decoder.decreaseUpdateRate(); + return true; case R.id.action_raw_mode: decoder.raw_mode(); return true; diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index a913342..4e8217f 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -20,6 +20,10 @@ android:orderInCategory="100" android:showAsAction="never" /> + + Toggle Auto Mode Toggle Debug Mode Toggle Analyzer + Increase Update Rate + Decrease Update Rate Raw Mode Robot36 Mode Robot72 Mode