• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Host Time epoch
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Host Time epoch


  • Subject: Re: Host Time epoch
  • From: Jeff Moore <email@hidden>
  • Date: Wed, 9 Feb 2005 15:09:45 -0800

The source of the time the HAL provides is the system bus clock. It is accessed via the routines in <mach/mach_time.h>. This counter is reset at boot time and increments monotonically at the system bus clock speed (I think). I'm not aware of any direct conversion routines that map this time base to the time base that gettimeofday(2) uses or that CFDate uses.

That said, you can always figure this out by sampling the two time bases to establish an anchor point to convert with. You would read the first time base, then the second, and then the first again. You can usually assume that the second time base's time is taken half way between the the times of the first time base. You want to do this a few times. Then you pick the sampling that had the smallest difference between the first time base's time.

Once you have the anchor point, you also need the slope between the two time bases to do the conversion (in other words the number of ticks it takes of one time base to equal a tick in the other). To get this, you have two choices. First you can assume that the system clock's conversion to nanoseconds doesn't drift. This is not a bad assumption to make as it is usually pretty accurate, so you can usually get away with. However since there is a limit to the precision of the nanosecond conversion, there is some error that will build up and cause drift over long durations. To get a more accurate reading of the conversion factor, you are going to need to sample the time bases over time and use the succeeding differences to figure out what the slope is (recall that the slope of a line defined as F(X) can be written as (F(X1) - F(X0)) / (X1 - X0)). You'll also want to keep updating this information while you are running to be sure that it stays up to date with what is going on in the hardware.

On Feb 9, 2005, at 1:56 PM, Geoff Schmidt wrote:

Hi,

Simple (?) newbie question I couldn't find answered in the docs or HostTime.h: How can I convert host timestamps (as is AudioGetCurrentHostTime or AudioTimeStamp.mHostTime) to a calendar date and wallclock time? In other words, a host time of 0 (or a 0 return value from AudioConvertHostTimeToNanos) corresponds to what absolute date and time?

This comes up because I am trying to synchronize audio playback between several machines on a network.


--

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
  • Follow-Ups:
    • Re: Host Time epoch
      • From: Steve Checkoway <email@hidden>
    • Re: Host Time epoch
      • From: John Iversen <email@hidden>
References: 
 >Host Time epoch (From: Geoff Schmidt <email@hidden>)

  • Prev by Date: Host Time epoch
  • Next by Date: Re: Host Time epoch
  • Previous by thread: Host Time epoch
  • Next by thread: Re: Host Time epoch
  • Index(es):
    • Date
    • Thread