I am attempting to add custom voice commands to a glass app by using AudioRecorder to grab input from the microphone and do speech recognition on that. Everything is working great except for the command to "stop recording", where I need to grab the current microphone input at the same time that a MediaRecorder object is recording the video.
Specifically, I don't get any errors, but doing a
int bufferResult = recorder.read(readBuffer, 0, readBuffer.length);
results in 0 bytes being read, and bufferResult being 0. readBuffer.length is 64000 bytes (4 seconds worth of audio)
I suspect that that there is some sort of lock on the underlying resources that is preventing from AudioRecorder from doing .reads() while MediaRecorder is recording as well. Has anyone run into this issue before? More generally, is there any way to get the audio from the microphone while MediaRecorder is recording, either via AudioRecorder or otherwise?