Re: Synchronize Audio Queue start times in iPhone
Re: Synchronize Audio Queue start times in iPhone
- Subject: Re: Synchronize Audio Queue start times in iPhone
- From: William Stewart <email@hidden>
- Date: Tue, 10 Mar 2009 17:40:03 -0700
As you describe, mHostTime is the time you want to use.
mHostTime is mach_absolute_time, so you can get it from:
mach_absolute_time();
On Mar 10, 2009, at 4:22 PM, Ken Bowlus wrote:
I have two audio queues that I want to synchronize to start playing
at the same time. I would like to use
AudioQueueEnqueBufferWithParameters and set identical start times
(in the AudioTimeStamps) but I'm at a loss as how to do this.
There are five choices as far as fields that I could set in the
AudioTimeStamp, and mSampleTime and mSMPTETime don't seem relevant.
I don't really understand what mRateScalar is but it doesn't seem
relevant to this either, and I can't find anything on what exactly
mWordClockTime is. That leaves me with mHostTime. What I'd like to
do is get the current host time add a little "time" to that value,
then use FillOutAudioTimeStampWithHostTime to set the time in two
AudioTimeStamp structs and use AudioQueueEnqueBufferWithParameters
to set the start times for both audio queues.
Here's the problem: how do I get the host time for the iPhone? It
doesn't appear that the <CoreAudio/HostTime.h> header file exists in
the iPhone Core Audio frameworks so I can't use
AudioGetCurrentHostTime and I can't find another call to get it.
Here are the structs and function calls related to the above
paragraphs:
struct AudioTimeStamp { Float64 mSampleTime; UInt64 mHostTime; //
This is the only field that I can see how to use for my purpose
Float64 mRateScalar; // ??? UInt64 mWordClockTime; // ??? SMPTETime
mSMPTETime; UInt32 mFlags; UInt32 mReserved; };
// I'd use this to fill in the host time in the AudioTimeStamp but I
don't know how to get the host time
FillOutAudioTimeStampWithHostTime (
AudioTimeStamp &outATS,
UInt64 inHostTime
)
// Could pass in inStartTime for each queue
OSStatus AudioQueueEnqueueBufferWithParameters (
AudioQueueRef inAQ,
AudioQueueBufferRef inBuffer,
UInt32 inNumPacketDescs,
const AudioStreamPacketDescription *inPacketDescs,
UInt32 inTrimFramesAtStart,
UInt32 inTrimFramesAtEnd,
UInt32 inNumParamValues,
const AudioQueueParameterEvent *inParamValues,
const AudioTimeStamp *inStartTime,
AudioTimeStamp *outActualStartTime
);
Any guidance on how to the get the host time or another method of
synchronizing these two audio queues to start playing at the same
time is appreciated.
Thanks,
Ken Bowlus
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden