googlearchive/android-Camera2Video

java.lang.IllegalStateException at android.media.MediaRecorder._start(Native Method)

Closed this issue · 1 comments

I am using this to record the video in Karaoke app.
I am using https://github.com/JorenSix/TarsosDSP to get the pitch rate from the microphone.
In this, link it is said that if there is any background service, which uses the microphone then this video recorder will not work.
So when I start recording the video the application crashes in startRecording method.
If I comment the pitch detection code and run, this will record perfectly.
How can I fix this issue now?
this is pitch detection code,

AudioDispatcher dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(22050, 1024, 0);
PitchDetectionHandler pdh = new PitchDetectionHandler() {
@OverRide
public void handlePitch(PitchDetectionResult result, AudioEvent e) {
final float pitchInHz = result.getPitch();
try {
Thread.sleep(200);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
runOnUiThread(new Runnable() {
@OverRide
public void run() {
Log.d("pitchinhz", String.valueOf(pitchInHz));
//TODO: dynamic value
//if (pitchInHz != -1.0)
try {
updatePointerPopupWindow(pitchInHz);
if (isPitchMatches())
Log.d("intersectionval", isPitchMatches() + "");
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
}
};
AudioProcessor p = new PitchProcessor(PitchProcessor.PitchEstimationAlgorithm.FFT_YIN, 22050, 1024, pdh);
dispatcher.addAudioProcessor(p);
new Thread(dispatcher, "Audio Dispatcher").start();

This sample has been migrated to a new location (check README for more information).

As recommended by GitHub, we are closing all issues and pull requests now that this older repo will be archived.

If you still see this issue in the updated repo, please reopen the issue/PR there. Thank you!