I am making an android app that records audio from a bluetooth earpiece. Everything works fine and the app is able to record audio through the earpiece.
However I will need the exact (or very close to exact) millisecond of when the first audio signal was recorded, if the audio recordings are going to be useful to me. I tried getting the timestamp with System.currentTimeMillis(); right after calling .start() on the MediaRecorder, as mentioned in this SO Question.
Sadly when I use this method for getting the start time of my audio recording it is often off by quite a lot (100ms or more even).
By getting the time befor calling MediaRecorder.start() and after the call, like this:
audioStartTime1 = System.currentTimeMillis();
recorder.start();
audioStartTime2 = System.currentTimeMillis();
I'm able to see that between audioStartTime1 and audioStartTime2 anywhere between 50ms to 150ms elapse. It seems like starting the MediaRecorder takes quite some time. This would be no problem at all if the recording started right after recorder.start() returns, however the recording doesn't start right after recorder.start() has returned, but still takes some time until the bluetooth earpiece really starts recording. This delay is different every time and can be more than 100ms.
Is there some kind of way for me to get a more exact timestamp for the first audio sample?
Maybe store the time of when the MediaRecorder gets the first data packet over bluetooth. How would I do that though?
This person here also has a similar problem for video recording and did not get any useful answeres
I would really appriciate some Help.
Thanks.