Hi,
I'm developing an iPhone app using CoreAudio and I have the requirements to know exactly the timestamp of a recorded audio sample, as well as the timestamp an audio sample will have when it's played back.
For this reason, I am using 2 callbacks: - Record callback: output scope of the input element - Playback callback: input scope of the output element.
In the record callback I'm able to get the timestamp of the first sample in the data by accessing the parameter inTimeStamp->mSampleTime. Same thing goes for the playback callback, except in this case I'd expect the timestamp value to correspond to the timestamp value of the first audio sample in the data.
It all works nice on iPhone 4S: the audio data is recorded, short after the record callback is called. After this, the playback callback. The difference between the 2 timestamps is reasonable: it's 704 samples (i'm using standard float PCM data format and an IO buffer duration of 256 samples).
Problem: On iPhone 5, the difference between input and output timestamps is of several samples, like 50'000'000! Corresponding to 20 min or so. The only way to solve this is restarting the iPhone 5. After this step the difference is 735 samples, similar to the one of iPhone 4S. It looks like after the iPhone 5 is on since a long time, the difference grows bigger and bigger.
I've also tried to set the "kAudioOutputUnitProperty_StartTimestampsAtZero" property on the global scope of the input and output element, but the samples don't start from zero! Is this normal?
Matteo |