的整個時期的Android AudioTrack寫入塊我使用AudioTrack
課堂上播放原始聲音數據流:在一個單獨的線程播放
AudioTrack audioTrack;
int sampleRate = 11025;
int channelConfigIn = AudioFormat.CHANNEL_IN_MONO;
int channelConfigOut = AudioFormat.CHANNEL_OUT_STEREO;
int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
.....
int bufferSize = AudioTrack.getMinBufferSize(sampleRate,channelConfigOut,audioFormat);
audioTrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL,sampleRate,channelConfigOut,audioFormat,bufferSize,AudioTrack.MODE_STREAM);
audioTrack.play();
然後:
while(true)
{
short [] buffer = new short[14500];
//fill buffer with sound data
long time = System.currentTimeMillis();
audioTrack.write(buffer,0,14500);
Log.i("time",(System.currentTimeMillis() - time) + "");
}
我的問題是該日誌總是顯示write
方法阻塞約0.6秒,這與播放聲音長度(14500個樣本)相同,而且在回放期間電話沒有響應,主要步驟幾乎無法做任何人都可以幫助的事情...
[this](http://pastebin.com/tz2Mvh5G)正常工作正常 – pskink