Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: AudioTimeStamp
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AudioTimeStamp




On Jul 7, 2009, at 13:36 , Doug Wyatt wrote:


On Jul 6, 2009, at 15:28 , Jeff Moore wrote:

As you can see from studying the CAHostTimeBase code, the time base being used is mach_absolute_time_t. This time base starts at 0 when the machine is booted. As such, it really is not the same thing as what you get with the CFDate API, which is generally speaking, anchored at like midnight January 1, 2001.

To my knowledge, there isn't a conversion between mach_absolute_time_t and what CFDate uses.


You can compute the host time of boot:

CFTimeInterval secondsSinceBoot = CAHostTimeBase::GetCurrentTimeInNanos() * 1.0e-9;
gettimeofday(&tv,NULL);
bootAbsoluteTime = ((double)tv.tv_sec - kCFTimeAbsoluteTimeIntervalSince1970) * 1.0e-6 * (double)tv.tv_usec - secondsSinceBoot;



oops, that should be:

bootAbsoluteTime = ((double)tv.tv_sec - kCFTimeAbsoluteTimeIntervalSince1970) + 1.0e-6 * (double)tv.tv_usec - secondsSinceBoot;

You'd want to do some caching to avoid calling gettimeofday too often.



On Jun 27, 2009, at 2:13 AM, Romain Pechayre wrote:

I'm using an audioRenderCallback for an audio unit remoteIO and I have problems with figuring out the real time out of the AudioTimeStamp pointer passed as argument to the callBack.
I am aware of the existence of the CAHostTimeBase class and I am using it. I am just wondering what time exactly is stored in this struct.
In fact, I want to know a which time the samples processed in my callback will be actually played in the future ( I mean the exact time at which the audio unit will play the first sample stored in the first buffer).
Is there a way to do this ?
I am currently doing th following :
CFTimeInterval beginTime = (Float64)CAHostTimeBase::ConvertToNanos (inTimeStamp->mHostTime) / 1000000000;
When I display the result of beginTime, it shows me some date in 2001. What am I doing the wrong way ? Should I be using another member of the struct AudioTimeStamp for my purpose ? Thank yo in advance for your help.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
@apple.com


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
References: 
 >Re: AudioTimeStamp (From: Jeff Moore <email@hidden>)
 >Re: AudioTimeStamp (From: Doug Wyatt <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.