It seems this error occurs after the instance of AudioRecord has already been stopped. Then I copy the contents of my temporary temp_record.wav (SD Card) to the destination (SD Card) with setting a proper wave file header.

I'm not able to filter any useful information out of the following debug information. I hope someone has an idea. Thank you!

Hi Chris, I think it's impossible to help with this informations. The debug log does not show any hint. Are you able to reproduce the error? Can you provide any code where it fails? I have a feeling in my stomach that it's some sort of asynchronous problem.
–
Diego FrehnerJun 30 '12 at 14:22

The error occurs from time to time but is not reproducible with a special "todo list". Sometimes the error happens at the first record sometimes many records later. I think you may be right that it is an asynchronous problem, cause I'm using a seperate thread writing audio to file. I will try to look a bit deeper at that part of code.
–
ChrisJun 30 '12 at 14:47

4 Answers
4

Thanks for pointing out SIGSEV again, i over read it a little because i didn't know its meaning. Now i do :)
I agree with CommonsWare that you should inform the manufacturer/modder of the firmware.
But i also think it does not help you further in a useful time span. Maybe we find a way to modify your code in a way not to provoke the error anymore.

Generally your code looks quite good. What i think is not totally safe and proper is the way you are stopping the recorder.

Instead of using the isRecording flag i'd use a isCancelled flag. So you record while(!isCancelled). And when you want to stop recording you just set isCancelled to true and call recorder.stop().

After recording stopped you can call, right after writeAudioDataToFile() in the audio recorder thread, your logic for display the progress dialog and for copy the file. I would not use an additional thread for these things since we are still in the audio recorder thread and your UI is not blocked.

When to call recorder.release(), it releases memory... The docs "Releases the native AudioRecord resources." I don' know exactly, if this has an influence on the problem. In the current code you provided, you call recorder.release() while theoretically the recorder could reading (without knowing if the class is threadsafe). Maybe you could also try to call it after you copied all your files, even i think it should be fine after the recorder really stopped and your outputstream is closed.

Thank you for your proposals.
I rebuild the code a little bit and now it seems to work.
At least I did not get the error for about one day (longer than before :D).

I changed the method writeAudioDataToFile() so that now releasing and so on is done there, too (after isRecording is set to false in the stopRecording() method). I do also not create a second Thread anymore, but handle all things in the RecorderThread.

A SIGSEGV should not be possible from Java code. Unless this was your JNI code, this would indicate a flaw in the firmware.

If you are running modded firmware, please pass this information along to the firmware modders.

If you are running the original firmware that came with your device, and this only occurs on one device, you can try to contact the device manufacturer.

If you are seeing this on more than one device with original firmware, and you can create a sample project that reproduces the error, post the project and the stack trace on the Android issue tracker, assuming this issue is not already reported there.

In order to receive the respective callback associated with these
listeners, applications are required to create MediaRecorder objects
on threads with a Looper running (the main UI thread by default
already has a Looper running).

Make sure you create the recorder on the UI thread. Perhaps also call its methods on the UI thread.