1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Thomas Martitz 2010-09-12 09:42:21 +00:00
parent 409c157089
commit cbbbe60dbf
2 changed files with 12 additions and 14 deletions

View file

@ -33,11 +33,15 @@ import android.util.Log;
public class RockboxPCM extends AudioTrack public class RockboxPCM extends AudioTrack
{ {
byte[] raw_data; private byte[] raw_data;
private int buf_len;
private PCMListener l; private PCMListener l;
private HandlerThread ht; private HandlerThread ht;
private Handler h = null; 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) private void LOG(CharSequence text)
{ {
@ -46,17 +50,10 @@ public class RockboxPCM extends AudioTrack
public RockboxPCM() public RockboxPCM()
{ {
super(AudioManager.STREAM_MUSIC, super(AudioManager.STREAM_MUSIC, samplerate, channels, encoding,
44100, buf_len, AudioTrack.MODE_STREAM);
/* should be CHANNEL_OUT_STEREO in 2.0 and above */
AudioFormat.CHANNEL_CONFIGURATION_STEREO,
AudioFormat.ENCODING_PCM_16BIT,
24<<10,
AudioTrack.MODE_STREAM);
ht = new HandlerThread("audio thread", Process.THREAD_PRIORITY_URGENT_AUDIO); ht = new HandlerThread("audio thread", Process.THREAD_PRIORITY_URGENT_AUDIO);
ht.start(); ht.start();
buf_len = 24<<10; /* in bytes */
raw_data = new byte[buf_len]; /* in shorts */ raw_data = new byte[buf_len]; /* in shorts */
Arrays.fill(raw_data, (byte) 0); Arrays.fill(raw_data, (byte) 0);
l = new PCMListener(buf_len); l = new PCMListener(buf_len);

View file

@ -558,6 +558,7 @@ Hayden Pearce
Rodrigo Barretto Rodrigo Barretto
Daniel Rigby Daniel Rigby
Alexey Polkhirev Alexey Polkhirev
István Nagy
The libmad team The libmad team
The wavpack team The wavpack team