Problem getting Audio Queues to play simultaneously
Problem getting Audio Queues to play simultaneously
- Subject: Problem getting Audio Queues to play simultaneously
- From: Ken Bowlus <email@hidden>
- Date: Tue, 17 Mar 2009 11:49:16 -0700
I'm having problems trying to play two sounds simultaneously on the iPhone. Dev Center documentation says to "create one audio queue object for each sound" and "specify simultaneous start times for the first audio buffer in each audio queue, using the AudioQueueEnqueueBufferWithParameters function."
Using code in SpeakHere as my basis I am doing the above but no matter what start times I specify the sounds always seem to play immediately as if I haven't specified a start time. To set my start time I call mach_absolute_time and add some "time" to that value then set the mHostTime (and mFlags) in the "in" AudioTimeStamp in the first audio buffer in each audio queue. My sound files are caf files with PCM data.
I can check Mach time and my start times for the audio queues before I call AudioQueueEnqueueBufferWithParameters and the actual start time (i.e., the mHostTime field in outActualStartTime) after the function returns. The "in" start times are after the current Mach time and the start times I specify are equal to the outActualStartTimes but the sounds play immediately (and not simultaneously). This happens in the iPhone simulator and on iPod Touch hardware, and I've tried it in a OS X application with the same results.
Here is an example of Mach times, start times I specify, and actual start times that I get when I run the code:
First audio queue:
mach time is 38673310564767
in mHostTime is 38675999617231 in mFlags is 2
out mHostTime is 38675999617231 out mFlags is 2
Second audio queue:
mach time is 38673951699062
in mHostTime is 38675999617231 in mFlags is 2
out mHostTime is 38675999617231 out mFlags is 2
I don't know what I'm doing wrong and any help as to why I am getting this behavior is appreciated.
-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