当我调用finishRecord()时,调试器返回错误:
05-09 19:26:58.491 17576-17576/? E/Zygote: v2
05-09 19:26:58.491 17576-17576/? E/Zygote: accessInfo : 0
05-09 19:26:59.551 17576-17576/com.cleveroad.audiovisualization.example E/MotionRecognitionManager: mSContextService = null
05-09 19:26:59.551 17576-17576/com.cleveroad.audiovisualization.example E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@e6c815c
05-09 19:27:16.181 17576-17863/com.cleveroad.audiovisualization.example E/AndroidRuntime: FATAL EXCEPTION: Thread-187715
Process: com.cleveroad.audiovisualization.example, PID: 17576
java.lang.IllegalStateException: stop() called on an uninitialized AudioRecord.
at android.media.AudioRecord.stop(AudioRecord.java:999)
at com.github.republicofgavin.pauseresumeaudiorecorder.PauseResumeAudioRecorder$AudioRecorderThread.run(PauseResumeAudioRecorder.java:364)
我的finishRecord方法是:
public void finishRecord() {
mr.stopRecording();
try {
int recorderStateLocal = recorderState;
if (recorderStateLocal != RECORDER_STATE_IDLE) {
synchronized (recorderStateMonitor) {
recorderStateLocal = recorderState;
if (recorderStateLocal == RECORDER_STATE_STARTING
|| recorderStateLocal == RECORDER_STATE_BUSY) {
recorderStateLocal = recorderState = RECORDER_STATE_STOPPING;
}
do {
try {
if (recorderStateLocal != RECORDER_STATE_IDLE) {
recorderStateMonitor.wait();
}
} catch (InterruptedException ignore) {
/* Nothing to do */
}
recorderStateLocal = recorderState;
} while (recorderStateLocal == RECORDER_STATE_STOPPING);
}
}
}
catch(IllegalStateException ee){}
}
如果我评论mr.stopRecording();项目可以成功运行
但我需要调用mr.stopRecording();
有人可以帮我解决这个问题吗?