diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-06-05 09:44:57 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-06-05 09:44:57 +0000 |
commit | dace72166e5250e2ea0a9beb6451f5e4da9e50e2 (patch) | |
tree | 47c2e602c55908a4b3a72a43d9baf20418e69f66 /android | |
parent | 03c12a790649c199f415f86366fc02ccee0f9004 (diff) |
Android: Greatly simplify the pcm callback mechanism on both, the Java and the C side. Should be more reliable now (if the old wasn't already).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29963 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android')
-rw-r--r-- | android/src/org/rockbox/RockboxPCM.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/android/src/org/rockbox/RockboxPCM.java b/android/src/org/rockbox/RockboxPCM.java index 48178fcc92..eaccddb76a 100644 --- a/android/src/org/rockbox/RockboxPCM.java +++ b/android/src/org/rockbox/RockboxPCM.java @@ -239,14 +239,14 @@ public class RockboxPCM extends AudioTrack } } - public native void pcmSamplesToByteArray(byte[] dest); + public native int nativeWrite(byte[] temp, int len); private class PCMListener implements OnPlaybackPositionUpdateListener { - private byte[] buf; - public PCMListener(int refill_bufsize) + byte[] pcm_data; + public PCMListener(int _refill_bufsize) { - buf = new byte[refill_bufsize]; + pcm_data = new byte[_refill_bufsize]; } public void onMarkerReached(AudioTrack track) @@ -254,8 +254,7 @@ public class RockboxPCM extends AudioTrack /* push new data to the hardware */ RockboxPCM pcm = (RockboxPCM)track; int result = -1; - pcm.pcmSamplesToByteArray(buf); - result = track.write(buf, 0, buf.length); + result = pcm.nativeWrite(pcm_data, pcm_data.length); if (result >= 0) { switch(getPlayState()) @@ -269,6 +268,8 @@ public class RockboxPCM extends AudioTrack break; } } + else /* stop on error */ + stop(); } public void onPeriodicNotification(AudioTrack track) |