googlearchive / android-Camera2Video

Migrated:
https://github.com/android/camera
Apache License 2.0
1.21k stars 568 forks source link

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

Closed HasanShaikh closed 5 years ago

HasanShaikh commented 6 years ago

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();

codingjeremy commented 5 years ago

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!