I'm working an Android AudioRecord app. If I do not call the release()
method on the AudioRecord object at the end of the script, it will not run correctly until I restart the phone.
This becomes a major hassle when working on this project because if the app should ever crash (which happens sometimes while testing and there's an unexpected buffer overflow, etc.) then I have to restart the phone every time.
I have the method to release the buffers inside the finalize()
method of my AudioListener class, and I also call them onStop()
of the main Activity.
Neither of these seem to work when the app freezes or crashes. Is there a way to attach the release action to an error handler or some general way of ensuring that an app will execute some code to release resources properly even after a crash.
Thanks for any help.