ViktorDegtyarev / CallRecLib

Call Recorder fix for Android 7 and Android 6
Apache License 2.0
101 stars 60 forks source link

The sample app is crashed when start record in galaxy s6, s7, s8, and note 8. #17

Closed MountainNine closed 6 years ago

MountainNine commented 6 years ago

The sample app is crashed when start record in galaxy s6, s7, s8, and note 8.

But it works in galaxy a3, a5, and a8(all '2015).

I think the cause is processor's difference.

galaxy s6~ models are 64-bit processor. On the other hand, my galaxy a series is 32-bit processor.

So, if I change some setting, the problem will be solved, but I don't know that some setting.

Can you help me?

mohammedhemaid commented 6 years ago

"this work for me in another library in java "

recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL); works on limited devices ,it will give exception only on that device in which voice call is not supported so catch the exception and start the recording from mic all over again that will keep you on safer side in non supported device.

use this code : String manufacturer = Build.MANUFACTURER; if (manufacturer.toLowerCase().contains("samsung")) { recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION); } else { recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL); }

Reference: https://stackoverflow.com/questions/24139332/voice-call-recording-in-android-using-mediarecorder/24139711

MountainNine commented 6 years ago

Thank you for response. But it isn't about my problem. I tried this library on VOICE_COMMUNICATION, too. It is work when first I turn on the service. But when I turn off, and turn on the service second, it is crashed. Also, I tried this library on galaxy a3, a5, and a8, but it isn't crashed.

So I look at the error, and I found it crashed on memcpy(), AudioRecord.cpp(Android native code). In line 188(AudioRecord.cpp), there is the code that if pAttributes is NULL and if pAttributes is not NULL. So, In my opinion, when the first record is started, it passed the code that pAttributes is NULL. However, when the second record is started, it passed the code that pAttributes is not NULL, and crashed on memcpy().

What I want to know is why it crashes in 64-bit. Can you tell me its reason clearly?

KnightOfRealm commented 6 years ago

Hi, I am not sure but as far as I know, it's not about 32bit and 64bit. It's because of android version after 6 androidOS has stopped the NDK lib direct access, and issued API and an app can only access these NDK libs available through the API. Can you confirm the device android version?

MountainNine commented 6 years ago

@KnightOfRealm The device android version is nougat and oreo. But I set targetSdkVersion=23, so it is not the problem. If I set targetSdkVersion=24 or higher, It is crashed because of KnightOfRealm's answer. That's why it may not be the reason.

MountainNine commented 6 years ago

Solved. When I changed one code in audio.h, it works.