Hello,
I hope that somebody can explain how to pause AudioTrack correctly. I
am recording and playing back a pcm file with the
OnPlaybackPositionUpdateListener in a remote service. This works fine.
Now when I call pause() on the audioTrack object, the playback pauses
and if I want to resume I call start() again. This works in general,
but some frames are skipped and the playback does not resume from the
point it paused but from a few frames later. Why is that? Please show
me how to pause a AudioTrack correctly without losing frames. Here is
my code for the PlaybackListener
audioTrack.setPlaybackPositionUpdateListener(new
OnPlaybackPositionUpdateListener() {
@Override
public void onPeriodicNotification(AudioTrack
track) {
try {
int error=0;
if(ramfile!=null)
{
error =
ramfile.read(buffer);
}
if(error==-1)
{
audioTrack.stop();
audioTrack.flush();
if(ramfile!=null)
ramfile = null;
audioTrack=null;
playing=false;
}
if(audioTrack!=null &&
audioTrack.getPlayState()==AudioTrack.PLAYSTATE_PLAYING)
audioTrack.write(buffer, 0, buffer.length);
} catch (IOException e) {
Log.d("EX","We run into an
Exception");
e.printStackTrace();
}
}
@Override
public void onMarkerReached(AudioTrack track) {
}
});
Greetings,
Markus
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en