• 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: AudioDeviceGetCurrentTime after headphone plug/unplug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AudioDeviceGetCurrentTime after headphone plug/unplug


  • Subject: Re: AudioDeviceGetCurrentTime after headphone plug/unplug
  • From: Bjorn Roche <email@hidden>
  • Date: Thu, 18 Jan 2007 16:30:35 -0500


On Jan 18, 2007, at 4:08 PM, Brant Sears wrote:

Hi. I've been following this thread, but I probably don't have the expertise in Core Audio to fully understand Jeff's statements.

I'm using PortAudio for a cross platform application and we ran into the "headphones" problem. We are relying on a PortAudio call that uses AudioDeviceGetCurrentTime(). There was some mention of using AudioDeviceTranslateTime() to work around this. I tried the following:

AudioTimeStamp timeStamp2;
AudioTimeStamp timeStamp;

memset(&timeStamp, 0, sizeof(AudioTimeStamp));
memset(&timeStamp2, 0, sizeof(AudioTimeStamp));
timeStamp.mFlags= kAudioTimeStampHostTimeValid;
timeStamp.mHostTime = AudioGetCurrentHostTime();
timeStamp2.mFlags = kAudioTimeStampSampleHostTimeValid;
AudioDeviceTranslateTime(stream->outputDevice, &timeStamp, &timeStamp2);


Then, I try to read the mSampleTime from timeStamp2. This is still not working for me. What am I doing wrong?

Hey Brant,

My guess is that stream->outputDevice is still referring to the old "device" (that is, the speakers rather than the headphones or vice versa), because PortAudio doesn't update its pointer when the underlying device changes. For now, the best thing to do is to use the data in the callback, as described here:

http://portaudio.com/docs/v19-doxydocs/ structPaStreamCallbackTimeInfo.html

I will try and provide some interpolation or something to work around this issue, but I don't know when I'll have time. If the accuracy of this time is critical, you'll have to use low latency, and that should get you pretty darn close.

I wish there was a really detailed (and simple to understand) book on CoreAudio. The documentation is confusing to me (but of course I'm no expert on audio in general).

The docs are not bad, but they are sparse. I learned CoreAudio by reading the draft PortAudio code that others wrote and the sparse notes about CoreAudio which at the time were on my computer, but not online, so I did not know they existed for a while (I'm not sure if this is still the case). The only reason I even knew about AUHAL was because someone on the PortAudio list knew an intern at apple who told us about it!!


	bjorn

-----------------------------
Bjorn Roche
XO Wave
Digital Audio Production and Post-Production Software
http://www.xowave.com
http://blog.bjornroche.com
http://myspace.com/xowave


_______________________________________________ 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: 
 >AudioDeviceGetCurrentTime after headphone plug/unplug (From: Bjorn Roche <email@hidden>)
 >Re: AudioDeviceGetCurrentTime after headphone plug/unplug (From: Jeff Moore <email@hidden>)
 >Re: AudioDeviceGetCurrentTime after headphone plug/unplug (From: Bjorn Roche <email@hidden>)
 >Re: AudioDeviceGetCurrentTime after headphone plug/unplug (From: Jeff Moore <email@hidden>)
 >Re: AudioDeviceGetCurrentTime after headphone plug/unplug (From: Brant Sears <email@hidden>)

  • Prev by Date: Re: AudioDeviceGetCurrentTime after headphone plug/unplug
  • Next by Date: Re: AudioDeviceGetCurrentTime after headphone plug/unplug
  • Previous by thread: Re: AudioDeviceGetCurrentTime after headphone plug/unplug
  • Next by thread: Re: AudioDeviceGetCurrentTime after headphone plug/unplug
  • Index(es):
    • Date
    • Thread