Re: Converting AudioTimeStamp between two devices
Re: Converting AudioTimeStamp between two devices
- Subject: Re: Converting AudioTimeStamp between two devices
- From: Jeff Moore <email@hidden>
- Date: Thu, 1 Jun 2006 21:44:20 -0700
From <CoreAudio/CoreAudioTypes.h>:
/*!
@enum Commonly Used Combinations of AudioTimeStamp Flags
@abstract Some commonly used combinations of
AudioTimeStamp flags.
@constant kAudioTimeStampSampleHostTimeValid
The sample frame time and the host time are
valid.
*/
enum
{
kAudioTimeStampSampleHostTimeValid =
(kAudioTimeStampSampleTimeValid | kAudioTimeStampHostTimeValid)
};
So by assigning kAudioTimeStampSampleHostTimeValid to
firstPlayTime.mFlags you are saying that both the sample time and the
host time are valid.
What you really want here is to just say that the host time is valid,
which means just assigning kAudioTimeStampHostTimeValid to
firstPlayTime.mFlags.
On Jun 1, 2006, at 8:31 PM, Andrew Kimpton wrote:
So I'm attempting to convert the output timestamp to an input
timestamp using AudioDeviceTranslateTime() as follows :
AudioTimeStamp firstPlayTime = iFirstPlayTimeStamp;
AudioTimeStamp firstPlayTimeForInputDevice;
firstPlayTime.mFlags = kAudioTimeStampSampleHostTimeValid;
memset(&firstPlayTimeForInputDevice,0,sizeof
(firstPlayTimeForInputDevice));
firstPlayTimeForInputDevice.mFlags = kAudioTimeStampSampleTimeValid;
OSStatus osStatus = AudioDeviceTranslateTime
(iInputDeviceID,&firstPlayTime,&firstPlayTimeForInputDevice);
The problem with your code is that you are providing too much
information in the first time stamp. You are saying, in effect,
"here's a time stamp with both a valid sample time and a valid
host time, please give me the sample time". The HAL is happy to
oblige.
What you really want to say is "here's a time stamp with a valid
host time, please translate that to a sample time." To do this,
you just need to set kAudioTimeStampHostTimeValid in the flags
field of firstPlayTime.
But I (think) I'm doing that - the code above has the line
firstPlayTime.mFlags = kAudioTimeStampSampleHostTimeValid;
Isn't that what you meant ? I don't bother to zero out the other
fields in firstPlayTime but is that required if I just indicate
that only the host time is valid ?
--
Jeff Moore
Core Audio
Apple
_______________________________________________
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