I'm developing for the iPhone and am trying to get an initial timeStamp to sync my audioQueues.
I'm using AudioQueueDeviceGetCurrentTime
for this. According to the documentation this function gives back a valid mHostTime whether the queue/device is running or not. But when I try this I get back a kAudioHardwareNotRunningError
(1937010544). All queues have an timeLine associated and have been initialized before I call the function.
How can I retrieve a valid mHostTime to sync my AudioQueues (prior to running the queues)?
My code:
AudioSessionInitialize(NULL, NULL, interruptionListenerCallback, self);
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
sizeof(sessionCategory), &sessionCategory);
// initialize all queues
// ....
AudioSessionSetActive(true);
OSStatus result;
AudioTimestamp currentTime;
result = AudioQueueDeviceGetCurrentTime(audioQueueRef, ¤tTimeStamp);
if (!result)
{
// rest of code
}