开发者

Problem with AudioTrack

Hello I wrote a program (on Android NDK), which gives audio buffer through JNI in Java. The problem of instability. Sometimes AudioTrack perfectly reproduces the buffer, and sometimes there are these messages:

08-18 15:13:00.745: INFO/AudioTrack(12457): AudioTrack::set streamType[3] channels[12] format[1] sampleRate[44100] 08-18 15:13:00.749: INFO/AudioPolicyManager(2381): setOutputDevice() output 1 device 2 delayMs 0 force:0 08-18 15:13:04.183: INFO/AudioHardwareALSA(2381): Output standby called!!. Turn off PCM device.

Code in Java like this:

final int bufSize = AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT);
track = new AudioTrack(AudioManager.STREAM_MUSIC, 44100,AudioFormat.CHANNEL_CONFIGURATION_STEREO,AudioFormat.ENCODING_PCM_16BIT, bufSize, Aud开发者_StackOverflowioTrack.MODE_STREAM);
track.play();
int byt = track.write(buf, 0, length);

In what may be a problem with this error?


You have to call track.write andf fill the minimum bufSize first before track.play is called.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜