forked from len0rd/rockbox
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
This commit is contained in:
parent
03c12a7906
commit
dace72166e
2 changed files with 39 additions and 53 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue