From 85f4bc7512c322ddc4e0d8e164854f038e8b26d2 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Fri, 20 Dec 2013 12:58:37 -0800 Subject: [PATCH] Tweak buffer size Empirical testing reveals that a smaller buffer size improves two separate issues. First, it gives much better results on devices that misreport their buffer size (Moto X is one, and it avoids a crash given that the reported buffer size was larger than the static allocation for the synth internal buffer). Second, even on devices that correctly report the buffer size, it reduces internal buffering in the OpenSL ES implementation, so this change reduces latency without impacting robustness. --- .../src/com/levien/synthesizer/android/ui/PianoActivity2.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java b/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java index 9281bf0..83e47a9 100644 --- a/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java +++ b/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java @@ -80,6 +80,9 @@ public class PianoActivity2 extends Activity { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { getJbMr1Params(params); } + // Empirical testing shows better performance with small buffer size + // than actually matching the media server's reported buffer size. + params.bufferSize = 64; androidGlue_ = new AndroidGlue(); androidGlue_.start(params.sampleRate, params.bufferSize);