我需要每20ms获取一个新的音频帧,因此我创建一个int minBufferSize = 7528;
mAudioTrack = new AudioTrack(
AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT, minBufferSize , AudioTrack.MODE_STREAM);
mAudioTrack.setPlaybackPositionUpdateListener(CarMediaPlayer.this ,mMainThreadHandler );
mAudioTrack.setPositionNotificationPeriod(914); //Set a notification for every 20ms to get an Audio frame. This is got by Dividing 3764/4(framesize)
,其缓冲区大小为7528字节(最多2个音频缓冲区,每个3764个字节)
@Override
public void onPeriodicNotification(AudioTrack track)
{
Log.i(TAG, "onPeriodicNotification ");
getAudioFrame();
}
我看到的问题是回调
s='956,938,987,964,1004,934,1018,912'
echo $s | sed 's/\([0-9]\{2,\}\)\([0-9]\)/\1.\2/g'
每20分钟没有被召唤。有时它会很早就被调用,有时甚至太晚。它不一致,但每次播放3764字节的帧都会被调用。
知道如何使其保持一致,以便每20毫秒调用一次吗?