问题描述
在我的Android应用中,我正在使用AudioTrack API输出从RFCOMM蓝牙连接接收到的音频字节.音频将按预期播放,并且非常清晰.但是,由于AudioTrackShared.cpp中的以下声明,该应用有时会崩溃:
In my Android app, I'm using the AudioTrack API to output audio bytes that I receive from a RFCOMM Bluetooth connection. The audio plays as expected and is very clear. However, the app occasionally crashes due to the following assertion in AudioTrackShared.cpp:
stepCount <= mUnreleased && mUnreleased <= mFrameCount
我不太确定此断言的含义,但是没有人知道可能导致此问题的原因吗?如果需要,我可以提供其他源代码:
I'm not really sure of what this assertion entails, but does anyone have an idea of what could cause this issue? I can provide additional source code if needed:
我对AudioTrack的设置:
My setup for AudioTrack:
int minSize = AudioTrack.getMinBufferSize(8000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_8BIT);
mAudioPlayer = new AudioTrack(AudioManager.STREAM_MUSIC, 8000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_8BIT, minSize * 4, AudioTrack.MODE_STREAM);
推荐答案
使AudioTrack缓冲区的大小与您从minBufferSize获得的大小相同.那可以解决您的问题.
Make AudioTrack buffer size the same you get from minBufferSize. That could fix your issue.
这篇关于了解Android中的AudioTrack断言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!