AudioRecord: start() status -38

前端 未结 4 681
旧巷少年郎
旧巷少年郎 2020-12-31 06:00

I have the following problem: I use SpeechRecognizer to identify a few words. I use the

public void onResults

method to destroy the SpeechR

相关标签:
4条回答
  • 2020-12-31 06:22

    You need to make sure you issue audioRecord.stop(); and audioRecord.release(); in your onPause() or similar methods. If you don't, the next time you run the app, you won't get access to the device, and you'll get start() status -38

    0 讨论(0)
  • 2020-12-31 06:30

    I was having a similar problem to this AudioRecord start() error status -38 what i eventually did was loop over the possible configurations of the audio recorder like the answerer said in this question AudioRecord object not initializing I like this method since it doesn't matter what device you run it on it will eventually find a configuration that it likes.

    0 讨论(0)
  • 2020-12-31 06:35

    I had a different app that was probably running the background and didn't release the recording device. You also need to make sure all other apps are closed (using the switch between apps > CLEAR ALL).

    0 讨论(0)
  • 2020-12-31 06:36

    I checked recording state by using audioRecord.getRecordingState() as Michael commented. Normally after audioRecord.startRecording();, recordingState becomes RECORDSTATE_RECORDING. If state is not RECORDSTATE_RECORDING, I will close app.

    audioRecord.startRecording();
    int recordingState = audioRecord.getRecordingState();
    Log.i(VoiceRecorder.class.getSimpleName(), "RecordingState() after startRecording() = " + String.valueOf(recordingState));
    if (recordingState != AudioRecord.RECORDSTATE_RECORDING) {
        Log.i(VoiceRecorder.class.getSimpleName(), "AudioRecord error has occured. Reopen app.");
        System.exit(0);
    }
    
    0 讨论(0)
提交回复
热议问题