added menu items to increase / decrease update rate

default update rate is 2 updates per second
This commit is contained in:
Ahmet Inan 2015-01-16 18:47:57 +01:00
parent 0945e8b031
commit 8b16b13ad2
4 changed files with 17 additions and 1 deletions

View file

@ -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;

View file

@ -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;

View file

@ -20,6 +20,10 @@
android:orderInCategory="100" android:showAsAction="never" />
<item android:id="@+id/action_toggle_analyzer" android:title="@string/action_toggle_analyzer"
android:orderInCategory="100" android:showAsAction="never" />
<item android:id="@+id/action_increase_update_rate" android:title="@string/action_increase_update_rate"
android:orderInCategory="100" android:showAsAction="never" />
<item android:id="@+id/action_decrease_update_rate" android:title="@string/action_decrease_update_rate"
android:orderInCategory="100" android:showAsAction="never" />
<item android:id="@+id/action_raw_mode" android:title="@string/action_raw_mode"
android:orderInCategory="100" android:showAsAction="never" />
<item android:id="@+id/action_robot36_mode" android:title="@string/action_robot36_mode"

View file

@ -6,6 +6,8 @@
<string name="action_toggle_auto">Toggle Auto Mode</string>
<string name="action_toggle_debug">Toggle Debug Mode</string>
<string name="action_toggle_analyzer">Toggle Analyzer</string>
<string name="action_increase_update_rate">Increase Update Rate</string>
<string name="action_decrease_update_rate">Decrease Update Rate</string>
<string name="action_raw_mode">Raw Mode</string>
<string name="action_robot36_mode">Robot36 Mode</string>
<string name="action_robot72_mode">Robot72 Mode</string>