我正在使用Visualizer。当我点击一个按钮时,它将从AudioTrack获取数据并显示。在按钮中,我将调用函数DrawStart,如下所示:
private void DrawStart() {
if (startDrawing) {
initRecorder();
mVisualizerView.link(track);
startRecording();
}
else {
DrawStop();
}
}
适用于大约10次首次点击。这意味着如果我将DrawStart调用超过10次,则会出现错误
Fatal signal 11 (SIGSEGV) at 0x00030000 (code=1), thread 8164 (Visualizer)
你可以帮我解决一下吗?非常感谢。有我的子功能
private void initRecorder() {
_audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
int maxJitter = AudioTrack.getMinBufferSize(SAMPLE_RATE, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT);
track = new AudioTrack(AudioManager.MODE_IN_COMMUNICATION, SAMPLE_RATE, AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, maxJitter, AudioTrack.MODE_STREAM);
_audioManager.startBluetoothSco();
_audioManager.setMode(AudioManager.STREAM_VOICE_CALL);
}
private void startRecording() {
recordingThread = new AudioRecordingThread(track,mRecorder, bufferSize,SAMPLE_RATE,new AudioRecordingHandler() {
// Do something
});
recordingThread.start();
}
private void DrawStop() {
if (recordingThread != null) {
recordingThread = null;
}
track.release();
startDrawing = true;
}
并且
public void link(AudioTrack player)
{
if(player == null)
{
throw new NullPointerException("Cannot link to null MediaPlayer");
}
int playerId=player.getAudioSessionId();
// Create the Visualizer object and attach it to our media player.
mVisualizer = new Visualizer(playerId);
mVisualizer.setScalingMode(Visualizer.SCALING_MODE_NORMALIZED);
mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
}
答案 0 :(得分:0)
通过在AndroidManifest.xml中将应用程序的hardwareAccelerated属性设置为false来解决此问题
<application
android:hardwareAccelerated="false"