OmRecorder icon indicating copy to clipboard operation
OmRecorder copied to clipboard

Getting this error `E/AudioRecord-JNI: Error -38 during AudioRecord native read` when start recording again in Android 10, can give a suggestion?

Open kenchoong opened this issue 4 years ago • 4 comments

@kailash09dabhi

hey sir, just a quick question, I need to call for audioRecorder.release() when stop Recording, cause I also didnt ??

Cause I get this error E/AudioRecord-JNI: Error -38 during AudioRecord native read when start the recording again.

Behaviour now:

  • Start record : no problem
  • Stop record: no problem -Start again: no problem -Stop again: no problem
  • Start again: E/AudioRecord-JNI: Error -38 during AudioRecord native read

This happened nearly every time in Android 10 device.

I know this may cause by mic is using by another app, but in my testing, my phone is not record anything else when having error.

May be because of the recorder is not release when stop recording?? I have no single clue.

Please give me some hint..

kenchoong avatar Sep 06 '20 11:09 kenchoong

I tried to solve it like this:

Initialize the PullTransponse:

pullTransport = new PullTransport.Noise(mic(),
                   new PullTransport.OnAudioChunkPulledListener() {
                       @Override public void onAudioChunkPulled(AudioChunk audioChunk) {
                           animateVoice((float) (audioChunk.maxAmplitude() / 200.0));
                       }
                   },
                   new WriteAction.Default(),
                   new Recorder.OnSilenceListener() {
                       @Override public void onSilence(long silenceTime) {
                           Log.e("silenceTime", String.valueOf(silenceTime));
                           Toast.makeText(MainActivity.this, "silence of " + silenceTime + " detected",
                           Toast.LENGTH_SHORT).show();
                       }
                   }, 200
           );

Then release it like this:

if (audioRecorder == null) {
           return
        }else{
            try {
                audioRecorder.stopRecording();
                pullTransport.pullableSource().audioRecord().release(); //Here I tot it will release the audio,but still the same
                
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

after look at this issues:

https://github.com/kailash09dabhi/OmRecorder/issues/23

But it still having the still having the same error

kenchoong avatar Sep 06 '20 13:09 kenchoong

This problem only happen at Android 10, at least I test in our device below 10 is ok, only 10 have this E/AudioRecord-JNI: Error -38 during AudioRecord native read when it start recording again

kenchoong avatar Sep 06 '20 17:09 kenchoong

Did you try adding android:requestLegacyExternalStorage="true" to the application tag in manifest file. It worked for me(this is a temporary solution though )

md0092651 avatar Sep 20 '20 16:09 md0092651

@md0092651 bro I already set android:requestLegacyExternalStorage="true" in AndroidManifest.xml but it still the same.. Still having the same error..

kenchoong avatar Oct 09 '20 07:10 kenchoong