summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-09-12 09:42:21 +0000
committerThomas Martitz <kugel@rockbox.org>2010-09-12 09:42:21 +0000
commitcbbbe60dbf407ef853a5e9be93f85ef53d7cfd06 (patch)
treea0314bb316047d53000dae088d86d01242102e1e
parent409c157089c59ec60aed2c83a8e18cb4a66478f0 (diff)
Use getMinBufferSize instead of hardcoding a buffer size.
Seems to fix problems on Samsung Galaxy S, thanks to István Nagy. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28059 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--android/src/org/rockbox/RockboxPCM.java25
-rw-r--r--docs/CREDITS1
2 files changed, 12 insertions, 14 deletions
diff --git a/android/src/org/rockbox/RockboxPCM.java b/android/src/org/rockbox/RockboxPCM.java
index f11f37f358..b39aaef5e4 100644
--- a/android/src/org/rockbox/RockboxPCM.java
+++ b/android/src/org/rockbox/RockboxPCM.java
@@ -33,11 +33,15 @@ import android.util.Log;
public class RockboxPCM extends AudioTrack
{
- byte[] raw_data;
- private int buf_len;
+ private byte[] raw_data;
private PCMListener l;
private HandlerThread ht;
private Handler h = null;
+ private static final int samplerate = 44100;
+ /* should be CHANNEL_OUT_STEREO in 2.0 and above */
+ private static final int channels = AudioFormat.CHANNEL_CONFIGURATION_STEREO;
+ private static final int encoding = AudioFormat.ENCODING_PCM_16BIT;
+ private static final int buf_len = getMinBufferSize(44100, channels, encoding);
private void LOG(CharSequence text)
{
@@ -46,20 +50,13 @@ public class RockboxPCM extends AudioTrack
public RockboxPCM()
{
- super(AudioManager.STREAM_MUSIC,
- 44100,
- /* should be CHANNEL_OUT_STEREO in 2.0 and above */
- AudioFormat.CHANNEL_CONFIGURATION_STEREO,
- AudioFormat.ENCODING_PCM_16BIT,
- 24<<10,
- AudioTrack.MODE_STREAM);
+ super(AudioManager.STREAM_MUSIC, samplerate, channels, encoding,
+ buf_len, AudioTrack.MODE_STREAM);
ht = new HandlerThread("audio thread", Process.THREAD_PRIORITY_URGENT_AUDIO);
ht.start();
- buf_len = 24<<10; /* in bytes */
-
- raw_data = new byte[buf_len]; /* in shorts */
- Arrays.fill(raw_data, (byte) 0);
- l = new PCMListener(buf_len);
+ raw_data = new byte[buf_len]; /* in shorts */
+ Arrays.fill(raw_data, (byte) 0);
+ l = new PCMListener(buf_len);
}
int bytes2frames(int bytes) {
diff --git a/docs/CREDITS b/docs/CREDITS
index c78fe42163..82790135aa 100644
--- a/docs/CREDITS
+++ b/docs/CREDITS
@@ -558,6 +558,7 @@ Hayden Pearce
Rodrigo Barretto
Daniel Rigby
Alexey Polkhirev
+István Nagy
The libmad team
The wavpack team