I have an application which consists of a service and an activity that may be started by the service for certain events. The service may create & use the AudioRecord & AudioTrack classes - at which time the application's Activity is displayed. The problem is if the Activity is paused (i.e., onPause() is called) I start getting the RecordThread: buffer overflow errors?
My guess is the AudioRecorder is running in the main thread. And, even though it was created by the service, when the Activity pauses reading stops thus the buffer overflows? Must the AudioRecorder reading be done in a separate thread even though it is running in the service?
Any help would be greatly appreciated, thanks.
The RecordThread buffer overflows happen when you aren't pulling the data from the AudioRecord object fast enough.
You should definitely have the loop that pulls data from the AudioRecord object in a sperate thread, and you should stop that thread if your activity gets paused (unless you want to record in the background.)
Here are a couple examples of working implementations:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With