• 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: Input callback timestamp reset and current sample time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Input callback timestamp reset and current sample time


  • Subject: Re: Input callback timestamp reset and current sample time
  • From: Jeff Moore <email@hidden>
  • Date: Tue, 27 Sep 2005 18:16:22 -0700


On Sep 27, 2005, at 4:10 PM, email@hidden wrote:

I believe that you can use the property,
kAudioOutputUnitProperty_StartTimestampsAtZero, to tell the instance
of AUHAL to not reset the sample time.


Thanks, that seems to work around one problem, but now I see the reverse problem. If I plug in headphones during playback, the timestamp in my input callback continues consistently, but now AudioDeviceGetCurrentTime resets to 0 and starts counting from there so the two timelines are again different. I assumed that setting kAudioOutputUnitProperty_StartTimestampsAtZero to false, would cause the audio unit to always use the current device's timeline, but that doesn't seem to be case.

Ah. I forgot about that. It tries to maintain the sample count properly across discontinuities in the HAL's timeline that it didn't cause, like plugging in headphones (which is a ghastly complicated process on some CPUs).


What do you do with this sample time?


I'm using the sample time to correlate the audio I'm giving to CoreAudio with information on another device. This requires me to know the sample index of the audio currently being played. This generally works, except in these cases where the AudioDeviceGetCurrentTime differs from the time passed to my input callback.

Is there a way to get a current timestamp that is always consistent
with the input callback? If I go the other way and use
AudioDeviceGetCurrentTime to construct my audio buffer (instead of the
input timestamp) and to get the current time (so both are always
consistent), then I run into 1-3 or so sample gaps here and there due
to the latency and time variation involved in my callback being called
(which is to be expected).

It seems like I need the equivalent of an AudioUnitGetCurrentTime
function. Does something like this exist (I couldn't find anything
like it)?

One of the good things about AUHAL is that the time stamps it provides also contain the host time that corresponds to the sample time. This allows you to use the HAL API call, AudioDeviceTranslateTime(), to map the sample time from AUHAL's timeline to a sample time in the HAL's timeline.


--

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: Input callback timestamp reset and current sample time
      • From: <email@hidden>
References: 
 >Input callback timestamp reset and current sample time (From: <email@hidden>)
 >Re: Input callback timestamp reset and current sample time (From: Jeff Moore <email@hidden>)
 >Re: Input callback timestamp reset and current sample time (From: <email@hidden>)

  • Prev by Date: Re: Input callback timestamp reset and current sample time
  • Next by Date: Re: Error -10838 calling MIDIClientCreate
  • Previous by thread: Re: Input callback timestamp reset and current sample time
  • Next by thread: Re: Input callback timestamp reset and current sample time
  • Index(es):
    • Date
    • Thread