Re: DefaultOutputDevice timestamps
Re: DefaultOutputDevice timestamps
- Subject: Re: DefaultOutputDevice timestamps
- From: Jeff Moore <email@hidden>
- Date: Mon, 22 Oct 2001 15:07:34 -0700
on 10/22/01 2:59 AM, email@hidden <email@hidden> wrote:
>
If an AudioDevice gives me AudioTimeStamps
>
with the kAudioTimeStampHostTimeValid flag set to true in the mFlags
>
variable, shouldn't that guarantee me that the time is
>
indeed valid? I'm still obviously confused by why this isn't working when
>
it says it should be.
I guess I came in the middle of this conversation.
What exactly isn't working?
For devices that have output, the inOutputTime argument of your
AudioDeviceIOProc is the time stamp for when the data in outOutputData is
going to hit the wire. Note that you cannot modify this value. It is for
your information only.
For device's that don't have output, the inOutputTime argument will be all
zeroes and should be ignored.
>
In the above, I eliminated my error handling code and some other things
>
which weren't directly related and would be more confusing. Right
>
now I'd assume my callback can't be the responsible party as it
>
only reports the AudioTimeStamps and outputs data. Anyway, any
>
advice appreciated.
I don't understand. Responsible party for what?
One problem in your code I see already is that you assume that
AudioDeviceStart is synchronous. It is not. You should wait until you
receive a notification for kAudioDevicePropertyDeviceIsRunning before
setting the value of your isPlaying member.
This brings up an interesting point that I've seen hurt otherwise good code.
Just about everything in the HAL is asynchronous. In particular, starting,
stopping, and changing the format are asynchronous. This is very different
from the way things work on 9. You should structure your code such that you
only update your engine's state from the notification. This has the added
benefit of making your engine friendly to the rest of the processes you are
sharing the machine with. Plus, it's the only way to know certain things
like when the user unplugs a USB device.
--
Jeff Moore
Core Audio
Apple